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.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public void signout(final int userUid) { Connection conn = null;//from w w w . j a va2 s . c o m CallableStatement stmt = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_SIGNOUT (?)}"); stmt.setInt(1, userUid); stmt.execute(); } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); } finally { DbUtils.closeQuietly(conn, stmt, null); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseTenantTable.java
public long nextTldIdGen(CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) { final String S_ProcName = "nextTldIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }/* w w w.j ava 2 s .co m*/ Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextTldIdGen = null; try { String sql = "{ call sp_next_tldidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextTldIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextTldIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextTldIdGen.setLong(argIdx++, Id); stmtSelectNextTldIdGen.execute(); long nextId = stmtSelectNextTldIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextTldIdGen != null) { try { stmtSelectNextTldIdGen.close(); } catch (SQLException e) { } stmtSelectNextTldIdGen = null; } } }
From source file:com.cws.esolutions.security.dao.usermgmt.impl.SQLUserManager.java
/** * @see com.cws.esolutions.security.dao.usermgmt.interfaces.UserManager#removeUserAccount(java.lang.String) *//*www.j a v a 2s .c o m*/ public synchronized boolean removeUserAccount(final String userId) throws UserManagementException { final String methodName = SQLUserManager.CNAME + "#removeUserAccount(final String userId) throws UserManagementException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("userId: {}", userId); } 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 removeUserAccount(?) }"); stmt.setString(1, userId); 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.cfasterisk.v2_1.CFAstSybase.CFAstSybaseTenantTable.java
public long nextTldIdGen(CFAstAuthorization Authorization, CFAstTenantPKey PKey) { final String S_ProcName = "nextTldIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }/*from w w w . j a v a 2 s . co m*/ Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextTldIdGen = null; try { String sql = "{ call sp_next_tldidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextTldIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextTldIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextTldIdGen.setLong(argIdx++, Id); stmtSelectNextTldIdGen.execute(); long nextId = stmtSelectNextTldIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextTldIdGen != null) { try { stmtSelectNextTldIdGen.close(); } catch (SQLException e) { } stmtSelectNextTldIdGen = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseTenantTable.java
public long nextDomainIdGen(CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) { final String S_ProcName = "nextDomainIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }//from w w w .j a v a 2 s . c o m Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextDomainIdGen = null; try { String sql = "{ call sp_next_domainidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextDomainIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextDomainIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextDomainIdGen.setLong(argIdx++, Id); stmtSelectNextDomainIdGen.execute(); long nextId = stmtSelectNextDomainIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextDomainIdGen != null) { try { stmtSelectNextDomainIdGen.close(); } catch (SQLException e) { } stmtSelectNextDomainIdGen = null; } } }
From source file:com.wabacus.system.component.application.report.configbean.editablereport.StoreProcedureActionBean.java
public void updateData(ReportRequest rrequest, ReportBean rbean, Map<String, String> mRowData, Map<String, String> mParamValues) throws SQLException { AbsDatabaseType dbtype = rrequest.getDbType(this.ownerGroupBean.getDatasource()); Connection conn = rrequest.getConnection(this.ownerGroupBean.getDatasource()); CallableStatement cstmt = null; try {//from w w w .j a v a 2 s. c o m if (Config.show_sql) log.info("Execute sql:" + sql); cstmt = conn.prepareCall(sql); if (lstParams != null && lstParams.size() > 0) { int idx = 1; IDataType varcharTypeObj = Config.getInstance().getDataTypeByClass(VarcharType.class); EditableReportParamBean paramBeanTmp; for (Object paramObjTmp : this.lstParams) { if (paramObjTmp instanceof EditableReportParamBean) { paramBeanTmp = (EditableReportParamBean) paramObjTmp; paramBeanTmp.getDataTypeObj().setPreparedStatementValue(idx++, getParamValue(mRowData, mParamValues, rbean, rrequest, paramBeanTmp), cstmt, dbtype); } else { varcharTypeObj.setPreparedStatementValue(idx++, paramObjTmp == null ? "" : String.valueOf(paramObjTmp), cstmt, dbtype); } } } int outputindex = -1; if (this.returnValueParamname != null && !this.returnValueParamname.trim().equals("")) { outputindex = this.lstParams == null ? 1 : this.lstParams.size() + 1; cstmt.registerOutParameter(outputindex, java.sql.Types.VARCHAR); } cstmt.execute(); if (outputindex > 0) { String rtnVal = cstmt.getString(outputindex); storeReturnValue(rrequest, mParamValues, rtnVal); } } finally { WabacusAssistant.getInstance().release(null, cstmt); } }
From source file:com.cws.esolutions.security.dao.usermgmt.impl.SQLUserManager.java
/** * @see com.cws.esolutions.security.dao.usermgmt.interfaces.UserManager#listUserAccounts() *///from ww w.ja v a2 s .co m public synchronized List<String[]> listUserAccounts() throws UserManagementException { final String methodName = SQLUserManager.CNAME + "#listUserAccounts() throws UserManagementException"; if (DEBUG) { DEBUGGER.debug(methodName); } Connection sqlConn = null; ResultSet resultSet = null; CallableStatement stmt = null; List<String[]> results = 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 listUserAccounts() }"); if (DEBUG) { DEBUGGER.debug("CallableStatement: {}", stmt); } if (stmt.execute()) { resultSet = stmt.getResultSet(); if (resultSet.next()) { resultSet.beforeFirst(); results = new ArrayList<String[]>(); while (resultSet.next()) { String[] userData = new String[] { resultSet.getString("cn"), resultSet.getString("uid") }; if (DEBUG) { for (String str : userData) { DEBUGGER.debug(str); } } results.add(userData); } if (DEBUG) { DEBUGGER.debug("List: {}", results); } } } } catch (SQLException sqx) { throw new UserManagementException(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 UserManagementException(sqx.getMessage(), sqx); } } return results; }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseTenantTable.java
public long nextDomainIdGen(CFAstAuthorization Authorization, CFAstTenantPKey PKey) { final String S_ProcName = "nextDomainIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }/* w w w .ja v a 2s . c om*/ Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextDomainIdGen = null; try { String sql = "{ call sp_next_domainidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextDomainIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextDomainIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextDomainIdGen.setLong(argIdx++, Id); stmtSelectNextDomainIdGen.execute(); long nextId = stmtSelectNextDomainIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextDomainIdGen != null) { try { stmtSelectNextDomainIdGen.close(); } catch (SQLException e) { } stmtSelectNextDomainIdGen = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseTenantTable.java
public int nextTSecGroupIdGen(CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) { final String S_ProcName = "nextTSecGroupIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }//from w w w. j ava 2 s. co m Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextTSecGroupIdGen = null; try { String sql = "{ call sp_next_tsecgroupidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextTSecGroupIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextTSecGroupIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER); stmtSelectNextTSecGroupIdGen.setLong(argIdx++, Id); stmtSelectNextTSecGroupIdGen.execute(); int nextId = stmtSelectNextTSecGroupIdGen.getInt(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextTSecGroupIdGen != null) { try { stmtSelectNextTSecGroupIdGen.close(); } catch (SQLException e) { } stmtSelectNextTSecGroupIdGen = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseTenantTable.java
public int nextTSecGroupIdGen(CFAstAuthorization Authorization, CFAstTenantPKey PKey) { final String S_ProcName = "nextTSecGroupIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }//from w w w. ja v a2s .c om Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextTSecGroupIdGen = null; try { String sql = "{ call sp_next_tsecgroupidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextTSecGroupIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextTSecGroupIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER); stmtSelectNextTSecGroupIdGen.setLong(argIdx++, Id); stmtSelectNextTSecGroupIdGen.execute(); int nextId = stmtSelectNextTSecGroupIdGen.getInt(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextTSecGroupIdGen != null) { try { stmtSelectNextTSecGroupIdGen.close(); } catch (SQLException e) { } stmtSelectNextTSecGroupIdGen = null; } } }