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:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ???CIQ???????CIQ?//from www . j a v a2 s . c o m */ public static int saveDeclInfo(String declNo) { int retCode = -1; Connection conn = null; CallableStatement proc = null; String call = "{call Pro_SaveDeclInfo(?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declNo); proc.registerOutParameter(2, Types.INTEGER); proc.execute(); retCode = proc.getInt(2); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N48", e); } catch (Exception e) { log.error("N49", e); } finally { try { if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N50", e); } } return retCode; }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ??// w w w. j a v a 2s. c o m */ public static int declFlagAction(String declNo) { int retCode = -1; Connection conn = null; CallableStatement proc = null; String call = "{call Pro_DeclFlagAction(?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declNo); proc.registerOutParameter(2, Types.INTEGER); proc.execute(); retCode = proc.getInt(2); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N33", e); } catch (Exception e) { log.error("N34", e); } finally { try { if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N35", e); } } return retCode; }
From source file:genepi.db.JdbcDataAccessObject.java
public boolean callProcedure(String sql, Object[] params) throws SQLException { Connection connection = null; try {/*from ww w .j av a 2s .c o m*/ connection = database.getDataSource().getConnection(); CallableStatement cstmt = connection.prepareCall(sql); runner.fillStatement(cstmt, params); boolean state = cstmt.execute(); cstmt.close(); connection.close(); return state; } catch (SQLException e) { throw e; } finally { connection.close(); } }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ??// w ww.jav a 2 s . c o m */ public static int checkEntExists(String entCode) { int retCode = -1; Connection conn = null; CallableStatement proc = null; String call = "{call Pro_CheckEntExists(?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); System.out.println("entcode" + entCode); proc.setString(1, entCode); proc.registerOutParameter(2, Types.INTEGER); proc.execute(); retCode = proc.getInt(2); System.out.println("retcode" + retCode); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N39", e); } catch (Exception e) { log.error("N40", e); } finally { try { if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N41", e); } } return retCode; }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ?????/*from w ww .j a va2 s . co m*/ * @param declNo * @return */ public static int checkDeclProductPerfect(String declNo) { int retCode = -1; Connection conn = null; CallableStatement proc = null; ResultSet rs = null; String call = "{call Pro_CheckDeclProductPerfect(?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declNo); proc.registerOutParameter(2, Types.INTEGER); proc.execute(); retCode = proc.getInt(2); } catch (SQLException e) { // TODO Auto-generated catch block log.error(e); } catch (Exception e) { log.error(e); } finally { try { if (rs != null) { rs.close(); } if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error(e); } } return retCode; }
From source file:net.sf.jdbcwrappers.trim.TrimmingTest.java
@Test public void testCallableStatement() throws SQLException { CallableStatement statement = connection.prepareCall("{ call TESTPROC() }"); try {/*from w w w . j a va 2 s . co m*/ ResultSet rs = statement.executeQuery(); rs.next(); assertEquals("test", rs.getString(2)); assertEquals("test", rs.getString("CHAR_COL")); } finally { statement.close(); } }
From source file:com.bstek.dorado.core.store.H2BaseStore.java
protected void prepareNamespace() throws Exception { Class.forName(driverClassName); Connection conn = DriverManager.getConnection(getConnectionUrl(), username, password); try {/*from w w w . j a v a 2s. c o m*/ int storeVersion = 0; CallableStatement prepareCall = conn.prepareCall("SELECT @storeVersion"); ResultSet resultSet = prepareCall.executeQuery(); try { if (resultSet.first()) { storeVersion = resultSet.getInt("@storeVersion"); } } finally { resultSet.close(); prepareCall.close(); } if (storeVersion < version) { logger.info("Initializing store \"" + namespace + "\"."); prepareCall = conn.prepareCall("SET @storeVersion = " + version); try { prepareCall.execute(); } finally { prepareCall.close(); } initNamespace(conn); } } finally { conn.close(); } }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ?:?//from w w w.ja v a 2 s . co m * @return */ public static int checkRapidRelease(String declNo) { int retCode = -1; Connection conn = null; CallableStatement proc = null; ResultSet rs = null; String call = "{call Pro_CheckRapidRelease(?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declNo); proc.registerOutParameter(2, Types.INTEGER); proc.execute(); retCode = proc.getInt(2); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N60", e); } catch (Exception e) { log.error("N61", e); } finally { try { if (rs != null) { rs.close(); } if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N62", e); } } return retCode; }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
public static int checkDeclProductSampling(String declNo) { int retCode = -1; Connection conn = null;//from w ww . jav a 2 s . c o m CallableStatement proc = null; ResultSet rs = null; String call = "{call Pro_CheckDeclProductSampling(?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declNo); proc.registerOutParameter(2, Types.INTEGER); proc.execute(); retCode = proc.getInt(2); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N57", e); } catch (Exception e) { log.error("N58", e); } finally { try { if (rs != null) { rs.close(); } if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N59", e); } } return retCode; }
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 w w w . j a v a 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(); } }