I configured my Tomcat server (4.1.24, jdk1.3.1_02/j2sdk1.4.0_01, Win2000
Professional)
as it was described in section "MySQL DBCP Example" of
jndi-datasource-examples-howto.html
file from Tomcat documentation. Everything works. Then I repeated the same with JDBC
driver
for MS SQL server. I got it from Microsoft site. When I used:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://alext:1433;DatabaseName=pubs;User=alext;Password=java");
I got data from my MS SQL server without any problems.
When I repeated my configuration used for MySQL with MS SQL server I got next message:
org.apache.jasper.JasperException: Name jdbc is not bound in this Context
and many other string...
When I looked at log file I saw next:
2003-04-03 18:14:23 NamingContextListener[/Standalone/localhost]: Resource
parameters for jdbc/PubsDb = ResourceParams[name=jdbc/PubsDb,
parameters={factory=org.apache.commons.dbcp.BasicDataSourceFactory, maxWait=10000,
maxActive=100, url=jdbc:microsoft:sqlserver://alext:1433, password=java,
driverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver, maxIdle=30,
username=alext}]
2003-04-03 18:14:23 NamingContextListener[/Standalone/localhost]: Adding resource
ref jdbc/PubsDb
2003-04-03 18:14:23 NamingContextListener[/Standalone/localhost]:
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=maxWait,content=10000},{type=maxActive,content=100},{type=url,content=jdbc:microsoft:sqlserver://alext:1433},{type=password,content=java},{type=driverClassName,content=com.microsoft.jdbc.sqlserver.SQLServerDriver},{type=maxIdle,content=30},{type=username,content=alext}]
2003-04-03 18:14:23 NamingContextListener[/Standalone/localhost]: Resource
parameters for jdbc/TestDB = ResourceParams[name=jdbc/TestDB,
parameters={factory=org.apache.commons.dbcp.BasicDataSourceFactory,
url=jdbc:mysql://localhost/bookstore?autoReconnect=true, password=mysql,
maxWait=10000, maxActive=100, driverClassName=org.gjt.mm.mysql.Driver, username=mysql,
maxIdle=30}]
2003-04-03 18:14:23 NamingContextListener[/Standalone/localhost]: Adding resource
ref jdbc/TestDB
2003-04-03 18:14:23 NamingContextListener[/Standalone/localhost]:
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=url,content=jdbc:mysql://localhost/bookstore?autoReconnect=true},{type=password,content=mysql},{type=maxWait,content=10000},{type=maxActive,content=100},{type=driverClassName,content=org.gjt.mm.mysql.Driver},{type=username,content=mysql},{type=maxIdle,content=30}]
2003-04-03 18:14:23 NamingContextListener[/Standalone/localhost]: Resource
parameters for UserTransaction = null
So as I understand JNDI resource jdbc/PubsDb is bound for my context (I used ROOT
context).
Is any solution to use DataSource in Tomcat for MS SQL server?
Alex.