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.esolutions.security.dao.usermgmt.impl.SQLUserManager.java
/** * @see com.cws.esolutions.security.dao.usermgmt.interfaces.UserManager#addUserAccount(java.util.List, java.util.List) *///from w w w . ja v a2 s . c o m public synchronized boolean addUserAccount(final List<String> userAccount, final List<String> roles) throws UserManagementException { final String methodName = SQLUserManager.CNAME + "#addUserAccount(final List<String> userAccount, final List<String> roles) throws UserManagementException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", userAccount); DEBUGGER.debug("Value: {}", roles); } Connection sqlConn = null; boolean isComplete = false; CallableStatement stmt = null; try { sqlConn = SQLUserManager.dataSource.getConnection(); if (sqlConn.isClosed()) { throw new SQLException("Unable to obtain application datasource connection"); } sqlConn.setAutoCommit(true); stmt = sqlConn.prepareCall("{ CALL addUserAccount(?, ?, ?, ?, ?, ?, ?, ?) }"); stmt.setString(1, userAccount.get(0)); // guid stmt.setString(2, userAccount.get(1)); // username stmt.setString(3, userAccount.get(2)); // password stmt.setBoolean(4, Boolean.valueOf(userAccount.get(3))); // suspended stmt.setString(5, userAccount.get(4)); // surname stmt.setString(6, userAccount.get(5)); // givenname stmt.setString(7, userAccount.get(6)); // displayname stmt.setString(8, userAccount.get(7)); // email if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (!(stmt.execute())) { isComplete = true; } } catch (SQLException sqx) { throw new UserManagementException(sqx.getMessage(), sqx); } finally { try { if (stmt != null) { stmt.close(); } if (!(sqlConn == null) && (!(sqlConn.isClosed()))) { sqlConn.close(); } } catch (SQLException sqx) { throw new UserManagementException(sqx.getMessage(), sqx); } } return isComplete; }
From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswOracle.CFFswOracleFSSofiaTable.java
public CFFswFSSofiaBuff[] readAllBuff(CFFswAuthorization Authorization) { final String S_ProcName = "readAllBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from ww w . j av a 2s . co m ResultSet resultSet = null; Connection cnx = schema.getCnx(); CallableStatement stmtReadAllBuff = null; try { CFFswFSSofiaBuff buff = null; List<CFFswFSSofiaBuff> buffList = new LinkedList<CFFswFSSofiaBuff>(); stmtReadAllBuff = cnx.prepareCall( "begin " + schema.getLowerDbSchemaName() + ".rd_fssofiaall( ?, ?, ?, ?, ?, ? ) ); end;"); int argIdx = 1; stmtReadAllBuff.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadAllBuff.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadAllBuff.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadAllBuff.execute(); resultSet = (ResultSet) stmtReadAllBuff.getObject(1); if (resultSet != null) { try { while (resultSet.next()) { buff = unpackFSSofiaResultSetToBuff(resultSet); buffList.add(buff); } } catch (SQLException e) { // Oracle may return an invalid resultSet if the rowset is empty } } int idx = 0; CFFswFSSofiaBuff[] retBuff = new CFFswFSSofiaBuff[buffList.size()]; Iterator<CFFswFSSofiaBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadAllBuff != null) { try { stmtReadAllBuff.close(); } catch (SQLException e) { } stmtReadAllBuff = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleServiceTypeTable.java
public CFSecurityServiceTypeBuff readBuffByUDescrIdx(CFSecurityAuthorization Authorization, String Description) {//from ww w. j av a 2 s . c o m final String S_ProcName = "readBuffByUDescrIdx"; ResultSet resultSet = null; Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByUDescrIdx = null; try { stmtReadBuffByUDescrIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".rd_svctypebyudescridx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByUDescrIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByUDescrIdx.setString(argIdx++, Description); stmtReadBuffByUDescrIdx.execute(); resultSet = (ResultSet) stmtReadBuffByUDescrIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFSecurityServiceTypeBuff buff = unpackServiceTypeResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByUDescrIdx != null) { try { stmtReadBuffByUDescrIdx.close(); } catch (SQLException e) { } stmtReadBuffByUDescrIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleServiceTypeTable.java
public CFAccServiceTypeBuff readBuffByUDescrIdx(CFAccAuthorization Authorization, String Description) { final String S_ProcName = "readBuffByUDescrIdx"; ResultSet resultSet = null;/*from w w w.j ava2 s . c o m*/ Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByUDescrIdx = null; try { stmtReadBuffByUDescrIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".rd_svctypebyudescridx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByUDescrIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByUDescrIdx.setString(argIdx++, Description); stmtReadBuffByUDescrIdx.execute(); resultSet = (ResultSet) stmtReadBuffByUDescrIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFAccServiceTypeBuff buff = unpackServiceTypeResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByUDescrIdx != null) { try { stmtReadBuffByUDescrIdx.close(); } catch (SQLException e) { } stmtReadBuffByUDescrIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstOracle.CFAstOracleServiceTypeTable.java
public CFAstServiceTypeBuff readBuffByUDescrIdx(CFAstAuthorization Authorization, String Description) { final String S_ProcName = "readBuffByUDescrIdx"; ResultSet resultSet = null;/*from www . jav a 2 s . c o m*/ Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByUDescrIdx = null; try { stmtReadBuffByUDescrIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".rd_svctypebyudescridx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByUDescrIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByUDescrIdx.setString(argIdx++, Description); stmtReadBuffByUDescrIdx.execute(); resultSet = (ResultSet) stmtReadBuffByUDescrIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFAstServiceTypeBuff buff = unpackServiceTypeResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByUDescrIdx != null) { try { stmtReadBuffByUDescrIdx.close(); } catch (SQLException e) { } stmtReadBuffByUDescrIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstOracle.CFAstOracleServiceTypeTable.java
public CFAstServiceTypeBuff readBuffByUDescrIdx(CFAstAuthorization Authorization, String Description) { final String S_ProcName = "readBuffByUDescrIdx"; ResultSet resultSet = null;/*from w w w.j a va 2 s . com*/ Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByUDescrIdx = null; try { stmtReadBuffByUDescrIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".rd_svctypebyudescridx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByUDescrIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByUDescrIdx.setString(argIdx++, Description); stmtReadBuffByUDescrIdx.execute(); resultSet = (ResultSet) stmtReadBuffByUDescrIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFAstServiceTypeBuff buff = unpackServiceTypeResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByUDescrIdx != null) { try { stmtReadBuffByUDescrIdx.close(); } catch (SQLException e) { } stmtReadBuffByUDescrIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleSecUserTable.java
public CFAccSecUserBuff readBuffByUEMailIdx(CFAccAuthorization Authorization, String EMailAddress) { final String S_ProcName = "readBuffByUEMailIdx"; ResultSet resultSet = null;//from w w w .java 2 s . c o m Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByUEMailIdx = null; try { stmtReadBuffByUEMailIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".rd_secuserbyuemailidx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByUEMailIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByUEMailIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUEMailIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByUEMailIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByUEMailIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUEMailIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByUEMailIdx.setString(argIdx++, EMailAddress); stmtReadBuffByUEMailIdx.execute(); resultSet = (ResultSet) stmtReadBuffByUEMailIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFAccSecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByUEMailIdx != null) { try { stmtReadBuffByUEMailIdx.close(); } catch (SQLException e) { } stmtReadBuffByUEMailIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstOracle.CFAstOracleSecUserTable.java
public CFAstSecUserBuff readBuffByUEMailIdx(CFAstAuthorization Authorization, String EMailAddress) { final String S_ProcName = "readBuffByUEMailIdx"; ResultSet resultSet = null;// ww w . j a v a2 s. c om Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByUEMailIdx = null; try { stmtReadBuffByUEMailIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".rd_secuserbyuemailidx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByUEMailIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByUEMailIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUEMailIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByUEMailIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByUEMailIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUEMailIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByUEMailIdx.setString(argIdx++, EMailAddress); stmtReadBuffByUEMailIdx.execute(); resultSet = (ResultSet) stmtReadBuffByUEMailIdx.getObject(1); if (resultSet == null) { return (null); } try { if (resultSet.next()) { CFAstSecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByUEMailIdx != null) { try { stmtReadBuffByUEMailIdx.close(); } catch (SQLException e) { } stmtReadBuffByUEMailIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java
public boolean isSystemUser(CFAstAuthorization Authorization) { if (!inTransaction) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isSystemUser", "Not in a transaction"); }//from www .ja v a2 s. co m CallableStatement stmtSecurityCheck = null; try { final String sql = "{ call sp_is_system_user( ?, ? ) }"; stmtSecurityCheck = cnx.prepareCall(sql); stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER); stmtSecurityCheck.setString(2, Authorization.getSecUserId().toString()); stmtSecurityCheck.execute(); int isAuthorized = stmtSecurityCheck.getInt(1); if (isAuthorized == 0) { return (false); } else { return (true); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isSystemUser", e); } finally { if (stmtSecurityCheck != null) { try { stmtSecurityCheck.close(); } catch (SQLException e) { } stmtSecurityCheck = null; } } }
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public int editItem(final Item item) { int uid = -1; Connection conn = null;/*from w w w . ja va 2s .c om*/ CallableStatement stmt = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_EDITITEM (?,?,?,?,?,?,?,?,?,?,?)}"); stmt.registerOutParameter(1, Types.INTEGER); stmt.setInt(2, item.getAuctionUid()); stmt.setString(3, item.getItemNumber()); stmt.setString(4, item.getName()); stmt.setString(5, item.getDescription()); stmt.setString(6, item.getCategory()); stmt.setString(7, item.getSeller()); stmt.setDouble(8, item.getValPrice()); stmt.setDouble(9, item.getMinPrice()); stmt.setDouble(10, item.getIncPrice()); stmt.setString(11, item.getUrl()); stmt.execute(); uid = stmt.getInt(1); } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); uid = -1; } finally { DbUtils.closeQuietly(conn, stmt, null); } if (LOG.isDebugEnabled()) { LOG.debug("ITEM [method:{} result:{}]", new Object[] { "edit", uid }); } return uid; }