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:net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswOracle.CFFswOracleAuditActionTable.java
public CFFswAuditActionBuff readBuffByUDescrIdx(CFFswAuthorization Authorization, String Description) { final String S_ProcName = "readBuffByUDescrIdx"; ResultSet resultSet = null;//www .ja v a 2 s . c o m Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByUDescrIdx = null; try { stmtReadBuffByUDescrIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".rd_auditactionbyudescridx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByUDescrIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByUDescrIdx.setString(argIdx++, Description); stmtReadBuffByUDescrIdx.execute(); resultSet = (ResultSet) stmtReadBuffByUDescrIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFFswAuditActionBuff buff = unpackAuditActionResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByUDescrIdx != null) { try { stmtReadBuffByUDescrIdx.close(); } catch (SQLException e) { } stmtReadBuffByUDescrIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxOracle.CFEnSyntaxOracleAuditActionTable.java
public CFEnSyntaxAuditActionBuff readBuffByUDescrIdx(CFEnSyntaxAuthorization Authorization, String Description) {/*from w w w . j a v a 2 s.c o m*/ final String S_ProcName = "readBuffByUDescrIdx"; ResultSet resultSet = null; Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByUDescrIdx = null; try { stmtReadBuffByUDescrIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".rd_auditactionbyudescridx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByUDescrIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByUDescrIdx.setString(argIdx++, Description); stmtReadBuffByUDescrIdx.execute(); resultSet = (ResultSet) stmtReadBuffByUDescrIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFEnSyntaxAuditActionBuff buff = unpackAuditActionResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByUDescrIdx != null) { try { stmtReadBuffByUDescrIdx.close(); } catch (SQLException e) { } stmtReadBuffByUDescrIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleSecDeviceTable.java
public void createSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) { final String S_ProcName = "createSecDevice"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//w w w.j a va 2 s. c o m ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { UUID SecUserId = Buff.getRequiredSecUserId(); String DevName = Buff.getRequiredDevName(); String PubKey = Buff.getOptionalPubKey(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_secdev( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); 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++, "SDEV"); stmtCreateByPKey.setString(argIdx++, SecUserId.toString()); stmtCreateByPKey.setString(argIdx++, DevName); if (PubKey != null) { stmtCreateByPKey.setString(argIdx++, PubKey); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.CLOB); } stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_secdev() did not return a result set"); } try { if (resultSet.next()) { CFSecuritySecDeviceBuff createdBuff = unpackSecDeviceResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId()); Buff.setRequiredDevName(createdBuff.getRequiredDevName()); Buff.setOptionalPubKey(createdBuff.getOptionalPubKey()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } 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_secdev() 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.CFAsteriskOracleAuditActionTable.java
public void deleteAuditAction(CFSecurityAuthorization Authorization, CFSecurityAuditActionBuff Buff) { final String S_ProcName = "deleteAuditAction"; Connection cnx = schema.getCnx(); CallableStatement stmtDeleteByPKey = null; try {//from ww w. j a va 2 s . c om short AuditActionId = Buff.getRequiredAuditActionId(); stmtDeleteByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".dl_auditaction( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPKey.setShort(argIdx++, AuditActionId); stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision()); ; stmtDeleteByPKey.execute(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtDeleteByPKey != null) { try { stmtDeleteByPKey.close(); } catch (SQLException e) { } stmtDeleteByPKey = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleSysClusterTable.java
public void deleteSysCluster(CFSecurityAuthorization Authorization, CFSecuritySysClusterBuff Buff) { final String S_ProcName = "deleteSysCluster"; Connection cnx = schema.getCnx(); CallableStatement stmtDeleteByPKey = null; try {/*from ww w. jav a 2 s .co m*/ int SingletonId = Buff.getRequiredSingletonId(); stmtDeleteByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".dl_sysclus( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPKey.setInt(argIdx++, SingletonId); stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision()); ; stmtDeleteByPKey.execute(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtDeleteByPKey != null) { try { stmtDeleteByPKey.close(); } catch (SQLException e) { } stmtDeleteByPKey = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstOracle.CFAstOracleSysClusterTable.java
public CFAstSysClusterBuff readBuffByIdIdx(CFAstAuthorization Authorization, int SingletonId) { final String S_ProcName = "readBuffByIdIdx"; ResultSet resultSet = null;/*from www.j av a 2 s. c o m*/ Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByIdIdx = null; try { stmtReadBuffByIdIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".rd_sysclusbyididx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByIdIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByIdIdx.setInt(argIdx++, SingletonId); stmtReadBuffByIdIdx.execute(); resultSet = (ResultSet) stmtReadBuffByIdIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFAstSysClusterBuff buff = unpackSysClusterResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByIdIdx != null) { try { stmtReadBuffByIdIdx.close(); } catch (SQLException e) { } stmtReadBuffByIdIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleServiceTypeTable.java
public CFSecurityServiceTypeBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, int ServiceTypeId) { final String S_ProcName = "readBuffByIdIdx"; ResultSet resultSet = null;/*from w w w . java 2s .com*/ Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByIdIdx = null; try { stmtReadBuffByIdIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".rd_svctypebyididx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByIdIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByIdIdx.setInt(argIdx++, ServiceTypeId); stmtReadBuffByIdIdx.execute(); resultSet = (ResultSet) stmtReadBuffByIdIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFSecurityServiceTypeBuff buff = unpackServiceTypeResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByIdIdx != null) { try { stmtReadBuffByIdIdx.close(); } catch (SQLException e) { } stmtReadBuffByIdIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleMimeTypeTable.java
public CFInternetMimeTypeBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, int MimeTypeId) { final String S_ProcName = "readBuffByIdIdx"; ResultSet resultSet = null;//from ww w.j a va2s. c o m Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByIdIdx = null; try { stmtReadBuffByIdIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".rd_mimetypebyididx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByIdIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByIdIdx.setInt(argIdx++, MimeTypeId); stmtReadBuffByIdIdx.execute(); resultSet = (ResultSet) stmtReadBuffByIdIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFInternetMimeTypeBuff buff = unpackMimeTypeResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByIdIdx != null) { try { stmtReadBuffByIdIdx.close(); } catch (SQLException e) { } stmtReadBuffByIdIdx = null; } } }
From source file:com.cws.esolutions.core.dao.impl.ServiceDataDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IServiceDataDAO#getService(java.lang.String) */// ww w . j a va2 s.co m public synchronized List<String> getService(final String attribute) throws SQLException { final String methodName = IServiceDataDAO.CNAME + "#getService(final String attribute) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("attribute: {}", attribute); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<String> responseData = null; try { sqlConn = dataSource.getConnection(); if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain application datasource connection"); } sqlConn.setAutoCommit(true); // we dont know what we have here - it could be a guid or it could be a hostname // most commonly it'll be a guid, but we're going to search anyway stmt = sqlConn.prepareCall("{ CALL getServiceData(?) }"); stmt.setString(1, attribute); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (stmt.execute()) { resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("resultSet: {}", resultSet); } if (resultSet.next()) { resultSet.first(); responseData = new ArrayList<String>(Arrays.asList(resultSet.getString(1), // SERVICE_TYPE resultSet.getString(2), // NAME resultSet.getString(3), // REGION resultSet.getString(4), // NWPARTITION resultSet.getString(5), // STATUS resultSet.getString(6), // SERVERS resultSet.getString(7))); // DESCRIPTION if (DEBUG) { DEBUGGER.debug("responseData: {}", responseData); } } } } catch (SQLException sqx) { throw new SQLException(sqx.getMessage(), sqx); } finally { if (resultSet != null) { resultSet.close(); } if (stmt != null) { stmt.close(); } if ((sqlConn != null) && (!(sqlConn.isClosed()))) { sqlConn.close(); } } return responseData; }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleAuditActionTable.java
public void deleteAuditAction(CFAccAuthorization Authorization, CFAccAuditActionBuff Buff) { final String S_ProcName = "deleteAuditAction"; Connection cnx = schema.getCnx(); CallableStatement stmtDeleteByPKey = null; try {/*from ww w .j a va 2 s .c o m*/ short AuditActionId = Buff.getRequiredAuditActionId(); stmtDeleteByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".dl_auditaction( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPKey.setShort(argIdx++, AuditActionId); stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision()); ; stmtDeleteByPKey.execute(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtDeleteByPKey != null) { try { stmtDeleteByPKey.close(); } catch (SQLException e) { } stmtDeleteByPKey = null; } } }