Search in sources :

Example 1 with RowSet

use of javax.sql.RowSet in project adempiere by adempiere.

the class SimulatedPickList method print.

/**
	 * Print result generate for this report
	 */
void print() throws Exception {
    // Base Language
    Language language = Language.getLoginLanguage();
    MPrintFormat pf = null;
    int pfid = 0;
    // get print format for client, else copy system to client
    RowSet pfrs = MPrintFormat.getAccessiblePrintFormats(MTable.getTable_ID(X_RV_PP_Product_BOMLine_Storage_TableName), -1, null);
    pfrs.next();
    pfid = pfrs.getInt("AD_PrintFormat_ID");
    if (pfrs.getInt("AD_Client_ID") != 0)
        pf = MPrintFormat.get(getCtx(), pfid, false);
    else
        pf = MPrintFormat.copyToClient(getCtx(), pfid, getAD_Client_ID());
    pfrs.close();
    if (pf == null)
        raiseError("Error: ", "No Print Format");
    pf.setLanguage(language);
    pf.setTranslationLanguage(language);
    // query
    MQuery query = new MQuery(X_RV_PP_Product_BOMLine_Storage_TableName);
    query.addRestriction(X_T_BOMLine.COLUMNNAME_AD_PInstance_ID, MQuery.EQUAL, AD_PInstance_ID, getParamenterName(X_T_BOMLine.COLUMNNAME_AD_PInstance_ID), getParamenterInfo(X_T_BOMLine.COLUMNNAME_AD_PInstance_ID));
    query.addRestriction(X_T_BOMLine.COLUMNNAME_M_Warehouse_ID, MQuery.EQUAL, p_M_Warehouse_ID, getParamenterName(X_T_BOMLine.COLUMNNAME_M_Warehouse_ID), getParamenterInfo(X_T_BOMLine.COLUMNNAME_M_Warehouse_ID));
    query.addRestriction(X_T_BOMLine.COLUMNNAME_M_Warehouse_ID, MQuery.EQUAL, p_M_Warehouse_ID, getParamenterName("DateTrx"), getParamenterInfo("DateTrx"));
    PrintInfo info = new PrintInfo(X_RV_PP_Product_BOMLine_Storage_TableName, MTable.getTable_ID(X_RV_PP_Product_BOMLine_Storage_TableName), getRecord_ID());
    ReportEngine re = new ReportEngine(getCtx(), pf, query, info);
    ReportCtl.preview(re);
    // records are deleted when process ends
    while (re.getView().isDisplayable()) {
        Env.sleep(1);
    }
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) Language(org.compiere.util.Language) RowSet(javax.sql.RowSet) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo)

Example 2 with RowSet

use of javax.sql.RowSet in project adempiere by adempiere.

the class PrintBOM method print.

/**
	 * Print result generate for this report
	 */
void print() throws Exception {
    // Base Language
    Language language = Language.getLoginLanguage();
    MPrintFormat pf = null;
    int pfid = 0;
    // get print format for client, else copy system to client  
    RowSet pfrs = MPrintFormat.getAccessiblePrintFormats(X_RV_PP_Product_BOMLine_Table_ID, -1, null);
    pfrs.next();
    pfid = pfrs.getInt("AD_PrintFormat_ID");
    if (pfrs.getInt("AD_Client_ID") != 0)
        pf = MPrintFormat.get(getCtx(), pfid, false);
    else
        pf = MPrintFormat.copyToClient(getCtx(), pfid, getAD_Client_ID());
    pfrs.close();
    if (pf == null)
        raiseError("Error: ", "No Print Format");
    pf.setLanguage(language);
    pf.setTranslationLanguage(language);
    // query
    MQuery query = MQuery.get(getCtx(), AD_PInstance_ID, X_RV_PP_Product_BOMLine_Table_Name);
    query.addRestriction("AD_PInstance_ID", MQuery.EQUAL, AD_PInstance_ID);
    PrintInfo info = new PrintInfo(X_RV_PP_Product_BOMLine_Table_Name, X_RV_PP_Product_BOMLine_Table_ID, getRecord_ID());
    ReportEngine re = new ReportEngine(getCtx(), pf, query, info);
    ReportCtl.preview(re);
    // records are deleted when process ends 
    while (re.getView().isDisplayable()) {
        Env.sleep(1);
    }
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) Language(org.compiere.util.Language) RowSet(javax.sql.RowSet) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo)

Example 3 with RowSet

use of javax.sql.RowSet in project adempiere by adempiere.

the class DB method getRowSet.

//	commit
/**
	 * 	Get Row Set.
	 * 	When a Rowset is closed, it also closes the underlying connection.
	 * 	If the created RowSet is transfered by RMI, closing it makes no difference
	 *	@param sql sql
	 *	@param local local RowSet (own connection)
	 *	@return row set or null
	 */
public static RowSet getRowSet(String sql) {
    // Bugfix Gunther Hoppe, 02.09.2005, vpj-cd e-evolution
    // praneet - giving issues with mysql, doing a quick fix for now
    CStatementVO info;
    if (DB.isOracle() || DB.isPostgreSQL())
        info = new CStatementVO(RowSet.TYPE_SCROLL_INSENSITIVE, RowSet.CONCUR_READ_ONLY, DB.getDatabase().convertStatement(sql));
    else
        info = new CStatementVO(RowSet.TYPE_SCROLL_INSENSITIVE, RowSet.CONCUR_READ_ONLY, sql);
    //dete fix convert statement
    CPreparedStatement stmt = ProxyFactory.newCPreparedStatement(info);
    RowSet retValue = stmt.getRowSet();
    close(stmt);
    return retValue;
}
Also used : RowSet(javax.sql.RowSet)

Example 4 with RowSet

use of javax.sql.RowSet in project adempiere by adempiere.

the class ReplicationLocal method mergeData.

//	setupRemote
/*************************************************************************/
/**
	 * 	Receive new Data from Remote.
	 * 	@throws Exception
	 */
private void mergeData() throws Exception {
    log.info("mergeData");
    //
    String sql = "SELECT rt.AD_Table_ID, rt.ReplicationType, t.TableName, rt.AD_ReplicationTable_ID " + "FROM AD_ReplicationTable rt" + " INNER JOIN AD_Table t ON (rt.AD_Table_ID=t.AD_Table_ID) " + "WHERE rt.IsActive='Y' AND t.IsActive='Y'" + //	#1
    " AND AD_ReplicationStrategy_ID=?" + //	Merge
    " AND rt.ReplicationType='M' " + "ORDER BY t.LoadSeq";
    RowSet rowset = getRowSet(sql, new Object[] { new Integer(m_replication.getAD_ReplicationStrategy_ID()) });
    try {
        while (rowset.next()) mergeDataTable(rowset.getInt(1), rowset.getString(3), rowset.getInt(4));
        rowset.close();
        rowset = null;
    } catch (SQLException ex) {
        log.log(Level.SEVERE, "mergeData", ex);
        m_replicated = false;
    }
}
Also used : SQLException(java.sql.SQLException) RowSet(javax.sql.RowSet) CCachedRowSet(org.compiere.util.CCachedRowSet)

Example 5 with RowSet

use of javax.sql.RowSet in project adempiere by adempiere.

the class ReplicationLocal method getRowSet.

//	exit
/**************************************************************************
	 * 	Get RowSet of Local Connection
	 *	@param sql sql
	 * 	@param args optional argument array - supported: Integer, Timestamp, BigDecimal - rest is concerted to String
	 *	@return row set
	 */
public static RowSet getRowSet(String sql, Object[] args) {
    //	shared connection
    Connection conn = DB.getConnectionRO();
    PreparedStatement pstmt = null;
    RowSet rowSet = null;
    //
    try {
        pstmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        //	Set Parameters
        if (args != null) {
            for (int i = 0; i < args.length; i++) {
                if (args[i] == null)
                    s_log.log(Level.SEVERE, "NULL Argument " + i);
                else if (args[i] instanceof Integer)
                    pstmt.setInt(i + 1, ((Integer) args[i]).intValue());
                else if (args[i] instanceof Timestamp)
                    pstmt.setTimestamp(i + 1, (Timestamp) args[i]);
                else if (args[i] instanceof BigDecimal)
                    pstmt.setBigDecimal(i + 1, (BigDecimal) args[i]);
                else
                    pstmt.setString(i + 1, args[i].toString());
            }
        }
        //
        ResultSet rs = pstmt.executeQuery();
        rowSet = CCachedRowSet.getRowSet(rs);
        pstmt.close();
        pstmt = null;
    } catch (Exception ex) {
        s_log.log(Level.SEVERE, sql, ex);
        throw new RuntimeException(ex);
    }
    //	Close Cursor
    try {
        if (pstmt != null)
            pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        s_log.log(Level.SEVERE, "close pstmt", e);
    }
    return rowSet;
}
Also used : Connection(java.sql.Connection) CConnection(org.compiere.db.CConnection) RowSet(javax.sql.RowSet) CCachedRowSet(org.compiere.util.CCachedRowSet) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp) BigDecimal(java.math.BigDecimal) SQLException(java.sql.SQLException)

Aggregations

RowSet (javax.sql.RowSet)19 SQLException (java.sql.SQLException)8 CCachedRowSet (org.compiere.util.CCachedRowSet)7 ResultSet (java.sql.ResultSet)3 PreparedStatement (java.sql.PreparedStatement)2 Timestamp (java.sql.Timestamp)2 Properties (java.util.Properties)2 CachedRowSet (javax.sql.rowset.CachedRowSet)2 JoinRowSet (javax.sql.rowset.JoinRowSet)2 WebRowSet (javax.sql.rowset.WebRowSet)2 DBException (org.adempiere.exceptions.DBException)2 MQuery (org.compiere.model.MQuery)2 PrintInfo (org.compiere.model.PrintInfo)2 MPrintFormat (org.compiere.print.MPrintFormat)2 ReportEngine (org.compiere.print.ReportEngine)2 KeyNamePair (org.compiere.util.KeyNamePair)2 Language (org.compiere.util.Language)2 Test (org.testng.annotations.Test)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 BigDecimal (java.math.BigDecimal)1