List of usage examples for java.sql CallableStatement getResultSet
ResultSet getResultSet() throws SQLException;
ResultSet
object. From source file:com.cws.us.pws.dao.impl.ProductReferenceDAOImpl.java
/** * @see com.cws.us.pws.dao.interfaces.IProductReferenceDAO#getProductList(String) throws SQLException *//* w w w . j a va 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 ww w . j a v a 2 s . co m @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 *//* w w w . j a v a2s . co 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.cws.esolutions.core.dao.impl.WebMessagingDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IWebMessagingDAO#retrieveAlertMessages() *//*from www. j a v a 2 s.co m*/ public synchronized List<Object[]> retrieveAlertMessages() throws SQLException { final String methodName = IWebMessagingDAO.CNAME + "#retrieveAlertMessages() throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<Object[]> response = null; try { sqlConn = dataSource.getConnection(); if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain application datasource connection"); } sqlConn.setAutoCommit(true); stmt = sqlConn.prepareCall("{CALL retrAlertMessages()}"); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (stmt.execute()) { resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("ResultSet: {}", resultSet); } if (resultSet.next()) { resultSet.beforeFirst(); response = new ArrayList<Object[]>(); while (resultSet.next()) { Object[] data = new Object[] { resultSet.getString(1), // svc_message_id resultSet.getString(2), // svc_message_title resultSet.getString(3), // svc_message_txt resultSet.getString(4), // svc_message_author resultSet.getTimestamp(5), // svc_message_submitdate resultSet.getBoolean(6), // svc_message_active resultSet.getBoolean(7), // svc_message_alert resultSet.getBoolean(8), // svc_message_expires resultSet.getTimestamp(9), // svc_message_expirydate resultSet.getTimestamp(10), // svc_message_modifiedon resultSet.getString(11) // svc_message_modifiedby }; if (DEBUG) { DEBUGGER.debug("data: {}", data); } response.add(data); } } } } 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(); } } return response; }
From source file:com.cws.esolutions.core.dao.impl.WebMessagingDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IWebMessagingDAO#retrieveMessages() *//*www. ja v a2 s . c o m*/ public synchronized List<Object[]> retrieveMessages() throws SQLException { final String methodName = IWebMessagingDAO.CNAME + "#retrieveMessages() throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<Object[]> response = null; try { sqlConn = dataSource.getConnection(); if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain application datasource connection"); } sqlConn.setAutoCommit(true); stmt = sqlConn.prepareCall("{CALL retrServiceMessages()}"); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (stmt.execute()) { resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("ResultSet: {}", resultSet); } if (resultSet.next()) { resultSet.beforeFirst(); response = new ArrayList<Object[]>(); while (resultSet.next()) { Object[] data = new Object[] { resultSet.getString(1), // svc_message_id resultSet.getString(2), // svc_message_title resultSet.getString(3), // svc_message_txt resultSet.getString(4), // svc_message_author resultSet.getTimestamp(5), // svc_message_submitdate resultSet.getBoolean(6), // svc_message_active resultSet.getBoolean(7), // svc_message_alert resultSet.getBoolean(8), // svc_message_expires resultSet.getTimestamp(9), // svc_message_expirydate resultSet.getTimestamp(10), // svc_message_modifiedon resultSet.getString(11) // svc_message_modifiedby }; if (DEBUG) { DEBUGGER.debug("data: {}", data); } response.add(data); } } } } 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(); } } return response; }
From source file:com.cws.esolutions.core.dao.impl.ServerDataDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IServerDataDAO#listServers(int) *//*w w w. j a v a 2 s. com*/ public synchronized List<String[]> listServers(final int startRow) throws SQLException { final String methodName = IServerDataDAO.CNAME + "#listServers(final int startRow) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", startRow); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<String[]> 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 retrServerList(?)}"); stmt.setInt(1, startRow); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (stmt.execute()) { resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("resultSet: {}", resultSet); } if (resultSet.next()) { resultSet.beforeFirst(); responseData = new ArrayList<String[]>(); while (resultSet.next()) { String[] serverData = new String[] { resultSet.getString(1), // T1.SYSTEM_GUID resultSet.getString(2), // T1.SYSTEM_REGION resultSet.getString(3), // T1.NETWORK_PARTITION resultSet.getString(4), // T1.OPER_HOSTNAME resultSet.getString(5), // T1.OWNING_DMGR resultSet.getString(6), // T2.GUID resultSet.getString(7) // T2.NAME }; if (DEBUG) { for (Object obj : serverData) { DEBUGGER.debug("Value: {}", obj); } } responseData.add(serverData); } if (DEBUG) { for (Object[] objArr : responseData) { for (Object obj : objArr) { DEBUGGER.debug("Value: {}", obj); } } } } } } 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.core.dao.impl.WebMessagingDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IWebMessagingDAO#retrieveMessage(String) */// w w w. ja va2 s . c o m public synchronized List<Object> retrieveMessage(final String messageId) throws SQLException { final String methodName = IWebMessagingDAO.CNAME + "#retrieveMessage(final String messageId) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug(messageId); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<Object> svcMessage = null; try { sqlConn = dataSource.getConnection(); if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain application datasource connection"); } sqlConn.setAutoCommit(true); stmt = sqlConn.prepareCall("{CALL retrServiceMessage(?)}"); stmt.setString(1, messageId); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (stmt.execute()) { resultSet = stmt.getResultSet(); if (resultSet.next()) { resultSet.first(); svcMessage = new ArrayList<Object>(); svcMessage.add(resultSet.getString(1)); // svc_message_id svcMessage.add(resultSet.getString(2)); // svc_message_title svcMessage.add(resultSet.getString(3)); // svc_message_txt svcMessage.add(resultSet.getString(4)); // svc_message_author svcMessage.add(resultSet.getTimestamp(5)); // svc_message_submitdate svcMessage.add(resultSet.getBoolean(6)); // svc_message_active svcMessage.add(resultSet.getBoolean(7)); // svc_message_alert svcMessage.add(resultSet.getBoolean(8)); // svc_message_expires svcMessage.add(resultSet.getTimestamp(9)); // svc_message_expirydate svcMessage.add(resultSet.getTimestamp(10)); // svc_message_modifiedon svcMessage.add(resultSet.getString(11)); // svc_message_modifiedby if (DEBUG) { DEBUGGER.debug("svcMessage: {}", svcMessage); } } } } 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(); } } return svcMessage; }
From source file:com.cws.esolutions.security.dao.userauth.impl.SQLAuthenticator.java
/** * @see com.cws.esolutions.security.dao.userauth.interfaces.Authenticator#performLogon(java.lang.String, java.lang.String) */// w w w. j a v a2 s. c o m public synchronized List<Object> performLogon(final String username, final String password) throws AuthenticatorException { final String methodName = SQLAuthenticator.CNAME + "#performLogon(final String user, final String password) throws AuthenticatorException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("String: {}", username); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<Object> userAccount = 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 performAuthentication(?, ?)}"); stmt.setString(1, username); // username stmt.setString(2, password); // password if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (!(stmt.execute())) { throw new AuthenticatorException("No user was found for the provided user information"); } resultSet = stmt.getResultSet(); if (DEBUG) { DEBUGGER.debug("ResultSet: {}", resultSet); } if (resultSet.next()) { resultSet.first(); userAccount = new ArrayList<Object>(); for (String returningAttribute : userAttributes.getReturningAttributes()) { if (DEBUG) { DEBUGGER.debug("returningAttribute: {}", returningAttribute); } userAccount.add(resultSet.getString(returningAttribute)); } if (DEBUG) { DEBUGGER.debug("List<Object>: {}", userAccount); } } } 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 userAccount; }
From source file:com.cws.esolutions.core.dao.impl.ServiceDataDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IServiceDataDAO#getService(java.lang.String) */// w w w. j a v a 2 s . c o m public synchronized List<String> getService(final String attribute) throws SQLException { final String methodName = IServiceDataDAO.CNAME + "#getService(final String attribute) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("attribute: {}", attribute); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<String> responseData = null; try { sqlConn = dataSource.getConnection(); if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain application datasource connection"); } sqlConn.setAutoCommit(true); // we dont know what we have here - it could be a guid or it could be a hostname // most commonly it'll be a guid, but we're going to search anyway stmt = sqlConn.prepareCall("{ CALL getServiceData(?) }"); stmt.setString(1, attribute); 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<String>(Arrays.asList(resultSet.getString(1), // SERVICE_TYPE resultSet.getString(2), // NAME resultSet.getString(3), // REGION resultSet.getString(4), // NWPARTITION resultSet.getString(5), // STATUS resultSet.getString(6), // SERVERS resultSet.getString(7))); // DESCRIPTION if (DEBUG) { DEBUGGER.debug("responseData: {}", 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.core.dao.impl.ServerDataDAOImpl.java
/** * @see com.cws.esolutions.core.dao.interfaces.IServerDataDAO#getServer(java.lang.String) *//* w w w .jav a2 s .c o m*/ public synchronized List<Object> getServer(final String attribute) throws SQLException { final String methodName = IServerDataDAO.CNAME + "#getServer(final String attribute) throws SQLException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("attribute: {}", attribute); } 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); // we dont know what we have here - it could be a guid or it could be a hostname // most commonly it'll be a guid, but we're going to search anyway stmt = sqlConn.prepareCall("{ CALL retrServerData(?) }"); stmt.setString(1, attribute); 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), // T1.SYSTEM_GUID resultSet.getString(2), // T1.SYSTEM_OSTYPE resultSet.getString(3), // T1.SYSTEM_STATUS resultSet.getString(4), // T1.SYSTEM_REGION resultSet.getString(5), // T1.NETWORK_PARTITION resultSet.getString(6), // T1.SYSTEM_TYPE resultSet.getString(7), // T1.DOMAIN_NAME resultSet.getString(8), // T1.CPU_TYPE resultSet.getInt(9), // T1.CPU_COUNT resultSet.getString(10), // T1.SERVER_RACK resultSet.getString(11), // T1.RACK_POSITION resultSet.getString(12), // T1.SERVER_MODEL resultSet.getString(13), // T1.SERIAL_NUMBER resultSet.getInt(14), // T1.INSTALLED_MEMORY resultSet.getString(15), // T1.OPER_IP resultSet.getString(16), // T1.OPER_HOSTNAME resultSet.getString(17), // T1.MGMT_IP resultSet.getString(18), // T1.MGMT_HOSTNAME resultSet.getString(19), // T1.BKUP_IP resultSet.getString(20), // T1.BKUP_HOSTNAME resultSet.getString(21), // T1.NAS_IP resultSet.getString(22), // T1.NAS_HOSTNAME resultSet.getString(23), // T1.NAT_ADDR resultSet.getString(24), // T1.COMMENTS resultSet.getString(25), // T1.ASSIGNED_ENGINEER resultSet.getTimestamp(26), // T1.ADD_DATE resultSet.getTimestamp(27), // T1.DELETE_DATE resultSet.getInt(28), // T1.DMGR_PORT resultSet.getString(29), // T1.OWNING_DMGR resultSet.getString(30), // T1.MGR_ENTRY resultSet.getString(31), // T2.GUID resultSet.getString(32))); // T2.NAME if (DEBUG) { DEBUGGER.debug("responseData: {}", 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; }