Skip to content

Instantly share code, notes, and snippets.

View anozimada's full-sized avatar

Anozi Mada anozimada

View GitHub Profile
@anozimada
anozimada / AskInputProcess.java
Created April 7, 2023 13:37
Just testing Ask for Input in process
package org.idempiere.process;
import java.util.ArrayList;
import java.util.List;
import org.adempiere.util.Callback;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.MColumn;
import org.compiere.model.MLookup;
/* iDempiere NOTE:
Use this script to enable uuid generation JUST on postgresql versions prior to 9.1
For Postgresql 9.1, run the CREATE EXTENSION "uuid-ossp" sql command instead of using this script
*/
/* $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.sql.in,v 1.6 2007/11/13 04:24:29 momjian Exp $ */
-- Adjust this setting to control where the objects get created.
SET search_path = adempiere;
// http://www.adempiere.com/ADempiere_Best_Practices#How_to_use_PreparedStatement.2FResultSet_.3F
// How to use PreparedStatement/ResultSet ?
final String sql = "''your SQL SELECT code''";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
DB.setParameters(pstmt, new Object[]{...''parameters''...});
rs = pstmt.executeQuery();
@anozimada
anozimada / pg-tablesize.sql
Last active September 26, 2017 03:04
Get table sizes from specific schema in Postgresql
select table_name, pg_relation_size(quote_ident(table_name))
from information_schema.tables
where table_schema = 'adempiere'
order by 2 desc
@anozimada
anozimada / pg-kill-session.sql
Created February 9, 2017 03:55
Kill postgresql session/connection
--Before executing this query, you have to REVOKE the CONNECT privileges to avoid new connections:
REVOKE CONNECT ON DATABASE dbname FROM PUBLIC, username;
--PostgreSQL 9.2 and above:
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
-- don't kill my own connection!
@anozimada
anozimada / ZkJRViewer.java
Created October 1, 2013 10:31
Migrate ZK Jasper Viewer multiple preview from iDempiere to ADempiere
package org.adempiere.webui.window;
import java.io.File;
import java.io.FileOutputStream;
import java.util.logging.Level;
import javax.servlet.http.HttpServletRequest;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperExportManager;