List of usage examples for java.sql CallableStatement close
void close() throws SQLException;
Statement
object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed. From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseClusterTable.java
public int nextSecFormIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) { final String S_ProcName = "nextSecFormIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }//from ww w .j ava 2 s.c om Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextSecFormIdGen = null; try { String sql = "{ call sp_next_secformidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextSecFormIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextSecFormIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER); stmtSelectNextSecFormIdGen.setLong(argIdx++, Id); stmtSelectNextSecFormIdGen.execute(); int nextId = stmtSelectNextSecFormIdGen.getInt(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextSecFormIdGen != null) { try { stmtSelectNextSecFormIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecFormIdGen = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseClusterTable.java
public long nextServiceIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) { final String S_ProcName = "nextServiceIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }/* w ww .j a va 2 s . com*/ Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextServiceIdGen = null; try { String sql = "{ call sp_next_serviceidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextServiceIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextServiceIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextServiceIdGen.setLong(argIdx++, Id); stmtSelectNextServiceIdGen.execute(); long nextId = stmtSelectNextServiceIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextServiceIdGen != null) { try { stmtSelectNextServiceIdGen.close(); } catch (SQLException e) { } stmtSelectNextServiceIdGen = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseClusterTable.java
public int nextSecGroupIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) { final String S_ProcName = "nextSecGroupIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }// w w w . j a v a 2s. c o m Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextSecGroupIdGen = null; try { String sql = "{ call sp_next_secgroupidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextSecGroupIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextSecGroupIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER); stmtSelectNextSecGroupIdGen.setLong(argIdx++, Id); stmtSelectNextSecGroupIdGen.execute(); int nextId = stmtSelectNextSecGroupIdGen.getInt(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextSecGroupIdGen != null) { try { stmtSelectNextSecGroupIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecGroupIdGen = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseClusterTable.java
public long nextHostNodeIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) { final String S_ProcName = "nextHostNodeIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }//from www . ja v a2 s .c o m Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextHostNodeIdGen = null; try { String sql = "{ call sp_next_hostnodeidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextHostNodeIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextHostNodeIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextHostNodeIdGen.setLong(argIdx++, Id); stmtSelectNextHostNodeIdGen.execute(); long nextId = stmtSelectNextHostNodeIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextHostNodeIdGen != null) { try { stmtSelectNextHostNodeIdGen.close(); } catch (SQLException e) { } stmtSelectNextHostNodeIdGen = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseClusterTable.java
public long nextSecGroupFormIdGen(CFSecurityAuthorization Authorization, CFSecurityClusterPKey PKey) { final String S_ProcName = "nextSecGroupFormIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }/* w w w .j a v a 2 s . co m*/ Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextSecGroupFormIdGen = null; try { String sql = "{ call sp_next_secgroupformidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextSecGroupFormIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextSecGroupFormIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextSecGroupFormIdGen.setLong(argIdx++, Id); stmtSelectNextSecGroupFormIdGen.execute(); long nextId = stmtSelectNextSecGroupFormIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextSecGroupFormIdGen != null) { try { stmtSelectNextSecGroupFormIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecGroupFormIdGen = null; } } }
From source file:com.mimp.hibernate.HiberNna.java
public ArrayList<InformeNna> listaInformesExpNna(Long idExpNna) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/*from ww w. ja v a2s. c o m*/ final Long expNna = idExpNna; final ArrayList<InformeNna> lista = new ArrayList(); Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { String hql = "{call HN_LIST_INF_EVAL(?,?)}"; CallableStatement statement = connection.prepareCall(hql); statement.setLong(1, expNna); statement.registerOutParameter(2, OracleTypes.CURSOR); statement.execute(); ResultSet rs = (ResultSet) statement.getObject(2); while (rs.next()) { InformeNna tempInf = new InformeNna(); tempInf.setIdinformeNna(rs.getLong("IDINFORME_NNA")); tempInf.setNumero(rs.getString("NUMERO")); tempInf.setFecha(rs.getDate("FECHA")); lista.add(tempInf); } rs.close(); statement.close(); } }; session.doWork(work); return lista; }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseClusterTable.java
public long nextSecGroupFormIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) { final String S_ProcName = "nextSecGroupFormIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }/* ww w . j a va 2s. c o m*/ Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextSecGroupFormIdGen = null; try { String sql = "{ call sp_next_secgroupformidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextSecGroupFormIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextSecGroupFormIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextSecGroupFormIdGen.setLong(argIdx++, Id); stmtSelectNextSecGroupFormIdGen.execute(); long nextId = stmtSelectNextSecGroupFormIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextSecGroupFormIdGen != null) { try { stmtSelectNextSecGroupFormIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecGroupFormIdGen = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseClusterTable.java
public long nextSecGroupMemberIdGen(CFSecurityAuthorization Authorization, CFSecurityClusterPKey PKey) { final String S_ProcName = "nextSecGroupMemberIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }/* ww w . ja v a 2 s . c om*/ Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextSecGroupMemberIdGen = null; try { String sql = "{ call sp_next_secgroupmemberidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextSecGroupMemberIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextSecGroupMemberIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextSecGroupMemberIdGen.setLong(argIdx++, Id); stmtSelectNextSecGroupMemberIdGen.execute(); long nextId = stmtSelectNextSecGroupMemberIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextSecGroupMemberIdGen != null) { try { stmtSelectNextSecGroupMemberIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecGroupMemberIdGen = null; } } }
From source file:com.oracle.tutorial.jdbc.StoredProcedureMySQLSample.java
public void runStoredProcedures(String coffeeNameArg, float maximumPercentageArg, float newPriceArg) throws SQLException { CallableStatement cs = null; try {/* w w w. j a v a2 s . c om*/ System.out.println("\nCalling the procedure GET_SUPPLIER_OF_COFFEE"); cs = this.con.prepareCall("{call GET_SUPPLIER_OF_COFFEE(?, ?)}"); cs.setString(1, coffeeNameArg); cs.registerOutParameter(2, Types.VARCHAR); cs.executeQuery(); String supplierName = cs.getString(2); if (supplierName != null) { System.out.println("\nSupplier of the coffee " + coffeeNameArg + ": " + supplierName); } else { System.out.println("\nUnable to find the coffee " + coffeeNameArg); } System.out.println("\nCalling the procedure SHOW_SUPPLIERS"); cs = this.con.prepareCall("{call SHOW_SUPPLIERS}"); ResultSet rs = cs.executeQuery(); while (rs.next()) { String supplier = rs.getString("SUP_NAME"); String coffee = rs.getString("COF_NAME"); System.out.println(supplier + ": " + coffee); } System.out.println("\nContents of COFFEES table before calling RAISE_PRICE:"); CoffeesTable.viewTable(this.con); System.out.println("\nCalling the procedure RAISE_PRICE"); cs = this.con.prepareCall("{call RAISE_PRICE(?,?,?)}"); cs.setString(1, coffeeNameArg); cs.setFloat(2, maximumPercentageArg); cs.registerOutParameter(3, Types.NUMERIC); cs.setFloat(3, newPriceArg); cs.execute(); System.out.println("\nValue of newPrice after calling RAISE_PRICE: " + cs.getFloat(3)); System.out.println("\nContents of COFFEES table after calling RAISE_PRICE:"); CoffeesTable.viewTable(this.con); } catch (SQLException e) { JDBCTutorialUtilities.printSQLException(e); } finally { if (cs != null) { cs.close(); } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseClusterTable.java
public long nextSecGroupIncludeIdGen(CFSecurityAuthorization Authorization, CFSecurityClusterPKey PKey) { final String S_ProcName = "nextSecGroupIncludeIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }//from w w w . j av a 2 s.c o m Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextSecGroupIncludeIdGen = null; try { String sql = "{ call sp_next_secgroupincludeidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextSecGroupIncludeIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextSecGroupIncludeIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextSecGroupIncludeIdGen.setLong(argIdx++, Id); stmtSelectNextSecGroupIncludeIdGen.execute(); long nextId = stmtSelectNextSecGroupIncludeIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextSecGroupIncludeIdGen != null) { try { stmtSelectNextSecGroupIncludeIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecGroupIncludeIdGen = null; } } }