本文整理汇总了Java中java.sql.CallableStatement.setArray方法的典型用法代码示例。如果您正苦于以下问题:Java CallableStatement.setArray方法的具体用法?Java CallableStatement.setArray怎么用?Java CallableStatement.setArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.CallableStatement
的用法示例。
在下文中一共展示了CallableStatement.setArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeStoredProcedure
import java.sql.CallableStatement; //导入方法依赖的package包/类
protected void executeStoredProcedure(final Connection pooledConnection, final String userid) throws java.sql.SQLException {
CallableStatement cs = null;
final String localId = (String) ContextManagerFactory.instance().getProperty(LOCAL_ID);
Object[] roles = getUserRoles(userid).toArray();
ARRAY newArray = null;
Connection connection = null;
try {
// Extract the actual oracle connection
connection = pooledConnection.unwrap(oracle.jdbc.OracleConnection.class);
if (!(connection instanceof oracle.jdbc.OracleConnection)) {
throw new Exception(String.format("Not an Oracle Connection : %s",connection.getClass().getName()));
}
cs = connection.prepareCall(CALL_JAFFA_SEC_SET_USERID);
cs.setString(1,userid);
newArray = ((oracle.jdbc.OracleConnection)connection).createARRAY(ROLE,roles);
cs.setArray(2,newArray);
cs.setString(3,localId);
if (log.isDebugEnabled()) {
// Log the call to the stored procedure
debugStatement(userid, localId, roles, newArray);
}
if(log.isDebugEnabled()) log.debug("Calling the Stored Procedure to Set the Context");
cs.execute();
connection.commit();
}
catch (Exception exception) {
final String message = String.format(String.format(SET_THE_CONTEXT_ERROR_MESSAGE,exception.getMessage()));
log.error(message, exception);
if (connection != null)
connection.rollback();
throw new UOWSecurityException(message, exception);
}
finally {
roles = null;
if (newArray != null)
newArray.free();
if (cs != null) {
cs.clearParameters();
cs.close();
cs = null;
}
}
}