我可以用StoredProcedureRequest编码到数据库
StoredProcedureQuery query = entityManager.createNamedStoredProcedureQuery("checkTest");
query.registerStoredProcedureParameter(2, String.class, ParameterMode.IN);
query.registerStoredProcedureParameter(3, String.class, ParameterMode.IN);
query.registerStoredProcedureParameter(4, Integer.class, ParameterMode.IN);
query.registerStoredProcedureParameter(1, void.class, ParameterMode.REF_CURSOR);
query.setParameter(2, dto.getIdentity());
query.setParameter(3, dto.getSourceIp());
query.setParameter(4, dto.getSource());
query.execute();
类callablestatement的所有变化如下:
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@10.233.1.120:1222:asd", "asdasdasd", "asdasdasd");
conn.setAutoCommit(false);
CallableStatement properCase = conn.prepareCall(" ? = check_test( ?,?,? ) ");
properCase.registerOutParameter(1, Types.REF_CURSOR);
properCase.setString(2, dto.getIdentity());
properCase.setString(3, dto.getSourceIp());
properCase.setInt(4, dto.getSource());
properCase.execute();
ResultSet rs = (ResultSet) properCase.getObject(1);
while (rs.next()) {
logger.error(rs.getCursorName());
}
暂无答案!
目前还没有任何答案,快来回答吧!