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.cfensyntax.v2_2.CFEnSyntaxOracle.CFEnSyntaxOracleEnPrepositionTable.java
public void createEnPreposition(CFEnSyntaxAuthorization Authorization, CFEnSyntaxEnPrepositionBuff Buff) { final String S_ProcName = "createEnPreposition"; ResultSet resultSet = null;//from w w w. j a v a 2 s . co m CallableStatement stmtCreateByPKey = null; try { String ClassCode = Buff.getClassCode(); Long ScopeId = Buff.getOptionalScopeId(); String Name = Buff.getRequiredName(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_enprep( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); 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++, ClassCode); if (ScopeId != null) { stmtCreateByPKey.setLong(argIdx++, ScopeId.longValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } stmtCreateByPKey.setString(argIdx++, Name); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_enprep() did not return a result set"); } try { if (resultSet.next()) { CFEnSyntaxEnPrepositionBuff createdBuff = unpackEnPrepositionResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredId(createdBuff.getRequiredId()); Buff.setOptionalScopeId(createdBuff.getOptionalScopeId()); Buff.setRequiredName(createdBuff.getRequiredName()); 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_enprep() 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.CFAsteriskOracleSecGroupTable.java
public void createSecGroup(CFSecurityAuthorization Authorization, CFSecuritySecGroupBuff Buff) { final String S_ProcName = "createSecGroup"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w w w. java 2s. com ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { long ClusterId = Buff.getRequiredClusterId(); String Name = Buff.getRequiredName(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_secgrp( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); 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++, "SGRP"); stmtCreateByPKey.setLong(argIdx++, ClusterId); stmtCreateByPKey.setString(argIdx++, Name); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_secgrp() did not return a result set"); } try { if (resultSet.next()) { CFSecuritySecGroupBuff createdBuff = unpackSecGroupResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredClusterId(createdBuff.getRequiredClusterId()); Buff.setRequiredSecGroupId(createdBuff.getRequiredSecGroupId()); Buff.setRequiredName(createdBuff.getRequiredName()); 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_secgrp() 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.CFAsteriskOracleTSecGroupTable.java
public void createTSecGroup(CFSecurityAuthorization Authorization, CFSecurityTSecGroupBuff Buff) { final String S_ProcName = "createTSecGroup"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }// w w w . j a v a 2s .c om ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { long TenantId = Buff.getRequiredTenantId(); String Name = Buff.getRequiredName(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_tsecgrp( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); 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++, "TGRP"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Name); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_tsecgrp() did not return a result set"); } try { if (resultSet.next()) { CFSecurityTSecGroupBuff createdBuff = unpackTSecGroupResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredTSecGroupId(createdBuff.getRequiredTSecGroupId()); Buff.setRequiredName(createdBuff.getRequiredName()); 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_tsecgrp() 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 CFSecuritySysClusterBuff[] readAllBuff(CFSecurityAuthorization Authorization) { final String S_ProcName = "readAllBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w w w.ja va 2 s . c o m ResultSet resultSet = null; Connection cnx = schema.getCnx(); CallableStatement stmtReadAllBuff = null; try { CFSecuritySysClusterBuff buff = null; List<CFSecuritySysClusterBuff> buffList = new LinkedList<CFSecuritySysClusterBuff>(); stmtReadAllBuff = cnx.prepareCall( "begin " + schema.getLowerDbSchemaName() + ".rd_sysclusall( ?, ?, ?, ?, ?, ? ) ); end;"); int argIdx = 1; stmtReadAllBuff.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadAllBuff.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadAllBuff.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadAllBuff.execute(); resultSet = (ResultSet) stmtReadAllBuff.getObject(1); if (resultSet != null) { try { while (resultSet.next()) { buff = unpackSysClusterResultSetToBuff(resultSet); buffList.add(buff); } } catch (SQLException e) { // Oracle may return an invalid resultSet if the rowset is empty } } int idx = 0; CFSecuritySysClusterBuff[] retBuff = new CFSecuritySysClusterBuff[buffList.size()]; Iterator<CFSecuritySysClusterBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadAllBuff != null) { try { stmtReadAllBuff.close(); } catch (SQLException e) { } stmtReadAllBuff = null; } } }
From source file:com.cws.esolutions.core.dao.impl.ServerDataDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IServerDataDAO#getServer(java.lang.String) *//*from ww w . j av a 2 s.c om*/ public synchronized List<Object> getServer(final String attribute) throws SQLException { final String methodName = IServerDataDAO.CNAME + "#getServer(final String attribute) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("attribute: {}", attribute); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<Object> 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 retrServerData(?) }"); 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<Object>(Arrays.asList(resultSet.getString(1), // T1.SYSTEM_GUID resultSet.getString(2), // T1.SYSTEM_OSTYPE resultSet.getString(3), // T1.SYSTEM_STATUS resultSet.getString(4), // T1.SYSTEM_REGION resultSet.getString(5), // T1.NETWORK_PARTITION resultSet.getString(6), // T1.SYSTEM_TYPE resultSet.getString(7), // T1.DOMAIN_NAME resultSet.getString(8), // T1.CPU_TYPE resultSet.getInt(9), // T1.CPU_COUNT resultSet.getString(10), // T1.SERVER_RACK resultSet.getString(11), // T1.RACK_POSITION resultSet.getString(12), // T1.SERVER_MODEL resultSet.getString(13), // T1.SERIAL_NUMBER resultSet.getInt(14), // T1.INSTALLED_MEMORY resultSet.getString(15), // T1.OPER_IP resultSet.getString(16), // T1.OPER_HOSTNAME resultSet.getString(17), // T1.MGMT_IP resultSet.getString(18), // T1.MGMT_HOSTNAME resultSet.getString(19), // T1.BKUP_IP resultSet.getString(20), // T1.BKUP_HOSTNAME resultSet.getString(21), // T1.NAS_IP resultSet.getString(22), // T1.NAS_HOSTNAME resultSet.getString(23), // T1.NAT_ADDR resultSet.getString(24), // T1.COMMENTS resultSet.getString(25), // T1.ASSIGNED_ENGINEER resultSet.getTimestamp(26), // T1.ADD_DATE resultSet.getTimestamp(27), // T1.DELETE_DATE resultSet.getInt(28), // T1.DMGR_PORT resultSet.getString(29), // T1.OWNING_DMGR resultSet.getString(30), // T1.MGR_ENTRY resultSet.getString(31), // T2.GUID resultSet.getString(32))); // T2.NAME 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.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleSecAppTable.java
public void createSecApp(CFSecurityAuthorization Authorization, CFSecuritySecAppBuff Buff) { final String S_ProcName = "createSecApp"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }// w w w .j a va 2s . c o m ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { long ClusterId = Buff.getRequiredClusterId(); String JEEMountName = Buff.getRequiredJEEMountName(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_secapp( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); 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++, "SAPP"); stmtCreateByPKey.setLong(argIdx++, ClusterId); stmtCreateByPKey.setString(argIdx++, JEEMountName); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_secapp() did not return a result set"); } try { if (resultSet.next()) { CFSecuritySecAppBuff createdBuff = unpackSecAppResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredClusterId(createdBuff.getRequiredClusterId()); Buff.setRequiredSecAppId(createdBuff.getRequiredSecAppId()); Buff.setRequiredJEEMountName(createdBuff.getRequiredJEEMountName()); 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_secapp() 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.CFAccOracleTldTable.java
public void createTld(CFAccAuthorization Authorization, CFAccTldBuff Buff) { final String S_ProcName = "createTld"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/* w ww . jav a 2 s . co m*/ ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { long TenantId = Buff.getRequiredTenantId(); String Name = Buff.getRequiredName(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".crt_tlddef( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); 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++, "GTLD"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Name); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_tlddef() did not return a result set"); } try { if (resultSet.next()) { CFAccTldBuff createdBuff = unpackTldResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredTLDId(createdBuff.getRequiredTLDId()); Buff.setRequiredName(createdBuff.getRequiredName()); 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_tlddef() 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.CFAstOracleTldTable.java
public void createTld(CFAstAuthorization Authorization, CFAstTldBuff Buff) { final String S_ProcName = "createTld"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from w w w .j a va 2 s . c o m*/ ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { long TenantId = Buff.getRequiredTenantId(); String Name = Buff.getRequiredName(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".crt_tlddef( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); 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++, "GTLD"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Name); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_tlddef() did not return a result set"); } try { if (resultSet.next()) { CFAstTldBuff createdBuff = unpackTldResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredTLDId(createdBuff.getRequiredTLDId()); Buff.setRequiredName(createdBuff.getRequiredName()); 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_tlddef() 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.CFAstOracleTldTable.java
public void createTld(CFAstAuthorization Authorization, CFAstTldBuff Buff) { final String S_ProcName = "createTld"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from ww w . j a v a 2s. c o m*/ ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { long TenantId = Buff.getRequiredTenantId(); String Name = Buff.getRequiredName(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_tlddef( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); 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++, "GTld"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Name); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_tlddef() did not return a result set"); } try { if (resultSet.next()) { CFAstTldBuff createdBuff = unpackTldResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredTldId(createdBuff.getRequiredTldId()); Buff.setRequiredName(createdBuff.getRequiredName()); 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_tlddef() 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.CFAccOracleSecGroupTable.java
public void createSecGroup(CFAccAuthorization Authorization, CFAccSecGroupBuff Buff) { final String S_ProcName = "createSecGroup"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//w w w.ja va 2 s . c om ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { long ClusterId = Buff.getRequiredClusterId(); String Name = Buff.getRequiredName(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".crt_secgrp( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); 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++, "SGRP"); stmtCreateByPKey.setLong(argIdx++, ClusterId); stmtCreateByPKey.setString(argIdx++, Name); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_secgrp() did not return a result set"); } try { if (resultSet.next()) { CFAccSecGroupBuff createdBuff = unpackSecGroupResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredClusterId(createdBuff.getRequiredClusterId()); Buff.setRequiredSecGroupId(createdBuff.getRequiredSecGroupId()); Buff.setRequiredName(createdBuff.getRequiredName()); 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_secgrp() 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; } } }