Hi All, I am from IBM - Informix Product Interoperability team . I tried to create a JNDI connection from Tomcat to Database Informix. But it is throwing error. I classified the error by the following way :
1. When I tried with type="javax.sql.DataSource" , I am getting error "Cannot create PoolableConnectionFactory (Can't load driver java.lang.reflect.InvocationTargetException)" . 2. When I tried with type="com.informix.jdbcx.IfxConnectionPoolDataSource" , I am getting error "java.sql.SQLException: No suitable driver". 3. But we use JNDI connections from WAS , WAS CE and Web Logic also. There it works fine. 4. Here I have added a sample Java Code also for Pooled connection and it is working fine. So the clarification I need is, whether Tomcat supports Informix for a JNDI connection. If yes, please suggest me the way it should work . I attached my context.xml as well as web.xml contains also. Looking for your help eagerly. ==================================================================================== Context File Entry: <Resource name="jdbc/myinformix" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="inform" password="inform123" driverClassName="com.informix.jdbc.IfxDriver" url="jdbc:informix-sqli://idcps2.in.ibm.com:16001/stores_demo:INFORMIXSERVER=ids1050"/> WEB-INF\web.xml Entry: <description>Informix Test Connection</description> <resource-ref> <description>Informix DB Connection</description> <res-ref-name>jdbc/myinformix</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Can't load driver java.lang.reflect.InvocationTargetException)" org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause javax.servlet.ServletException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Can't load driver java.lang.reflect.InvocationTargetException)" org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774) org.apache.jsp.Informix.test_005fconnection_jsp._jspService(test_005fconnection_jsp.java:80) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Can't load driver java.lang.reflect.InvocationTargetException)" org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(Unknown Source) org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(Unknown Source) org.apache.jsp.Informix.test_005fconnection_jsp._jspx_meth_sql_005fquery_005f0(test_005fconnection_jsp.java:99) org.apache.jsp.Informix.test_005fconnection_jsp._jspService(test_005fconnection_jsp.java:57) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) =========================================================================================== Context File Entry: <Resource name="jdbc/myinformix" auth="Container" type="com.informix.jdbcx.IfxConnectionPoolDataSource" maxActive="100" maxIdle="30" maxWait="10000" username="inform" password="inform123" driverClassName="com.informix.jdbc.IfxDriver" url="jdbc:informix-sqli://idcps2.in.ibm.com:16001/stores_demo:INFORMIXSERVER=ids1050"/> WEB-INF\web.xml Entry: <resource-ref> <description>Informix DB Connection</description> <res-ref-name>jdbc/myinformix</res-ref-name> <res-type>com.informix.jdbcx.IfxConnectionPoolDataSource</res-type> <res-auth>Container</res-auth> </resource-ref> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver" org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774) org.apache.jsp.Informix.test_005fconnection_jsp._jspService(test_005fconnection_jsp.java:82) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver" org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(Unknown Source) org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(Unknown Source) org.apache.jsp.Informix.test_005fconnection_jsp._jspx_meth_sql_005fquery_005f0(test_005fconnection_jsp.java:101) org.apache.jsp.Informix.test_005fconnection_jsp._jspService(test_005fconnection_jsp.java:59) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) ======================================================================================================= Stand Alone Java Program works perfectly for a pooled connection import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import com.informix.jdbcx.IfxConnectionPoolDataSource; import javax.sql.*; public class test5 { IfxConnectionPoolDataSource cpds = null; public Connection getConnection () throws SQLException, Exception { cpds = new IfxConnectionPoolDataSource(); cpds.setUser("informix"); cpds.setPassword("inform123"); cpds.setServerName("ids1050"); cpds.setDatabaseName("stores_demo"); cpds.setPortNumber(16001); cpds.setIfxPROTOCOLTRACE(99); cpds.setIfxIFXHOST("idcps2.in.ibm.com"); PooledConnection pooledCon = cpds.getPooledConnection(); return pooledCon.getConnection(); } void testinsert (Connection conn) throws SQLException { int rc ; String sql = "INSERT INTO TOMCAT_TEST VALUES ( 1, 'TEST') " ; try { PreparedStatement pstmt = conn.prepareStatement(sql); System.out.println("Executing the statement: " + sql); rc = pstmt.executeUpdate(); System.out.println("Statement executed successfully with RC "+ rc); sql="select * from TOMCAT_TEST"; pstmt = conn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { System.out.println("After fetch the value is ID=" +rs.getString(1) + " CHAR "+ rs.getString(2) ); } } catch (SQLException s) { printSQLException(s); System.out.println("Prepare Statement: " + s.toString()); } } public void createTable (Connection conn) throws SQLException { String sql = "CREATE TABLE TOMCAT_TEST( ID_TOMCAT INTEGER,ID_CHAR CHAR(12)) LOCK MODE ROW" ; Statement stmt = conn.createStatement(); System.out.println("Creating the table TOMCAT_TEST ..."); stmt.executeUpdate(sql); System.out.println("Table created successfully!"); } public void dropTable (Connection conn) throws SQLException { String sql = "DROP TABLE TOMCAT_TEST"; Statement stmt = conn.createStatement(); try { System.out.println("Dropping the table TOMCAT_TEST ..."); stmt.executeUpdate(sql); System.out.println("Table dropped successfully!"); } catch (SQLException exc) { if (exc.getSQLState().equals("42000")) { System.out.println("The table, dbuser1.user1, does not exist in the database."); System.out.println("Skip dropping the table."); } else { printSQLException(exc); throw exc; } } } public static void printSQLException (SQLException exc) { if (exc != null) { System.out.println("Error Code: " + exc.getErrorCode()); System.out.println("SQL State: " + exc.getSQLState()); System.out.println("Message: " + exc.getMessage()); exc.printStackTrace(); printSQLException(exc.getNextException()); } else { return; } } public static void main (String[] args) { test5 test = new test5(); try { Connection conn = test.getConnection(); test.dropTable(conn); test.createTable(conn); test.testinsert(conn); } catch (Exception exc) { exc.printStackTrace(); } } } Thanks.. Amitava Chakraborty PMPĀ® Lead - Informix Interoperability IBM India PVT LTD. Plot No 1&2, Block - G, 2nd Floor , The Mira Corporation Suites, Old Ishwar Nagar, Mathura Rd. New Delhi 110065 ------------------------------------------- Ph : Extn : 91-11-46592644 / 91-129-4033409 Mobile : +919958995870 Fax : 91-11-26921061 E - id : [EMAIL PROTECTED] --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]