Hi,
I use JDBC API to execute a Stored Procedure. For this, I use the deprecated (in Hibernate 3.2.6) methode Session.connection()
With this connection, I can use a CallableStatement (Jdbc API).
Expl :
Code:
Connection conn = sess.connection();
String sql = "{call PREFCO006_INT_PLASMA2REFCO.P_CREATE_ARTICLE(?, ?, ?, ?, ?, ?, ?)}";
CallableStatement cstmt = conn.prepareCall(sql);
cstmt.registerOutParameter(4, Types.VARCHAR);
cstmt.registerOutParameter(6, Types.VARCHAR);
cstmt.registerOutParameter(7, Types.VARCHAR);
cstmt.setString(1, null);
cstmt.setString(2, null);
cstmt.setString(3, /* myVariableInput*/);
cstmt.setString(4, "0");
cstmt.setString(5, "xxx");
cstmt.execute();
int retour = Integer.parseInt(cstmt.getString(4));
if (retour < 0) {
// do something like throx an Exception
}
if (cstmt.getString(6) != null) {
String newCode = extractCode(cstmt.getString(6));
// do something with this returned value
}
I don't know if it is a "good way", but it works in my production environnement !