I am trying to use a DB2 stored procedure in a managed bean.
The following code works in a Java agent:
1. Class.forName("com.ibm.db2.jcc.DB2Driver");
2. Connection con = DriverManager.getConnection("jdbc:db2://10.10.10.10:50001/MYDB", "userid", "password");
3. CallableStatement cs1 = con.prepareCall("CALL V1.MYPROC(?)");
4. Integer[] myArr = new Integer[2];
5. myArr[0] = 1;
6. myArr[1] = 2;
7. cs1.setArray(1, con.createArrayOf("INTEGER", myArr));
8. cs1.execute();
If I create similar code in a managed bean and utilize the ExtLib connection pool, the code looks like this:
1. InitialContext ctx = new InitialContext();
2. DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/db2");
3. Connection con = ds.getConnection();
4. CallableStatement cs1 = con.prepareCall("CALL V1.MYPROC(?)");
5. Integer[] myArr = new Integer[2];
6. myArr[0] = 1;
7. myArr[1] = 2;
8. cs1.setArray(1, con.createArrayOf("INTEGER", myArr)); <-- FAILS
9. cs1.execute();
In the managed bean, line 8 fails with java.lang.AbstractMethodError: java/sql/Connection.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;) appearing in error-log-0.xml
Generally, this error occurs if the JDBC driver is not a Type 4 driver running Java version 5 or 6. Both the agent and the managed bean reports Java version 1.6.0 and JDBC version 4.13 (IBM Data Server Driver for JDBC and SQLJ).
The connection pool works fine for other purposes such as con.PrepareStatement etc.