List of usage examples for java.sql Connection prepareCall
CallableStatement prepareCall(String sql) throws SQLException;
CallableStatement
object for calling database stored procedures. From source file:com.cws.esolutions.core.dao.impl.ServerDataDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IServerDataDAO#addServer(java.util.List) *//*from ww w. j a v a2s . c om*/ public synchronized boolean addServer(final List<Object> serverData) throws SQLException { final String methodName = IServerDataDAO.CNAME + "#addServer(final List<Object> serverData) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); for (Object str : serverData) { DEBUGGER.debug("Value: {}", str); } } Connection sqlConn = null; boolean isComplete = false; CallableStatement stmt = null; try { sqlConn = dataSource.getConnection(); if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain application datasource connection"); } sqlConn.setAutoCommit(true); stmt = sqlConn.prepareCall( "{CALL insertNewServer(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}"); stmt.setString(1, (String) serverData.get(0)); // systemGuid stmt.setString(2, (String) serverData.get(1)); // systemOs stmt.setString(3, (String) serverData.get(2)); // systemStatus stmt.setString(4, (String) serverData.get(3)); // systemRegion stmt.setString(5, (String) serverData.get(4)); // networkPartiton stmt.setString(6, (String) serverData.get(5)); // datacenter stmt.setString(7, (String) serverData.get(6)); // systemType stmt.setString(8, (String) serverData.get(7)); // domainName stmt.setString(9, (String) serverData.get(8)); // cpuType stmt.setInt(10, (Integer) serverData.get(9)); // cpuCount stmt.setString(11, (String) serverData.get(10)); // serverModel stmt.setString(12, (String) serverData.get(11)); // serialNumber stmt.setInt(13, (Integer) serverData.get(12)); // installedMemory stmt.setString(14, (String) serverData.get(13)); // operIp stmt.setString(15, (String) serverData.get(14)); // operHostname stmt.setString(16, (String) serverData.get(15)); // mgmtIp stmt.setString(17, (String) serverData.get(16)); // mgmtHostname stmt.setString(18, (String) serverData.get(17)); // backupIp stmt.setString(19, (String) serverData.get(18)); // backupHostname stmt.setString(20, (String) serverData.get(19)); // nasIp stmt.setString(21, (String) serverData.get(20)); // nasHostname stmt.setString(22, (String) serverData.get(21)); // natAddr stmt.setString(23, (String) serverData.get(22)); // systemComments stmt.setString(24, (String) serverData.get(23)); // engineer stmt.setString(25, (String) serverData.get(24)); // mgrEntry stmt.setInt(26, (Integer) serverData.get(25)); // dmgrPort stmt.setString(27, (String) serverData.get(26)); // serverRack stmt.setString(28, (String) serverData.get(27)); // rackPosition stmt.setString(29, (String) serverData.get(28)); // owningDmgr if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } isComplete = (!(stmt.execute())); if (DEBUG) { DEBUGGER.debug("isComplete: {}", isComplete); } } catch (SQLException sqx) { throw new SQLException(sqx.getMessage(), sqx); } finally { if (stmt != null) { stmt.close(); } if ((sqlConn != null) && (!(sqlConn.isClosed()))) { sqlConn.close(); } } return isComplete; }
From source file:com.cws.esolutions.core.dao.impl.ServerDataDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IServerDataDAO#updateServer(java.lang.String, java.util.List) *//*from www .j a v a 2 s.c om*/ public synchronized boolean updateServer(final String serverGuid, final List<Object> serverData) throws SQLException { final String methodName = IServerDataDAO.CNAME + "#updateServer(final String serverGuid, final List<Object> serverData) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", serverGuid); for (Object str : serverData) { DEBUGGER.debug("Value: {}", str); } } Connection sqlConn = null; boolean isComplete = false; CallableStatement stmt = null; try { sqlConn = dataSource.getConnection(); if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain application datasource connection"); } sqlConn.setAutoCommit(true); stmt = sqlConn.prepareCall( "{CALL updateServerData(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}"); stmt.setString(1, serverGuid); // systemGuid stmt.setString(2, (String) serverData.get(1)); // systemOs stmt.setString(3, (String) serverData.get(2)); // systemStatus stmt.setString(4, (String) serverData.get(3)); // systemRegion stmt.setString(5, (String) serverData.get(4)); // networkPartiton stmt.setString(6, (String) serverData.get(5)); // datacenter stmt.setString(7, (String) serverData.get(6)); // systemType stmt.setString(8, (String) serverData.get(7)); // domainName stmt.setString(9, (String) serverData.get(8)); // cpuType stmt.setInt(10, (Integer) serverData.get(9)); // cpuCount stmt.setString(11, (String) serverData.get(10)); // serverModel stmt.setString(12, (String) serverData.get(11)); // serialNumber stmt.setInt(13, (Integer) serverData.get(12)); // installedMemory stmt.setString(14, (String) serverData.get(13)); // operIp stmt.setString(15, (String) serverData.get(14)); // operHostname stmt.setString(16, (String) serverData.get(15)); // mgmtIp stmt.setString(17, (String) serverData.get(16)); // mgmtHostname stmt.setString(18, (String) serverData.get(17)); // backupIp stmt.setString(19, (String) serverData.get(18)); // backupHostname stmt.setString(20, (String) serverData.get(19)); // nasIp stmt.setString(21, (String) serverData.get(20)); // nasHostname stmt.setString(22, (String) serverData.get(21)); // natAddr stmt.setString(23, (String) serverData.get(22)); // systemComments stmt.setString(24, (String) serverData.get(23)); // engineer stmt.setString(25, (String) serverData.get(24)); // mgrEntry stmt.setInt(26, (Integer) serverData.get(25)); // dmgrPort stmt.setString(27, (String) serverData.get(26)); // serverRack stmt.setString(28, (String) serverData.get(27)); // rackPosition stmt.setString(29, (String) serverData.get(28)); // owningDmgr if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } isComplete = (!(stmt.execute())); if (DEBUG) { DEBUGGER.debug("isComplete: {}", isComplete); } } catch (SQLException sqx) { throw new SQLException(sqx.getMessage(), sqx); } finally { if (stmt != null) { stmt.close(); } if ((sqlConn != null) && (!(sqlConn.isClosed()))) { sqlConn.close(); } } return isComplete; }
From source file:com.bstek.dorado.core.store.SqlBaseStoreSupport.java
protected void runInitScriptFile(Connection conn, Resource initScriptFile) throws Exception { InputStream is = initScriptFile.getInputStream(); try {//from ww w.ja va 2 s.c om InputStreamReader isr = new InputStreamReader(is, StringUtils.defaultIfEmpty(scriptFileCharset, Constants.DEFAULT_CHARSET)); BufferedReader br = new BufferedReader(isr); StringBuffer scripts = new StringBuffer(); String line = br.readLine(); while (line != null) { scripts.append(line).append('\n'); line = br.readLine(); } if (scripts.length() > 0) { CallableStatement prepareCall = conn.prepareCall(scripts.toString()); try { prepareCall.execute(); } finally { prepareCall.close(); } } br.close(); isr.close(); } finally { is.close(); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleAuditActionTable.java
public void createAuditAction(CFSecurityAuthorization Authorization, CFSecurityAuditActionBuff Buff) { final String S_ProcName = "createAuditAction"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//w ww .jav a 2s.com ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { short AuditActionId = Buff.getRequiredAuditActionId(); String Description = Buff.getRequiredDescription(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_auditaction( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "AUDT"); stmtCreateByPKey.setShort(argIdx++, AuditActionId); stmtCreateByPKey.setString(argIdx++, Description); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a result set"); } try { if (resultSet.next()) { CFSecurityAuditActionBuff createdBuff = unpackAuditActionResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredAuditActionId(createdBuff.getRequiredAuditActionId()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleAuditActionTable.java
public void createAuditAction(CFAccAuthorization Authorization, CFAccAuditActionBuff Buff) { final String S_ProcName = "createAuditAction"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w ww .ja va2 s .c o m ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { short AuditActionId = Buff.getRequiredAuditActionId(); String Description = Buff.getRequiredDescription(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".crt_auditaction( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "AUDT"); stmtCreateByPKey.setShort(argIdx++, AuditActionId); stmtCreateByPKey.setString(argIdx++, Description); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a result set"); } try { if (resultSet.next()) { CFAccAuditActionBuff createdBuff = unpackAuditActionResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredAuditActionId(createdBuff.getRequiredAuditActionId()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstOracle.CFAstOracleAuditActionTable.java
public void createAuditAction(CFAstAuthorization Authorization, CFAstAuditActionBuff Buff) { final String S_ProcName = "createAuditAction"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from w w w . j av a 2s. co m*/ ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { short AuditActionId = Buff.getRequiredAuditActionId(); String Description = Buff.getRequiredDescription(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".crt_auditaction( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "AUDT"); stmtCreateByPKey.setShort(argIdx++, AuditActionId); stmtCreateByPKey.setString(argIdx++, Description); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a result set"); } try { if (resultSet.next()) { CFAstAuditActionBuff createdBuff = unpackAuditActionResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredAuditActionId(createdBuff.getRequiredAuditActionId()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstOracle.CFAstOracleAuditActionTable.java
public void createAuditAction(CFAstAuthorization Authorization, CFAstAuditActionBuff Buff) { final String S_ProcName = "createAuditAction"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w ww . j av a 2s .c om ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { short AuditActionId = Buff.getRequiredAuditActionId(); String Description = Buff.getRequiredDescription(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_auditaction( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "AUDT"); stmtCreateByPKey.setShort(argIdx++, AuditActionId); stmtCreateByPKey.setString(argIdx++, Description); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a result set"); } try { if (resultSet.next()) { CFAstAuditActionBuff createdBuff = unpackAuditActionResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredAuditActionId(createdBuff.getRequiredAuditActionId()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleSysClusterTable.java
public void createSysCluster(CFSecurityAuthorization Authorization, CFSecuritySysClusterBuff Buff) { final String S_ProcName = "createSysCluster"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//www .java 2s . c o m ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { int SingletonId = Buff.getRequiredSingletonId(); long ClusterId = Buff.getRequiredClusterId(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_sysclus( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "SYSC"); stmtCreateByPKey.setInt(argIdx++, SingletonId); stmtCreateByPKey.setLong(argIdx++, ClusterId); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_sysclus() did not return a result set"); } try { if (resultSet.next()) { CFSecuritySysClusterBuff createdBuff = unpackSysClusterResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredSingletonId(createdBuff.getRequiredSingletonId()); Buff.setRequiredClusterId(createdBuff.getRequiredClusterId()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_sysclus() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }
From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswOracle.CFFswOracleAuditActionTable.java
public void createAuditAction(CFFswAuthorization Authorization, CFFswAuditActionBuff Buff) { final String S_ProcName = "createAuditAction"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from w w w . ja va 2 s . co m*/ ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { short AuditActionId = Buff.getRequiredAuditActionId(); String Description = Buff.getRequiredDescription(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_auditaction( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "AUDT"); stmtCreateByPKey.setShort(argIdx++, AuditActionId); stmtCreateByPKey.setString(argIdx++, Description); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a result set"); } try { if (resultSet.next()) { CFFswAuditActionBuff createdBuff = unpackAuditActionResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredAuditActionId(createdBuff.getRequiredAuditActionId()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }
From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxOracle.CFEnSyntaxOracleAuditActionTable.java
public void createAuditAction(CFEnSyntaxAuthorization Authorization, CFEnSyntaxAuditActionBuff Buff) { final String S_ProcName = "createAuditAction"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w w w .ja v a 2 s .c om ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { short AuditActionId = Buff.getRequiredAuditActionId(); String Description = Buff.getRequiredDescription(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_auditaction( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "AUDT"); stmtCreateByPKey.setShort(argIdx++, AuditActionId); stmtCreateByPKey.setString(argIdx++, Description); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a result set"); } try { if (resultSet.next()) { CFEnSyntaxAuditActionBuff createdBuff = unpackAuditActionResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredAuditActionId(createdBuff.getRequiredAuditActionId()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_auditaction() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }