java.sql.array的实例_Java CallableStatement.setArray方法代码示例

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;

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值