Search in sources :

Example 11 with RowSet

use of javax.sql.RowSet in project jdk8u_jdk by JetBrains.

the class JoinRowSetTests method joinRowSetTests0002.

/*
     * Join two CachedRowSets specifying a column name to join against
     */
@Test(dataProvider = "createCachedRowSetsToUse")
public void joinRowSetTests0002(CachedRowSet crs, CachedRowSet crs1) throws Exception {
    try (JoinRowSet jrs = newInstance()) {
        RowSet[] rowsets = { crs, crs1 };
        String[] joinCols = { JOIN_COLNAME, JOIN_COLNAME };
        jrs.addRowSet(rowsets, joinCols);
        validateResults(jrs);
        crs.close();
        crs1.close();
    }
}
Also used : JoinRowSet(javax.sql.rowset.JoinRowSet) JoinRowSet(javax.sql.rowset.JoinRowSet) WebRowSet(javax.sql.rowset.WebRowSet) CachedRowSet(javax.sql.rowset.CachedRowSet) RowSet(javax.sql.RowSet) Test(org.testng.annotations.Test)

Example 12 with RowSet

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

the class PreparedStatementProxy method getRowSet.

@Override
protected RowSet getRowSet() {
    log.finest("local_getRowSet");
    RowSet rowSet = null;
    ResultSet rs = null;
    PreparedStatement pstmt = (PreparedStatement) p_stmt;
    try {
        rs = pstmt.executeQuery();
        rowSet = CCachedRowSet.getRowSet(rs);
    } catch (Exception ex) {
        log.log(Level.SEVERE, p_vo.toString(), ex);
        throw new RuntimeException(ex);
    } finally {
        DB.close(rs);
    }
    return rowSet;
}
Also used : RowSet(javax.sql.RowSet) CCachedRowSet(org.compiere.util.CCachedRowSet) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) DBException(org.adempiere.exceptions.DBException)

Example 13 with RowSet

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

the class StatementProxy method getRowSet.

//	close
/**
	 * 	Execute Query
	 * 	@return ResultSet or RowSet
	 * 	@throws SQLException
	 *  @see java.sql.PreparedStatement#executeQuery()
	 */
protected RowSet getRowSet() {
    log.finest("getRowSet");
    RowSet rowSet = null;
    ResultSet rs = null;
    try {
        rs = p_stmt.executeQuery(p_vo.getSql());
        rowSet = CCachedRowSet.getRowSet(rs);
    } catch (Exception ex) {
        log.log(Level.SEVERE, p_vo.toString(), ex);
        throw new RuntimeException(ex);
    } finally {
        DB.close(rs);
    }
    return rowSet;
}
Also used : RowSet(javax.sql.RowSet) CCachedRowSet(org.compiere.util.CCachedRowSet) ResultSet(java.sql.ResultSet) InvocationTargetException(java.lang.reflect.InvocationTargetException) DBException(org.adempiere.exceptions.DBException) SQLException(java.sql.SQLException)

Example 14 with RowSet

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

the class MPrintFormat method getAccessiblePrintFormats.

//end vpj-cd e-evolution
/**
	 * @param AD_Table_ID
	 * @param AD_Client_ID use -1 to retrieve from all client 
	 * @param trxName
	 */
public static RowSet getAccessiblePrintFormats(int AD_Table_ID, int AD_Client_ID, String trxName) {
    RowSet rowSet = null;
    String sql = "SELECT AD_PrintFormat_ID, Name, AD_Client_ID " + "FROM AD_PrintFormat " + "WHERE AD_Table_ID=? AND IsTableBased='Y' ";
    if (AD_Client_ID >= 0) {
        sql = sql + " AND AD_Client_ID = ? ";
    }
    //	Own First 
    sql = sql + "ORDER BY AD_Client_ID DESC, IsDefault DESC, Name";
    //
    sql = MRole.getDefault().addAccessSQL(sql, "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    CPreparedStatement pstmt = null;
    try {
        pstmt = DB.prepareStatement(sql, trxName);
        pstmt.setInt(1, AD_Table_ID);
        if (AD_Client_ID >= 0)
            pstmt.setInt(2, AD_Client_ID);
        rowSet = pstmt.getRowSet();
    } catch (SQLException e) {
        s_log.log(Level.SEVERE, sql, e);
    } finally {
        DB.close(pstmt);
        pstmt = null;
    }
    return rowSet;
}
Also used : SQLException(java.sql.SQLException) RowSet(javax.sql.RowSet) CPreparedStatement(org.compiere.util.CPreparedStatement)

Example 15 with RowSet

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

the class ReplicationLocal method mergeDataTable.

//	mergeData
/**
	 * 	Receive New Data from Remote (and send local updates)
	 * 	@param AD_Table_ID table id
	 * 	@param TableName table name
	 * 	@param AD_ReplicationTable_ID id
	 * 	@return true if success
	 * 	@throws java.lang.Exception
	 */
private boolean mergeDataTable(int AD_Table_ID, String TableName, int AD_ReplicationTable_ID) throws Exception {
    RemoteMergeDataVO data = new RemoteMergeDataVO();
    data.Test = m_test;
    data.TableName = TableName;
    //	Create SQL
    StringBuffer sql = new StringBuffer("SELECT * FROM ").append(TableName).append(" WHERE AD_Client_ID=").append(m_replication.getRemote_Client_ID());
    if (m_replication.getRemote_Org_ID() != 0)
        sql.append(" AND AD_Org_ID IN (0,").append(m_replication.getRemote_Org_ID()).append(")");
    if (m_replication.getDateLastRun() != null)
        sql.append(" AND Updated >= ").append(DB.TO_DATE(m_replication.getDateLastRun(), false));
    sql.append(" ORDER BY ");
    data.KeyColumns = getKeyColumns(AD_Table_ID);
    if (data.KeyColumns == null || data.KeyColumns.length == 0) {
        log.log(Level.SEVERE, "mergeDataTable - No KeyColumns for " + TableName);
        m_replicated = false;
        return false;
    }
    for (int i = 0; i < data.KeyColumns.length; i++) {
        if (i > 0)
            sql.append(",");
        sql.append(data.KeyColumns[i]);
    }
    data.Sql = sql.toString();
    //	New Central Data
    data.CentralData = getRowSet(data.Sql, null);
    if (data.CentralData == null) {
        log.fine("mergeDataTable - CentralData is Null - " + TableName);
        m_replicated = false;
        return false;
    }
    //	Process Info
    ProcessInfo pi = new ProcessInfo("MergeData", 0);
    pi.setClassName(REMOTE);
    pi.setSerializableObject(data);
    //	send it
    pi = m_serverRemote.process(new Properties(), pi);
    ProcessInfoLog[] logs = pi.getLogs();
    String msg = "< ";
    if (logs != null && logs.length > 0)
        //	Remote Message
        msg += logs[0].getP_Msg();
    log.info("mergeDataTable - " + pi);
    //
    MReplicationLog rLog = new MReplicationLog(getCtx(), m_replicationRun.getAD_Replication_Run_ID(), AD_ReplicationTable_ID, msg, get_TrxName());
    if (pi.isError()) {
        log.severe("mergeDataTable Error - " + pi);
        m_replicated = false;
        rLog.setIsReplicated(false);
    } else //	import data fom remote
    {
        RowSet sourceRS = (RowSet) pi.getSerializableObject();
        RowSet targetRS = getRowSet(data.Sql, null);
        Object result = doIt(START, "sync", new //	Merge
        Object[] { data.TableName, data.KeyColumns, sourceRS, targetRS, m_test, Boolean.TRUE });
        boolean replicated = isReplicated(result);
        if (replicated)
            log.fine("mergeDataTable -> " + TableName + " - " + result);
        else {
            m_replicated = false;
            log.severe("mergeDataTable -> " + TableName + " - " + result);
        }
        rLog.setIsReplicated(replicated);
        if (result != null)
            rLog.setP_Msg("< " + result.toString());
        sourceRS.close();
        sourceRS = null;
        targetRS.close();
        targetRS = null;
    }
    rLog.saveEx();
    return !pi.isError();
}
Also used : MReplicationLog(org.compiere.model.MReplicationLog) RowSet(javax.sql.RowSet) CCachedRowSet(org.compiere.util.CCachedRowSet) Properties(java.util.Properties)

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