Fredrik Skånberg | 2006-04-26 02:30:21.0 | |
Hi!
I'm trying to create JNDI Datasource to a database in a Tomcat 5.5 environment. But I can't figure out how to do it. What am I doing wrong? I can access the database the normal way so it's nothing wrong with the database url and so. I have put this in my context.xml: username="" password="" driverClassName="com.hxtt.sql.access.AccessDriver" url="jdbc:access:/e:/tmp/webtest.mdb"/> In my web.xml I have this: And in a test servlet I use this: Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); DataSource ds = (DataSource) envCtx.lookup("jdbc/dctest"); Connection conn = ds.getConnection(); But I receive an exception: Cannot create JDBC driver of class '' for connect URL 'null' What's wrong? Regards, Fredrik Skånberg, Sweden | ||
HXTT Support | 2006-04-26 10:17:34.0 | |
username="" password="" driverClassName="com.hxtt.sql.access.AccessDriver" url="jdbc:access:///f:/mdbfiles/aaa.mdb"/> If it cannot work normal,please tell us your version of tomcat. I tested upper config at tomcat 5.5.9 and it work normal. | ||
HXTT Support | 2006-04-26 10:19:54.0 | |
<!--context.xml--> <Resource name="jdbc/testAccessPool1" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="" password="" driverClassName="com.hxtt.sql.access.AccessDriver" url="jdbc:access:///f:/mdbfiles/aaa.mdb"/> <!--web.xml--> <resource-ref> <res-ref-name>jdbc/testAccessPool1</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> If it cannot work normal,please tell us your version of tomcat. I tested upper config at tomcat 5.5.9 and it work normal. | ||
Fredrik Skånberg | 2006-04-27 04:51:16.0 | |
Hi!
I still can't get it to work. I have tried it on Tomcat 5.5.12 and 5.5.16. I copied your example and used this in a servlet: Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); DataSource ds = (DataSource) envCtx.lookup("jdbc/testAccessPool1"); Connection conn = ds.getConnection(); But when I run this I get this: Cannot create JDBC driver of class '' for connect URL 'null'. Where have you put Access_JDBC30.jar? In the applications WEB-INF/lib or in {Tomcat home}/common/lib or some place else? /Fredrik | ||
HXTT Support | 2006-04-27 06:51:31.0 | |
I use tomcat 5.5.16 to test and it work normal. | ||
Fredrik Skånberg | 2006-04-27 08:30:27.0 | |
Hi!
Now it's working. It was two errors. I had put the context.xml file in the WEB-INF folder and not in the META-INF folder and my Context tag was written with a lower case, context. Realy bad error messages from Tomcat here. But because of your little demo application I was able to solve this problem. Thanks for excellent support! /Fredrik |