Dear All,
I have scenario that may need to use jdbcpool query database, i understand that I need to deploy JDBC driver and create JDBC data source with XA datasource type due to two phase commit required, everything is fine from nwa as I created but once I try execute from UDF I got an error as following this detail.
com.sap.engine.services.dbpool.cci.ConnectionFactoryImpl:service:dbpool@com.sap.engine.boot.loader.ResourceMultiParentClassLoader@5e832150@alive incompatible with interface javax.sql.XADataSource
Please refer for this info.
Database: MS SQL Server 2008
JDBC: sqljdbc.jar
SAP: PI 7.1
UDF Code: (which I got guideline from http://scn.sap.com/people/william.li/blog/2007/03/30/using-jdbc-connection-pool-in-xi-message-mapping)
String dataSource = "jdbc/SQLServerPI";
String sqlStmt = "select * from ztest where id <5";
Connection conn = null;
XAConnection xaconn = null;
XADataSource ds = null;
Statement stmt = null;
ResultSet rst = null;
javax.naming.InitialContext ctx = null;
try {
ctx = new javax.naming.InitialContext();
if (ctx == null) {
value = "Error - No Context";
return "1:::" + value;
}
}
catch (Exception e) {
value = e.getMessage();
return "3:::" + value;
}
try{
ds = (XADataSource) ctx.lookup(dataSource);
if (ds == null) {
value = "Error - No dataSource: " + dataSource;
return "3.5:::" + value;
}
}
catch (Exception e) {
value = e.getMessage();
return "3.5:::" + value;
}
try {
xaconn = ds.getXAConnection();
conn = xaconn.getConnection();
if (conn != null) {
stmt = conn.createStatement();
rst = stmt.executeQuery(sqlStmt);
while (rst.next()){
value += rst.getString(1) + "," + rst.getString(2) + "," + rst.getString(3) + "," + rst.getString(4) + "\n" ;
}
conn.close();
}
}
catch (Exception e) {
value = "4:::" + e.getMessage();
}
as I checked it's error at datasource lookup.
Anyone got any Idea?
Thanks and Regards
Park