List of usage examples for java.sql CallableStatement execute
boolean execute() throws SQLException;
PreparedStatement
object, which may be any kind of SQL statement. From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseClusterTable.java
public long nextServiceIdGen(CFSecurityAuthorization Authorization, CFSecurityClusterPKey PKey) { final String S_ProcName = "nextServiceIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }//from www .j a v a 2 s. c om 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:com.mimp.hibernate.HiberNna.java
public Nna getNna(long id) { Session session = sessionFactory.getCurrentSession(); final Nna tempnna = new Nna(); final Long idnna = id; Work work = new Work() { @Override/*from ww w .ja v a2 s. c om*/ public void execute(Connection connection) throws SQLException { ExpedienteNna expnna; Juzgado juz; Car car; String hql = "{call HN_GET_NNA(?,?)}"; CallableStatement statement = connection.prepareCall(hql); statement.setLong(1, idnna); statement.registerOutParameter(2, OracleTypes.CURSOR); statement.execute(); temp = (ResultSet) statement.getObject(2); while (temp.next()) { tempnna.setIdnna(idnna); juz = new Juzgado(); juz.setIdjuzgado(temp.getLong("IDJUZGADO")); tempnna.setJuzgado(juz); tempnna.setNombre(temp.getString(2)); tempnna.setApellidoP(temp.getString(3)); tempnna.setApellidoM(temp.getString(4)); tempnna.setSexo(temp.getString(5)); tempnna.setFechaNacimiento(temp.getDate(6)); tempnna.setEdadAnhos(temp.getShort(7)); tempnna.setEdadMeses(temp.getShort(8)); tempnna.setActaNacimiento(temp.getShort(9)); tempnna.setCondicionSalud(temp.getString(10)); tempnna.setDepartamentoNacimiento(temp.getString(11)); tempnna.setProvinciaNacimiento(temp.getString(12)); tempnna.setDistritoNacimiento(temp.getString(13)); tempnna.setPaisNacimiento(temp.getString(14)); tempnna.setLugarNac(temp.getString(15)); tempnna.setFechaResolAbandono(temp.getDate(16)); tempnna.setFechaResolConsentida(temp.getDate("FECHA_RESOL_CONSENTIDA")); tempnna.setClasificacion(temp.getString(18)); tempnna.setIncesto(temp.getShort(19)); tempnna.setMental(temp.getShort(20)); tempnna.setEpilepsia(temp.getShort(21)); tempnna.setAbuso(temp.getShort(22)); tempnna.setSifilis(temp.getShort(23)); tempnna.setSeguiMedico(temp.getShort(24)); tempnna.setOperacion(temp.getShort(25)); tempnna.setHiperactivo(temp.getShort(26)); tempnna.setEspecial(temp.getShort(27)); tempnna.setEnfermo(temp.getShort(28)); tempnna.setMayor(temp.getShort(29)); tempnna.setAdolescente(temp.getShort(30)); tempnna.setHermano(temp.getShort(31)); tempnna.setNn(temp.getShort(32)); tempnna.setObservaciones(temp.getString(33)); tempnna.setNResolAband(temp.getString(34)); tempnna.setNResolCons(temp.getString("N_RESOL_CONS")); try { expnna = getExpNna(tempnna.getIdnna()); if (expnna.getIdexpedienteNna() != 0) { Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>(); listexp.add(expnna); tempnna.setExpedienteNnas(listexp); } } catch (Exception e) { } car = new Car(); car.setIdcar(temp.getLong("IDCAR")); car.setNombre(temp.getString(37)); car.setDireccion(temp.getString(38)); car.setDepartamento(temp.getString(39)); car.setProvincia(temp.getString(40)); car.setDistrito(temp.getString(41)); car.setDirector(temp.getString(42)); car.setContacto(temp.getString(43)); car.setCorreo(temp.getString(44)); car.setFax(temp.getString(45)); car.setCelular(temp.getString(46)); car.setTelefono(temp.getString(47)); car.setObservaciones(temp.getString(48)); tempnna.setCar(car); } temp.close(); statement.close(); } }; session.doWork(work); return tempnna; }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseClusterTable.java
public int nextSecFormIdGen(CFSecurityAuthorization Authorization, CFSecurityClusterPKey PKey) { final String S_ProcName = "nextSecFormIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }// w w w .j a v a 2 s .com 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:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public Item addWatch(final Watch watch) { Item obj = null;//from w ww . j av a2s. c om Connection conn = null; CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_EDITWATCH (?,?,?)}"); stmt.registerOutParameter(1, Types.INTEGER); stmt.setInt(2, watch.getItemUid()); stmt.setInt(3, watch.getUserUid()); stmt.execute(); stmt.close(); // close statement to prevent leak stmt = conn.prepareCall("{call SP_GETITEM (?)}"); stmt.setInt(1, watch.getItemUid()); rs = stmt.executeQuery(); if (rs.next()) { ItemBuilder builder = Item.newBuilder().setUid(rs.getInt("UID")) .setAuctionUid(rs.getInt("AUCTIONUID")).setItemNumber(rs.getString("ITEMNUMBER")) .setName(rs.getString("NAME")).sertCurPrice(rs.getDouble("CURPRICE")) .setWinner(rs.getString("WINNER")).setBidCount(rs.getInt("BIDCOUNT")) .setWatchCount(rs.getInt("WATCHCOUNT")); obj = builder.build(); } } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); } finally { DbUtils.closeQuietly(conn, stmt, rs); } if (LOG.isDebugEnabled()) { LOG.debug("WATCH [method:{} result:{}]", new Object[] { "add", obj != null ? obj.toString() : "[error]" }); } return obj; }
From source file:com.mimp.hibernate.HiberNna.java
public ExpedienteNna getExpNna(long idNna) { Session session = sessionFactory.getCurrentSession(); final ExpedienteNna expnna = new ExpedienteNna(); final Long idnna = idNna; Work work = new Work() { @Override//from w ww . j a v a 2s .co m public void execute(Connection connection) throws SQLException { Nna tempnna; String hql = "{call HN_GET_EXPEDIENTE_NNA_UNO(?,?)}"; CallableStatement statement = connection.prepareCall(hql); statement.setLong(1, idnna); statement.registerOutParameter(2, OracleTypes.CURSOR); statement.execute(); tempexp = (ResultSet) statement.getObject(2); while (tempexp.next()) { expnna.setIdexpedienteNna(tempexp.getLong(1)); expnna.setNumero(tempexp.getString(2)); expnna.setFechaIngreso(tempexp.getDate(3)); expnna.setHt(tempexp.getString(4)); expnna.setNExpTutelar(tempexp.getString(5)); expnna.setProcTutelar(tempexp.getString(6)); expnna.setFichaIntegral(tempexp.getShort(7)); expnna.setComentarios(tempexp.getString(8)); expnna.setRespLegalNombre(tempexp.getString(9)); expnna.setRespLegalP(tempexp.getString(10)); expnna.setRespLegalM(tempexp.getString(11)); expnna.setRespPsicosocialNombre(tempexp.getString(12)); expnna.setRespPiscosocialP(tempexp.getString(13)); expnna.setRespPsicosocialM(tempexp.getString(14)); expnna.setEstado(tempexp.getString(15)); expnna.setFechaEstado(tempexp.getDate(16)); expnna.setAdoptable(tempexp.getShort(17)); expnna.setFechaResolCons(tempexp.getDate(18)); expnna.setNacional(tempexp.getShort(19)); expnna.setDiagnostico(tempexp.getString(20)); expnna.setCodigoReferencia(tempexp.getString(21)); expnna.setNActual(tempexp.getString(22)); expnna.setApellidopActual(tempexp.getString(23)); expnna.setApellidomActual(tempexp.getString(24)); expnna.setObservaciones(tempexp.getString(25)); expnna.setFechaInvTutelar(tempexp.getDate(26)); expnna.setFechaIngPrio(tempexp.getDate("FECHA_ING_PRIO")); expnna.setFechaActualizacion(tempexp.getDate("FECHA_ACTUALIZACION")); tempnna = new Nna(); tempnna.setIdnna(tempexp.getLong(27)); tempnna.setNombre(tempexp.getString(28)); tempnna.setApellidoP(tempexp.getString(29)); tempnna.setApellidoM(tempexp.getString(30)); tempnna.setSexo(tempexp.getString(31)); tempnna.setFechaNacimiento(tempexp.getDate(32)); tempnna.setEdadAnhos(tempexp.getShort(33)); tempnna.setEdadMeses(tempexp.getShort(34)); tempnna.setActaNacimiento(tempexp.getShort(35)); tempnna.setCondicionSalud(tempexp.getString(36)); tempnna.setDepartamentoNacimiento(tempexp.getString(37)); tempnna.setProvinciaNacimiento(tempexp.getString(38)); tempnna.setDistritoNacimiento(tempexp.getString(39)); tempnna.setPaisNacimiento(tempexp.getString(40)); tempnna.setLugarNac(tempexp.getString(41)); tempnna.setFechaResolAbandono(tempexp.getDate(42)); tempnna.setFechaResolConsentida(tempexp.getDate(43)); tempnna.setClasificacion(tempexp.getString(44)); tempnna.setIncesto(tempexp.getShort(45)); tempnna.setMental(tempexp.getShort(46)); tempnna.setEpilepsia(tempexp.getShort(47)); tempnna.setAbuso(tempexp.getShort(48)); tempnna.setSifilis(tempexp.getShort(49)); tempnna.setSeguiMedico(tempexp.getShort(50)); tempnna.setOperacion(tempexp.getShort(51)); tempnna.setHiperactivo(tempexp.getShort(52)); tempnna.setEspecial(tempexp.getShort(53)); tempnna.setEnfermo(tempexp.getShort(54)); tempnna.setMayor(tempexp.getShort(55)); tempnna.setAdolescente(tempexp.getShort(56)); tempnna.setHermano(tempexp.getShort(57)); tempnna.setNn(tempexp.getShort(58)); tempnna.setObservaciones(tempexp.getString(59)); tempnna.setNResolAband(tempexp.getString(60)); tempnna.setNResolCons(tempexp.getString(61)); expnna.setNna(tempnna); Unidad unid = new Unidad(); unid.setIdunidad(tempexp.getLong(62)); expnna.setUnidad(unid); } tempexp.close(); statement.close(); } }; session.doWork(work); return expnna; }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseClusterTable.java
public long nextHostNodeIdGen(CFSecurityAuthorization Authorization, CFSecurityClusterPKey PKey) { final String S_ProcName = "nextHostNodeIdGen"; 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 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 int nextSecGroupIdGen(CFSecurityAuthorization Authorization, CFSecurityClusterPKey PKey) { final String S_ProcName = "nextSecGroupIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }//from www .jav a 2 s . com 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 int nextSecAppIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) { final String S_ProcName = "nextSecAppIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }/*from ww w. ja v a 2s . c om*/ Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextSecAppIdGen = null; try { String sql = "{ call sp_next_secappidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextSecAppIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextSecAppIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER); stmtSelectNextSecAppIdGen.setLong(argIdx++, Id); stmtSelectNextSecAppIdGen.execute(); int nextId = stmtSelectNextSecAppIdGen.getInt(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextSecAppIdGen != null) { try { stmtSelectNextSecAppIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecAppIdGen = null; } } }
From source file:com.mimp.hibernate.HiberNna.java
public Nna getNnaPostAdopcion(long id) { Session session = sessionFactory.getCurrentSession(); final Nna tempnna = new Nna(); final Long idnna = id; Work work = new Work() { @Override/*from w w w.java 2s. co m*/ public void execute(Connection connection) throws SQLException { ExpedienteNna expnna; Car car; Juzgado juz; String hql = "{call HN_GET_NNA_POST(?,?)}"; CallableStatement statement = connection.prepareCall(hql); statement.setLong(1, idnna); statement.registerOutParameter(2, OracleTypes.CURSOR); statement.execute(); temp = (ResultSet) statement.getObject(2); while (temp.next()) { tempnna.setIdnna(idnna); tempnna.setNombre(temp.getString(1)); tempnna.setApellidoP(temp.getString(2)); tempnna.setApellidoM(temp.getString(3)); tempnna.setSexo(temp.getString(4)); tempnna.setFechaNacimiento(temp.getDate(5)); tempnna.setEdadAnhos(temp.getShort(6)); tempnna.setEdadMeses(temp.getShort(7)); tempnna.setActaNacimiento(temp.getShort(8)); tempnna.setCondicionSalud(temp.getString(9)); tempnna.setDepartamentoNacimiento(temp.getString(10)); tempnna.setProvinciaNacimiento(temp.getString(11)); tempnna.setDistritoNacimiento(temp.getString(12)); tempnna.setPaisNacimiento(temp.getString(13)); tempnna.setLugarNac(temp.getString(14)); tempnna.setFechaResolAbandono(temp.getDate(15)); tempnna.setFechaResolConsentida(temp.getDate(16)); tempnna.setClasificacion(temp.getString(17)); tempnna.setIncesto(temp.getShort(18)); tempnna.setMental(temp.getShort(19)); tempnna.setEpilepsia(temp.getShort(20)); tempnna.setAbuso(temp.getShort(21)); tempnna.setSifilis(temp.getShort(22)); tempnna.setSeguiMedico(temp.getShort(23)); tempnna.setOperacion(temp.getShort(24)); tempnna.setHiperactivo(temp.getShort(25)); tempnna.setEspecial(temp.getShort(26)); tempnna.setEnfermo(temp.getShort(27)); tempnna.setMayor(temp.getShort(28)); tempnna.setAdolescente(temp.getShort(29)); tempnna.setHermano(temp.getShort(30)); tempnna.setNn(temp.getShort(31)); tempnna.setObservaciones(temp.getString(32)); tempnna.setNResolAband(temp.getString(33)); tempnna.setNResolCons(temp.getString(34)); try { expnna = getExpNna(tempnna.getIdnna()); if (expnna.getIdexpedienteNna() != 0) { Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>(); listexp.add(expnna); tempnna.setExpedienteNnas(listexp); } } catch (Exception e) { } car = new Car(); car.setIdcar(temp.getLong(35)); car.setNombre(temp.getString(36)); car.setDireccion(temp.getString(37)); car.setDepartamento(temp.getString(38)); car.setProvincia(temp.getString(39)); car.setDistrito(temp.getString(40)); car.setDirector(temp.getString(41)); car.setContacto(temp.getString(42)); car.setCorreo(temp.getString(43)); car.setFax(temp.getString(44)); car.setCelular(temp.getString(45)); car.setTelefono(temp.getString(46)); car.setObservaciones(temp.getString(47)); tempnna.setCar(car); juz = new Juzgado(); juz.setIdjuzgado(temp.getLong("IDJUZGADO")); juz.setNombre(temp.getString(49)); juz.setDenominacion(temp.getString(50)); juz.setEspecialidad(temp.getString(51)); juz.setDireccion(temp.getString(52)); juz.setDepartamento(temp.getString(53)); juz.setCorteSuperior(temp.getString(54)); juz.setDistritoJudicial(temp.getString(55)); juz.setNombreJuez(temp.getString(56)); juz.setTelefono(temp.getString(57)); juz.setCorreo(temp.getString(58)); juz.setObservaciones(temp.getString(59)); tempnna.setJuzgado(juz); } temp.close(); statement.close(); } }; session.doWork(work); return tempnna; }
From source file:com.mimp.hibernate.HiberNna.java
public void crearExpNna2(ExpedienteNna temp) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/* w w w.j ava2 s .com*/ final ExpedienteNna expnna = temp; Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { String hql = "{call HN_SAVE_EXP_NNA2(?,?,?)}"; CallableStatement statement = connection.prepareCall(hql); statement.setLong(1, expnna.getNna().getIdnna()); statement.setLong(2, expnna.getUnidad().getIdunidad()); statement.setString(3, expnna.getNumero()); statement.execute(); statement.close(); } }; session.doWork(work); }