tags:

views:

62

answers:

2

I'm deploying an old app on a new box. When hitting the database for the first time I get

File input error: Cannot create PoolableConnectionFactory (Invalid handle)

I've set up my resource in context.xml, my dsn with unixODBC, and my resource-ref in web.xml. What else am I missing?

from content.xml -->

<Resource name="jdbc/MoleComp" auth="Container"
type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="-1"
removeAbandoned="false" removeAbandonedTimeout="60"
username="userName" password="passWord" 
driverClassName="sun.jdbc.odbc.JdbcOdbcDriver" 
url="jdbc:odbc:DSNName"/>

from app/WEB-INF/web.xml -->

<resource-ref>
    <description>DB connection</description>
    <res-ref-name>jdbc/MoleComp</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

Thanks.

A: 

First, you should remove the <resource-def> from web.xml. This is just another way to define data source, which you've already done in context.xml.

That error is from ODBC-JDBC bridge driver. So either ODBC is not running or the url="jdbc:odbc:DSNName" is invalid.

ZZ Coder
Thanks Zhihong. It is a valid DSN, I can connect to it from the shell with isql (provided with unixODB). If I give it an invalid DSN, I get "Cannot create PoolableConnectionFactory ([unixODBC][Driver Manager]Data source name not found, and no default driver specified)"
Mark
Oh, and I remove the <resource-ref> from web.xml, still get the same error.
Mark
I have no experience with unixODB. It must be some kind of environment difference causing it work in isql, not in Java.
ZZ Coder
A: 

After getting this problem on yet another server, I switched the application from using unixODBC and odbc.jdbc to java type 4 driver jTDS jtds.jdbc. Performance is a bit better too!

Mark