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:com.cws.us.pws.dao.impl.CareersReferenceDAOImpl.java
/** * @see com.cws.us.pws.dao.interfaces.ICareersReferenceDAO#getCareerData(String, String) throws SQLException */// ww w . jav a2s.c om @Override public List<Object> getCareerData(final String reqId, final String lang) throws SQLException { final String methodName = ICareersReferenceDAO.CNAME + "#getCareerData(final int reqId, final String lang) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", reqId); DEBUGGER.debug("Value: {}", lang); } Connection sqlConn = null; ResultSet resultSet = null; List<Object> results = null; CallableStatement stmt = null; try { sqlConn = this.dataSource.getConnection(); if (DEBUG) { DEBUGGER.debug("Connection: {}", sqlConn); } if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain connection to application datasource"); } stmt = sqlConn.prepareCall("{ CALL getCareerData(?, ?) }"); stmt.setString(1, reqId); stmt.setString(2, lang); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (!(stmt.execute())) { throw new SQLException("PreparedStatement is null. Cannot execute."); } resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("ResultSet: {}", resultSet); } if (resultSet.next()) { resultSet.beforeFirst(); results = new ArrayList<Object>(); while (resultSet.next()) { results.add(resultSet.getString(1)); // REQ_ID results.add(resultSet.getDate(2)); // POST_DATE results.add(resultSet.getDate(3)); // UNPOST_DATE results.add(resultSet.getString(4)); // JOB_TITLE results.add(resultSet.getString(5)); // JOB_SHORT_DESC results.add(resultSet.getString(6)); // JOB_DESCRIPTION } if (DEBUG) { DEBUGGER.debug("results: {}", results); } } } catch (SQLException sqx) { ERROR_RECORDER.error(sqx.getMessage(), sqx); throw new SQLException(sqx.getMessage(), sqx); } finally { if (resultSet != null) { resultSet.close(); } if (stmt != null) { stmt.close(); } if ((sqlConn != null) && (!(sqlConn.isClosed()))) { sqlConn.close(); } } if (DEBUG) { DEBUGGER.debug("results: {}", results); } return results; }
From source file:exifIndexer.MetadataReader.java
public static void walk(String path, boolean is_recursive) { File root = new File(path); File[] list = root.listFiles(); String filePath;//from w ww . j a v a 2 s . c o m String fileName; String fileExt; String valueName; String tagName; String catName; Metadata metadata; long fileSize; long fileLastModified; java.util.Date utilDate; java.sql.Date sqlDate; String sql = "{ ? = call INSERTIMAGE(?,?,?,?,?) }"; String sqlMetaData = "{ call INSERTMETADATA (?,?,?,?) }"; CallableStatement statement; CallableStatement statementMeta; long result; if (list == null) { return; } for (File f : list) { if (f.isDirectory() && is_recursive) { walk(f.getAbsolutePath(), true); } else { filePath = FilenameUtils.getFullPath(f.getAbsolutePath()); fileName = FilenameUtils.getBaseName(f.getName()); fileExt = FilenameUtils.getExtension(f.getName()); utilDate = new java.util.Date(f.lastModified()); sqlDate = new java.sql.Date(utilDate.getTime()); fileSize = f.length(); try { metadata = ImageMetadataReader.readMetadata(f.getAbsoluteFile()); try { DBHandler db = new DBHandler(); db.openConnection(); Connection con = db.getCon(); // llamada al metodo insertar imagen SQL con (filePath,fileName,fileExtension,fileSize, fileLastModified) statement = con.prepareCall(sql); statement.setString(2, filePath); statement.setString(3, fileName); statement.setString(4, fileExt); statement.setLong(5, fileSize); statement.setDate(6, sqlDate); statement.registerOutParameter(1, java.sql.Types.NUMERIC); statement.execute(); result = statement.getLong(1); // llamada al metodo insertar metadatos SQL con (idImg,valueName, tagName, catName) for (Directory directory : metadata.getDirectories()) { for (Tag tag : directory.getTags()) { valueName = tag.getDescription(); tagName = tag.getTagName(); catName = directory.getName(); if (isNull(valueName) || isNull(tagName) || isNull(catName) || valueName.equals("") || tagName.equals("") || catName.equals("") || valueName.length() > 250 || tagName.length() > 250 || catName.length() > 500) { System.out.println("Exif row omitted."); System.out.println("Omitting: [" + catName + "] " + tagName + " " + valueName); } else { statementMeta = con.prepareCall(sqlMetaData); statementMeta.setLong(1, result); statementMeta.setString(2, valueName); statementMeta.setString(3, tagName); statementMeta.setString(4, catName); statementMeta.executeUpdate(); } } } db.closeConnection(); } catch (SQLException ex) { System.err.println("Error with SQL command. \n" + ex); } } catch (ImageProcessingException e) { System.out.println("ImageProcessingException " + e); } catch (IOException e) { System.out.println("IOException " + e); } } } }
From source file:com.mobilewallet.admin.dao.QuestionDAO.java
public int submitQuestion(String question, String qType, String option1, String option2, String option3, String option4, String answer, String explanation, String isAdminApproved) { Connection connection = null; CallableStatement pstmt = null; ResultSet rs = null;// w w w. j ava2 s . c om int submitted = 0; try { connection = dataSource.getConnection(); pstmt = connection.prepareCall("{call SUBMIT_QUESTION(?,?,?,?,?,?,?,?,?,?)}"); pstmt.setString(1, qType); pstmt.setString(2, question); pstmt.setString(3, option1); pstmt.setString(4, option2); pstmt.setString(5, option3); pstmt.setString(6, option4); pstmt.setString(7, answer); pstmt.setString(8, explanation); pstmt.setString(9, isAdminApproved); pstmt.registerOutParameter(10, java.sql.Types.INTEGER); pstmt.execute(); submitted = pstmt.getInt(10); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (rs != null) { rs.close(); } } catch (Exception ex) { } try { if (pstmt != null) { pstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return submitted; }
From source file:com.cws.esolutions.core.dao.impl.ApplicationDataDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IApplicationDataDAO#getApplication(java.lang.String) *//*w ww . j a v a 2s . co m*/ public synchronized List<Object> getApplication(final String value) throws SQLException { final String methodName = IApplicationDataDAO.CNAME + "#getApplication(final String value) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("value: {}", value); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<Object> responseData = null; try { sqlConn = dataSource.getConnection(); if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain application datasource connection"); } sqlConn.setAutoCommit(true); stmt = sqlConn.prepareCall("{CALL getApplicationData(?)}"); stmt.setString(1, value); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (stmt.execute()) { resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("resultSet: {}", resultSet); } if (resultSet.next()) { resultSet.first(); responseData = new ArrayList<Object>(Arrays.asList(resultSet.getString(1), // APPLICATION_GUID resultSet.getString(2), // APPLICATION_NAME resultSet.getDouble(3), // APPLICATION_VERSION resultSet.getString(4), // INSTALLATION_PATH resultSet.getString(5), // PACKAGE_LOCATION resultSet.getString(6), // PACKAGE_INSTALLER resultSet.getString(7), // INSTALLER_OPTIONS resultSet.getString(8), // LOGS_DIRECTORY resultSet.getString(9) // PLATFORM_GUID )); if (DEBUG) { DEBUGGER.debug("data: {}", responseData); } } } } catch (SQLException sqx) { throw new SQLException(sqx.getMessage(), sqx); } finally { if (resultSet != null) { resultSet.close(); } if (stmt != null) { stmt.close(); } if ((sqlConn != null) && (!(sqlConn.isClosed()))) { sqlConn.close(); } } return responseData; }
From source file:com.cws.esolutions.security.dao.userauth.impl.SQLAuthenticator.java
/** * @see com.cws.esolutions.security.dao.userauth.interfaces.Authenticator#obtainOtpSecret(java.lang.String, java.lang.String) *//*from w ww . j a v a2s . co m*/ public synchronized String obtainOtpSecret(final String userName, final String userGuid) throws AuthenticatorException { final String methodName = SQLAuthenticator.CNAME + "#obtainOtpSecret(final String userName, final String userGuid) throws AuthenticatorException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", userName); DEBUGGER.debug("Value: {}", userGuid); } String otpSecret = null; Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; try { sqlConn = SQLAuthenticator.dataSource.getConnection(); if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain application datasource connection"); } sqlConn.setAutoCommit(true); stmt = sqlConn.prepareCall("{CALL getOtpSecret(?, ?)}"); stmt.setString(1, userGuid); // guid stmt.setString(2, userName); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (stmt.execute()) { resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("ResultSet: {}", resultSet); } if (resultSet.next()) { resultSet.first(); otpSecret = resultSet.getString(1); } } } catch (SQLException sqx) { throw new AuthenticatorException(sqx.getMessage(), sqx); } finally { try { if (resultSet != null) { resultSet.close(); } if (stmt != null) { stmt.close(); } if (!(sqlConn == null) && (!(sqlConn.isClosed()))) { sqlConn.close(); } } catch (SQLException sqx) { throw new AuthenticatorException(sqx.getMessage(), sqx); } } return otpSecret; }
From source file:com.cws.us.pws.dao.impl.ProductReferenceDAOImpl.java
/** * @see com.cws.us.pws.dao.interfaces.IProductReferenceDAO#getProductList(String) throws SQLException *//* ww w . ja v a 2 s. co m*/ @Override public List<Object[]> getProductList(final String lang) throws SQLException { final String methodName = IProductReferenceDAO.CNAME + "#getProductList(final String lang) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", lang); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<Object[]> results = null; try { sqlConn = this.dataSource.getConnection(); if (DEBUG) { DEBUGGER.debug("Connection: {}", sqlConn); } if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain connection to application datasource"); } stmt = sqlConn.prepareCall("{ CALL getProductList(?) }"); stmt.setString(1, lang); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (!(stmt.execute())) { throw new SQLException("PreparedStatement is null. Cannot execute."); } resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("ResultSet: {}", resultSet); } if (resultSet.next()) { resultSet.beforeFirst(); results = new ArrayList<Object[]>(); while (resultSet.next()) { Object[] data = new Object[] { resultSet.getString(1), // PRODUCT_ID resultSet.getString(2), // PRODUCT_NAME resultSet.getString(3), // PRODUCT_SHORT_DESC resultSet.getString(4), // PRODUCT_DESC resultSet.getBigDecimal(5), // PRODUCT_PRICE resultSet.getBoolean(6) // IS_FEATURED }; results.add(data); } if (DEBUG) { DEBUGGER.debug("results: {}", results); } } } catch (SQLException sqx) { ERROR_RECORDER.error(sqx.getMessage(), sqx); throw new SQLException(sqx.getMessage(), sqx); } finally { if (resultSet != null) { resultSet.close(); } if (stmt != null) { stmt.close(); } if ((sqlConn != null) && (!(sqlConn.isClosed()))) { sqlConn.close(); } } if (DEBUG) { DEBUGGER.debug("results: {}", results); } return results; }
From source file:com.cws.us.pws.dao.impl.ProductReferenceDAOImpl.java
/** * @see com.cws.us.pws.dao.interfaces.IProductReferenceDAO#getFeaturedProducts(String) throws SQLException *//*from w ww . j a v a2s . c om*/ @Override public List<Object[]> getFeaturedProducts(final String lang) throws SQLException { final String methodName = IProductReferenceDAO.CNAME + "#getFeaturedProducts(final String lang) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", lang); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<Object[]> results = null; try { sqlConn = this.dataSource.getConnection(); if (DEBUG) { DEBUGGER.debug("Connection: {}", sqlConn); } if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain connection to application datasource"); } stmt = sqlConn.prepareCall("{ CALL getFeaturedProducts(?) }"); stmt.setString(1, lang); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (!(stmt.execute())) { throw new SQLException("PreparedStatement is null. Cannot execute."); } resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("ResultSet: {}", resultSet); } if (resultSet.next()) { resultSet.beforeFirst(); results = new ArrayList<Object[]>(); while (resultSet.next()) { Object[] data = new Object[] { resultSet.getString(1), // PRODUCT_ID resultSet.getString(2), // PRODUCT_NAME resultSet.getString(3), // PRODUCT_SHORT_DESC resultSet.getString(4), // PRODUCT_DESC resultSet.getBigDecimal(5), // PRODUCT_PRICE resultSet.getBoolean(6) // IS_FEATURED }; results.add(data); } if (DEBUG) { DEBUGGER.debug("results: {}", results); } } } catch (SQLException sqx) { ERROR_RECORDER.error(sqx.getMessage(), sqx); throw new SQLException(sqx.getMessage(), sqx); } finally { if (resultSet != null) { resultSet.close(); } if (stmt != null) { stmt.close(); } if ((sqlConn != null) && (!(sqlConn.isClosed()))) { sqlConn.close(); } } if (DEBUG) { DEBUGGER.debug("results: {}", results); } return results; }
From source file:com.cws.us.pws.dao.impl.ProductReferenceDAOImpl.java
/** * @see com.cws.us.pws.dao.interfaces.IProductReferenceDAO#getProductData(String, String) throws SQLException *//*from w ww. j a va 2s . c o m*/ @Override public List<Object> getProductData(final String productId, final String lang) throws SQLException { final String methodName = IProductReferenceDAO.CNAME + "#getProductData(final int productId, final String lang) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", productId); DEBUGGER.debug("Value: {}", lang); } Connection sqlConn = null; ResultSet resultSet = null; List<Object> results = null; CallableStatement stmt = null; try { sqlConn = this.dataSource.getConnection(); if (DEBUG) { DEBUGGER.debug("Connection: {}", sqlConn); } if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain connection to application datasource"); } stmt = sqlConn.prepareCall("{ CALL getProductData(?, ?) }"); stmt.setString(1, productId); stmt.setString(2, lang); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (!(stmt.execute())) { throw new SQLException("PreparedStatement is null. Cannot execute."); } resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("ResultSet: {}", resultSet); } if (resultSet.next()) { resultSet.beforeFirst(); results = new ArrayList<Object>(); while (resultSet.next()) { results.add(resultSet.getString(1)); // PRODUCT_ID results.add(resultSet.getString(2)); // PRODUCT_NAME results.add(resultSet.getString(3)); // PRODUCT_SHORT_DESC results.add(resultSet.getString(4)); // PRODUCT_DESC results.add(resultSet.getBigDecimal(5)); // PRODUCT_PRICE results.add(resultSet.getBoolean(6)); // IS_FEATURED } if (DEBUG) { DEBUGGER.debug("results: {}", results); } } } catch (SQLException sqx) { ERROR_RECORDER.error(sqx.getMessage(), sqx); throw new SQLException(sqx.getMessage(), sqx); } finally { if (resultSet != null) { resultSet.close(); } if (stmt != null) { stmt.close(); } if ((sqlConn != null) && (!(sqlConn.isClosed()))) { sqlConn.close(); } } if (DEBUG) { DEBUGGER.debug("results: {}", results); } return results; }
From source file:com.intuit.it.billing.data.BillingDAOImpl.java
/** * PaymentInfoEFT//from w w w .ja v a2s .c o m * * <p/> * <p/> * <b>DATABASE PROCEDURE:</b> * * @code *FUNCTION fn_get_payinfo_eft * ( * item_no IN VARCHAR2 * ) * RETURN ref_cursor * @endcode * <p/> * <b>DATABASE RESULT SET:</b> * <ul> * <li>BILLING_PROFILE_ID,</li> * <li>BDOM,</li> * <li>PAYINFO_NAME,</li> * <li>BANK_ACCOUNT_NO,</li> * <li>BANK_NUMBER,</li> * </ul> * * @param itemNo - The item number (e.g. P1-111)of the item we want payment info for * * @return A single Payment Info record * */ @Override public PaymentInfoEFT getPayinfoEFT(String itemNo) throws JSONException { String query = "begin ? := billing_inquiry.fn_get_payinfo_eft( ? ); end;"; Connection conn = null; PaymentInfoEFT c = null; ResultSet rs = null; // DB Connection try { conn = this.getConnection(); } catch (SQLException e) { throw JSONException.sqlError(e); } catch (NamingException e) { throw JSONException.namingError(e.toString()); } try { CallableStatement stmt = conn.prepareCall(query); stmt.registerOutParameter(1, OracleTypes.CURSOR); stmt.setString(2, itemNo); stmt.execute(); rs = (ResultSet) stmt.getObject(1); while (rs.next()) { c = new PaymentInfoEFT(); c.setBillingProfile(rs.getString("BILLING_PROFILE_ID")); c.setProfileBdom(rs.getInt("BDOM")); c.setCustomerName(rs.getString("PAYINFO_NAME")); c.setBankAccountNumber(rs.getString("BANK_ACCOUNT_NO")); c.setBankNumber(rs.getString("BANK_NUMBER")); } conn.close(); rs.close(); } catch (SQLException e) { throw JSONException.sqlError(e); } if (c == null) { throw JSONException.noDataFound("Null set returned - no data found"); } return c; }
From source file:com.intuit.it.billing.data.BillingDAOImpl.java
/** * PaymentInfoCheck//www . j av a 2s . co m * <p/> * <p/> * <b>DATABASE PROCEDURE:</b> * * @code *FUNCTION fn_get_payinfo_check * ( * item_no IN VARCHAR2 * ) * RETURN ref_cursor; * @endcode * <p/> * <b>DATABASE RESULT SET:</b> * <ul> * <li>BILLING_PROFILE_ID,</li> * <li>BDOM,</li> * <li>PAYINFO_NAME,</li> * <li>NET_TERMS,</li> * <li>CHECK_NO,</li> * </ul> * * @param itemNo - The item number (e.g. P1-111)of the item we want payment info for * * @return A single Payment Info record * */ @Override public PaymentInfoCheck getPayinfoCheck(String itemNo) throws JSONException { String query = "begin ? := billing_inquiry.fn_get_payinfo_check( ? ); end;"; // TODO: configure strings ResultSet rs = null; Connection conn = null; PaymentInfoCheck c = null; // DB Connection try { conn = this.getConnection(); } catch (SQLException e) { throw JSONException.sqlError(e); } catch (NamingException e) { throw JSONException.namingError(e.toString()); } try { CallableStatement stmt = conn.prepareCall(query); stmt.registerOutParameter(1, OracleTypes.CURSOR); stmt.setString(2, itemNo); stmt.execute(); rs = (ResultSet) stmt.getObject(1); while (rs.next()) { c = new PaymentInfoCheck(); c.setBillingProfile(rs.getString("BILLING_PROFILE_ID")); // TODO: configure strings c.setProfileBdom(rs.getInt("BDOM")); c.setCustomerName(rs.getString("PAYINFO_NAME")); c.setNetTerms(rs.getString("NET_TERMS")); c.setCheckNumber(rs.getString("CHECK_NO")); } conn.close(); rs.close(); } catch (SQLException e) { throw JSONException.sqlError(e); } if (c == null) { throw JSONException.noDataFound("Null set returned - no data found"); } return c; }