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
/** * ???/*from w ww . java 2 s .c o m*/ * @param declNo * @return */ public static String getDeclProductFromEnt(String declNo) { String declProductFromEnt = null; Connection conn = null; CallableStatement proc = null; ResultSet rs = null; String call = "{call Pro_GetDeclProductFromEnt(?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declNo); proc.execute(); rs = proc.getResultSet(); while (rs.next()) { declProductFromEnt = rs.getString("RESULT_CONTENT"); break; } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N51", e); } catch (Exception e) { log.error("N52", 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("N53", e); } } return declProductFromEnt; }
From source file:org.devgateway.toolkit.forms.service.DerbyDatabaseBackupService.java
/** * Backup the On-Line Derby database. This temporarily locks the db in * readonly mode//from w ww.j a va 2s.c o m * * Invokes SYSCS_BACKUP_DATABASE and dumps the database to the temporary * directory Use {@link ZipUtil#pack(File, File)} to zip the directory * Deletes the temporary directory * * @see #createBackupURL(String) */ private void backupDerbyDatabase() { lastBackupURL = createBackupURL(); CallableStatement cs = null; try { cs = datasource.getConnection().prepareCall("CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE(?)"); cs.setString(1, lastBackupURL); cs.execute(); } catch (SQLException e) { LOGGER.error("Cannot perform database backup!", e); return; } finally { try { cs.close(); } catch (SQLException e) { LOGGER.error("Error closing backup connection ", e); return; } } File backupURLFile = new File(lastBackupURL); // zip the contents and delete the dir ZipUtil.pack(backupURLFile, new File(lastBackupURL + ARCHIVE_SUFFIX)); // delete the backup directory that we just zipped try { FileUtils.deleteDirectory(backupURLFile); } catch (IOException e) { LOGGER.error("Cannot delete temporary backup directory", e); } LOGGER.info("Backed up database to " + lastBackupURL + ARCHIVE_SUFFIX); }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ???????//from www .j a v a2s. co m */ public static int saveDeclProduct(String declNo, String entProductCode, String baseCode, String goodsNo) { int retCode = -1; Connection conn = null; CallableStatement proc = null; ResultSet rs = null; String call = "{call Pro_SaveDeclProduct(?,?,?,?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declNo); proc.setString(2, entProductCode); proc.setString(3, baseCode); proc.setString(4, goodsNo); proc.registerOutParameter(5, Types.INTEGER); proc.execute(); retCode = proc.getInt(5); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N54", e); } catch (Exception e) { log.error("N55", 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("N56", e); } } return retCode; }
From source file:com.mobilewallet.common.dao.RegisterDAO.java
public void updateGCM(String userId, String gcmId) { Connection con = null;/* ww w . jav a 2 s . c o m*/ CallableStatement cstmt = null; try { con = ds.getConnection(); cstmt = con.prepareCall("{call wp_update_gcm(?,?,?)}"); cstmt.setString(1, userId); cstmt.setString(2, gcmId); cstmt.registerOutParameter(3, java.sql.Types.VARCHAR); cstmt.execute(); } catch (Exception ex) { } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (con != null) { con.close(); } } catch (Exception ex) { } } }
From source file:com.mobilewallet.common.dao.FeedBackDAO.java
public void feedBack(long userId, String feedType, String feedText, String ip, String email) { Connection connection = null; CallableStatement cstmt = null; try {// w ww. java 2s . c om connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call FEEDBACK_PROC(?,?,?,?,?)}"); cstmt.setLong(1, userId); cstmt.setString(2, feedType); cstmt.setString(3, feedText); cstmt.setString(4, email); cstmt.setString(5, ip); cstmt.execute(); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } }
From source file:com.mobilewallet.users.dao.PushNotificationsDAO.java
public int updateNotification(long userId, String status, String type) { int updated = 0; Connection connection = null; CallableStatement cstmt = null; try {/*w ww . j av a 2 s. com*/ connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call UPDATE_PUSH_NOTIFICATIONS(?,?,?,?)}"); cstmt.setLong(1, userId); cstmt.setString(2, status); cstmt.setString(3, type); cstmt.registerOutParameter(4, java.sql.Types.INTEGER); cstmt.execute(); updated = cstmt.getInt(4); } catch (Exception ex) { } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return updated; }
From source file:com.mobilewallet.users.dao.NotificationsDAO.java
public int updateNotification(long userId, String status, String type) { int updated = 0; Connection connection = null; CallableStatement cstmt = null; try {//from ww w .j av a2 s . co m connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call wp_update_push_notification(?,?,?,?)}"); cstmt.setLong(1, userId); cstmt.setString(2, status); cstmt.setString(3, type); cstmt.registerOutParameter(4, java.sql.Types.INTEGER); cstmt.execute(); updated = cstmt.getInt(4); } catch (Exception ex) { } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return updated; }
From source file:com.mobilewallet.common.dao.ReferralIncentiveDAO.java
public String showInvitationStrig(long userId) { Connection connection = null; CallableStatement cstmt = null; String show = null;/*from w w w . j av a2 s. com*/ try { connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call wp_show_invitation(?,?)}"); cstmt.setLong(1, userId); cstmt.registerOutParameter(2, java.sql.Types.VARCHAR); cstmt.execute(); show = cstmt.getString(2); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return show; }
From source file:de.awtools.grooocle.varray.VarrayTest.java
@Test public void testOraclesVarray() throws Exception { CallableStatement cs = null; try {/*from w ww. j a v a 2 s .c o m*/ String arrayElements[] = { "Test3", "Test4", "Test5" }; ArrayDescriptor desc = ArrayDescriptor.createDescriptor("T_STRING_VARRAY", conn); ARRAY newArray = new ARRAY(desc, conn, arrayElements); String spCall = "{ call call_me(?, ?) }"; cs = conn.prepareCall(spCall); cs.setArray(1, newArray); cs.registerOutParameter(2, java.sql.Types.INTEGER); cs.execute(); assertEquals(3, cs.getInt(2)); } finally { if (cs != null) { cs.close(); } } }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ????// w w w. j a v a2 s .c o m * @param exchangeDto */ public static void saveDeclProductFromEnt(CEMSDeclExchangeDto exchangeDto) { Connection conn = null; CallableStatement proc = null; String call = "{call Pro_SaveDeclProductFromEnt(?,?,?,?,?,?,?,?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, exchangeDto.getSEQ_NUM()); proc.setString(2, exchangeDto.getDECL_NO_TYPE()); proc.setString(3, exchangeDto.getDECL_NO()); proc.setString(4, exchangeDto.getRESULT_CONTENT()); proc.setString(5, exchangeDto.getUPDATE_COUNT()); proc.setString(6, exchangeDto.getLAST_OPER_DATE()); proc.setString(7, exchangeDto.getGEN_FLAG()); proc.setString(8, exchangeDto.getTRUE_DECL_NO()); proc.setString(9, exchangeDto.getPROD_NO()); proc.execute(); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N45", e); } catch (Exception e) { log.error("N46", e); } finally { try { if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N47", e); } } }