van
van

Reputation: 9449

tomcat JNDI database configuration

I have the following in C:/Tomcat6/conf/context.xml:

<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <ResourceLink global="jdbc/MyDatasource" name="jdbc/MyDatasource" type="javax.sql.DataSource"/>


</Context>

and the following in C:/Tomcat6/conf/server.xml:

<Resource name="jdbc/MyDatasource"
    auth="Container"
    driverClassName="net.sourceforge.jtds.jdbc.Driver"
    maxactive="100"
    maxidle="30"
    maxwait="10000"
    type="javax.sql.DataSource"    
    jdbcUrl="jdbc:jtds:sqlserver://localhost/SAFEHOUSE-UK;integratedSecurity=true;">

I have jtds-1.2.5.jar in C:/Tomcat6/lib.

Yet when I hit my application I get the following:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class 'net.sourceforge.jtds.jdbc.Driver' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) at com.safehouse.safeservices.authenticate.AdminLoginForm.getpassword(Unknown Source)

Any help would be much appreciated

Upvotes: 0

Views: 1258

Answers (2)

Nicola Baiocco
Nicola Baiocco

Reputation: 156

From Apache Tomcat 6 documentation: https://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html maybe the mistake was in attribute name, try to use url instead of jdbcUrl

Upvotes: 1

sunysen
sunysen

Reputation: 2351

1、modify the connection url

 jdbcUrl="jdbc:jtds:sqlserver://localhost:1305;DatabaseName=your databasename"

Upvotes: 1

Related Questions