Folks,
I am trying to connect to a MS SQL database using Tomcat/JSP but having issues. The code that I am using is as follows:
Context ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("java:comp/env/j
dbc/test")
;
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
I have added the following code to my Server.xml:
<Resource name="jdbc/test" auth="Container" type="javax.sql.DataSource
"
maxActive="100" maxIdle="30" maxWait="10000"
username="DB_AW_DATA" password="tester" driverClassName="com.micro
soft.jdbc.
sqlserver.
SQLServerD
river"
url="jdbc:microsoft:sqlser
ver://192.
168.0.1\\N
ewcastle"/
>
And I have added the following code to web.xml:
<resource-ref>
<description>
Resource reference to java.sql.Connection
factory defined in server.xml
</description>
<res-ref-name>jdbc/test</r
es-ref-nam
e>
<res-type>javax.sql.DataSo
urce</res-
type>
<res-auth>Container</res-a
uth>
</resource-ref>
The error message that I am getting is as follows:
java.sql.SQLException: Cannot load JDBC driver class 'null'
What confuses me is that I have placed the following files in Tomcat\common\lib...
mssqlserver.jar
msbase.jar
msutil.jar
However they are also included in Tomcat\webapps\-AppName-\W
EB-INF\lib
as they are included in th *.war file.
What is also confusing is that when deploying the *.war file I get the following
Tomcat\webapps\-AppName-\c
lasses
Tomcat\webapps\-AppName-\c
lasses(2)
Tomcat\webapps\-AppName-\T
omcat\conf
Tomcat\webapps\-AppName-\T
omcat\conf
(2)
Please help. Any help would be much apprecaited.
Kind regards
Angus
Start Free Trial