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:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ?????/*from w w w . j a v a 2s .c om*/ * @param declNo */ public static void calculateAllDeclProductSampling(String declNo) { Connection conn = null; CallableStatement proc = null; String call = "{call Pro_CalculateAllDeclProductSampling(?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declNo); proc.execute(); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N36", e); } catch (Exception e) { log.error("N37", e); } finally { try { if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N38", e); } } }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ????// w w w . j ava 2 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); } } }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ?:?//from w ww.ja va 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
/** * ???/*from www. j av a 2 s . co 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:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ?????/*from ww w. j a v a 2 s. c om*/ * @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:cn.gov.scciq.timer.acceptOrder.FRMDao.java
public static int checkDeclProductSampling(String declNo) { int retCode = -1; Connection conn = null; CallableStatement proc = null; ResultSet rs = null;/*from w w w. j a v a 2 s .c o m*/ 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:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ???????/*from w ww . java 2 s. com*/ */ 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:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ?CIQ?//from www .jav a 2 s . c o m * @return */ public static int saveCIQGoodsInfo(CEMSGoodsDataDto goodsDto) { int retCode = -1; Connection conn = null; CallableStatement proc = null; String call = "{call Pro_SaveCIQGoodsInfo(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, goodsDto.getDecl_No()); proc.setString(2, goodsDto.getGoods_No()); proc.setString(3, goodsDto.getHS_Code()); proc.setString(4, goodsDto.getGoods_CName()); proc.setString(5, goodsDto.getGoods_EName()); proc.setString(6, goodsDto.getGoods_Model()); proc.setString(7, goodsDto.getOrigin_Place_Code()); proc.setString(8, goodsDto.getOrigin_Country_Code()); proc.setString(9, goodsDto.getWeight()); proc.setString(10, goodsDto.getWeight_Unit_Code()); proc.setString(11, goodsDto.getSTD_Weight()); proc.setString(12, goodsDto.getSTD_Weight_Unit_Code()); proc.setString(13, goodsDto.getQTY()); proc.setString(14, goodsDto.getQTY_Unit_Code()); proc.setString(15, goodsDto.getSTD_QTY()); proc.setString(16, goodsDto.getSTD_QTY_Unit_Code()); proc.setString(17, goodsDto.getPack_Number()); proc.setString(18, goodsDto.getPack_Type_Code()); proc.setString(19, goodsDto.getCCY()); proc.setString(20, goodsDto.getRate()); proc.setString(21, goodsDto.getPrice()); proc.setString(22, goodsDto.getGoods_Values()); proc.setString(23, goodsDto.getValues_USD()); proc.setString(24, goodsDto.getValues_RMB()); proc.setString(25, goodsDto.getCIQ_CODE()); proc.setString(26, goodsDto.getINSP_MODE_CODE()); proc.setString(27, goodsDto.getCONDITION_FLAG()); proc.setString(28, goodsDto.getWASTE_FLAG()); proc.setString(29, goodsDto.getCHECKUP_TYPE_CODE()); proc.setString(30, goodsDto.getCHECKUP_WORK_CODE()); proc.setString(31, goodsDto.getSITUATION_CODE()); proc.setString(32, goodsDto.getSITUATION_LEVEL()); proc.setString(33, goodsDto.getPURPOSE_CODE()); proc.setString(34, goodsDto.getNOTIFY_NOS()); proc.setString(35, goodsDto.getPROD_NO()); proc.setString(36, goodsDto.getCOMBBATCH_NO()); proc.registerOutParameter(37, Types.INTEGER); proc.execute(); retCode = proc.getInt(37); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N30", e); } catch (Exception e) { log.error("N31", e); } finally { try { if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N32", e); } } return retCode; }
From source file:com.alibaba.druid.pool.DBCPTest.java
public void test_dbcp() throws Exception { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(MockDriver.class.getName()); dataSource.setUrl("jdbc:mock:xxx"); dataSource.setMaxOpenPreparedStatements(100); dataSource.setPoolPreparedStatements(true); final String sql = "selelct 1"; {//from ww w .ja v a2 s . com Connection conn = dataSource.getConnection(); CallableStatement stmt = conn.prepareCall(sql); stmt.close(); conn.close(); } { Connection conn = dataSource.getConnection(); CallableStatement stmt = conn.prepareCall(sql); stmt.close(); conn.close(); } }
From source file:org.marccarre.spring.db.testing.FooDao.java
public List<Foo> getByIdCallableStatement(int id) { final int fooId = id; return jdbcTemplate.execute(new CallableStatementCreator() { public CallableStatement createCallableStatement(Connection con) throws SQLException { CallableStatement cs = con.prepareCall("{call GetFoosById(?)}"); cs.setInt(1, fooId);//from ww w.j ava2s.c om return cs; } }, new CallableStatementCallback<List<Foo>>() { public List<Foo> doInCallableStatement(CallableStatement cs) throws SQLException { cs.execute(); List<Foo> foos = new ArrayList<Foo>(); if (cs.getMoreResults()) { ResultSet rs = cs.getResultSet(); FooRowMapper mapper = new FooRowMapper(); int rowIndex = 0; while (rs.next()) { foos.add(mapper.mapRow(rs, rowIndex)); rowIndex++; } } return foos; } }); }