|
Home > Archive > SQL Server JDBC > September 2005 > Unable to connect to SQL Server 2000 using JNDI and Tomcat 5.0
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Unable to connect to SQL Server 2000 using JNDI and Tomcat 5.0
|
|
| stegra 2005-07-24, 3:23 am |
| When I attempt to connect to my SQL Server database I get the following
SQL Exception:
SQLState: null
Message: Cannot create JDBC driver of class '' for connect
URL 'null'
Vendor Code: 0
Environment:
Tomcat Install Directory: "C:\Tomcat 5.0"
SQL Server JDBC Jar Files (msbase.jar, mssqlserver.jar &
msutil.jar)Directory: "C:\Tomcat 5.0\common\lib"
********************
********************
*******************
Application directory: "C:\Tomcat 5.0\webapps\TEC"
********************
********************
*******************
web.xml directory "C:\Tomcat 5.0\webapps\TEC\WEB-INF"
********************
********************
*******************
web.xml contents:
********************
********************
*******************
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Timed Essential Conferencing</display-name>
<description>
TEC
</description>
<resource-ref>
<res-ref-name>jdbc/DefaultDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
********************
********************
*******************
context.xml Directory: "C:\Tomcat 5.0\webapps\TEC\META-INF"
********************
********************
*******************
context.xml Contents:
********************
********************
*******************
<!-- The contents of this file will be loaded for each web application
-->
<Context
cookies="true"
crossContext="true"
reloadable="true"
antiJARLocking="true"
antiResourceLocking=
"true"
cacheMaxSize="1024"
cacheTTL="5000"
cachingAllowed="true"
caseSensitive="true"
managerChecksFrequen
cy="10"
processTlds="true"
swallowOutput="false"
tldNamespaceAware="false"
tldValidation="false"
unpackWAR="true"
useNaming="true"
>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>META-INF/context.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across
Tomcat
restarts -->
<!--
<Manager pathname="" />
-->
<Resource name="jdbc/DefaultDS" auth="Container"
scope="Shareable"
type="javax.sql.DataSource"
maxActive="15"
maxIdle="5"
maxOpenPreparedState
ments="0"
minIdle="0"
maxWait="60000"
username="test"
password="test"
DatabaseName="TEC"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url=" jdbc:microsoft:sqlse
rver://essential-sbs:1433"
numTestsPerEvictionR
un="15"
timeBetweenEvictionR
unsMillis="900000"
minEvictableIdleTime
Millis="900000"
testWhileIdle="true"
testOnBorrow="false"
validationQuery="select count(*) from
tec.dbo.conference"
removeAbandoned="true"
removeAbandonedTimeo
ut="300"
logAbandoned="true"
/>
</Context>
********************
********************
*******************
login.jsp
********************
********************
*******************
<%@ page import="javax.naming.*, java.sql.*, javax.sql.DataSource"%>
<%
Connection conn = null;
InitialContext ctx = null ;
java.sql.Statement stmt = null;
ResultSet rs = null;
try
{
ctx = new InitialContext();
Context envCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/DefaultDS");
conn = ds.getConnection();
stmt = conn.createStatement();
/*etc...*/
}
catch (SQLException ex) {
while (ex != null){
system.out.println("SQLState: " + ex.getSQLState());
system.out.println("Message: " + ex.getMessage());
system.out.println("Vendor Code: " + ex.getErrorCode());
ex = ex.getNextException();
}
}
catch (Exception e) {
}
finally {
try {
if (stmt!=null) stmt.close();
if (conn!=null) conn.close();
if (ctx!=null) ctx.close();
}
catch(Exception ex) {
// do nothing
}
}
%>
********************
********************
*******************
Any Ideas as to why this is failing?
Thanks in advance.
| |
| Sue Purkis 2005-09-06, 8:23 pm |
| I have been comparing what you have listed here, to what we have in an
implementation that works. Can you provide one additional piece of
information? Can you provide the contents of your server.xml file?
Thanks.
Sue Purkis
DataDirect Technologies
"stegra" <stegra@qwest.net> wrote in message
news:1122176843.007206.136120@o13g2000cwo.googlegroups.com...
> When I attempt to connect to my SQL Server database I get the following
> SQL Exception:
> SQLState: null
> Message: Cannot create JDBC driver of class '' for connect
> URL 'null'
> Vendor Code: 0
>
> Environment:
> Tomcat Install Directory: "C:\Tomcat 5.0"
> SQL Server JDBC Jar Files (msbase.jar, mssqlserver.jar &
> msutil.jar)Directory: "C:\Tomcat 5.0\common\lib"
> ********************
********************
*******************
> Application directory: "C:\Tomcat 5.0\webapps\TEC"
> ********************
********************
*******************
> web.xml directory "C:\Tomcat 5.0\webapps\TEC\WEB-INF"
> ********************
********************
*******************
> web.xml contents:
> ********************
********************
*******************
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
> version="2.4">
>
> <display-name>Timed Essential Conferencing</display-name>
> <description>
> TEC
> </description>
>
> <resource-ref>
> <res-ref-name>jdbc/DefaultDS</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
> <resource-ref>
> <res-ref-name>mail/Session</res-ref-name>
> <res-type>javax.mail.Session</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
> </web-app>
> ********************
********************
*******************
> context.xml Directory: "C:\Tomcat 5.0\webapps\TEC\META-INF"
> ********************
********************
*******************
> context.xml Contents:
> ********************
********************
*******************
> <!-- The contents of this file will be loaded for each web application
> -->
> <Context
> cookies="true"
> crossContext="true"
> reloadable="true"
> antiJARLocking="true"
> antiResourceLocking=
"true"
> cacheMaxSize="1024"
> cacheTTL="5000"
> cachingAllowed="true"
> caseSensitive="true"
> managerChecksFrequen
cy="10"
> processTlds="true"
> swallowOutput="false"
> tldNamespaceAware="false"
> tldValidation="false"
> unpackWAR="true"
> useNaming="true"
>
>
> <!-- Default set of monitored resources -->
> <WatchedResource>WEB-INF/web.xml</WatchedResource>
> <WatchedResource>META-INF/context.xml</WatchedResource>
>
> <!-- Uncomment this to disable session persistence across
> Tomcat
> restarts -->
> <!--
> <Manager pathname="" />
> -->
>
> <Resource name="jdbc/DefaultDS" auth="Container"
> scope="Shareable"
> type="javax.sql.DataSource"
> maxActive="15"
> maxIdle="5"
> maxOpenPreparedState
ments="0"
> minIdle="0"
> maxWait="60000"
> username="test"
> password="test"
> DatabaseName="TEC"
>
> driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
>
> url=" jdbc:microsoft:sqlse
rver://essential-sbs:1433"
> numTestsPerEvictionR
un="15"
> timeBetweenEvictionR
unsMillis="900000"
> minEvictableIdleTime
Millis="900000"
> testWhileIdle="true"
> testOnBorrow="false"
> validationQuery="select count(*) from
> tec.dbo.conference"
> removeAbandoned="true"
> removeAbandonedTimeo
ut="300"
> logAbandoned="true"
> />
>
>
>
> </Context>
> ********************
********************
*******************
> login.jsp
> ********************
********************
*******************
> <%@ page import="javax.naming.*, java.sql.*, javax.sql.DataSource"%>
> <%
>
> Connection conn = null;
> InitialContext ctx = null ;
> java.sql.Statement stmt = null;
> ResultSet rs = null;
> try
> {
> ctx = new InitialContext();
> Context envCtx = (Context) ctx.lookup("java:comp/env");
> DataSource ds = (DataSource) envCtx.lookup("jdbc/DefaultDS");
> conn = ds.getConnection();
> stmt = conn.createStatement();
> /*etc...*/
> }
> catch (SQLException ex) {
> while (ex != null){
> system.out.println("SQLState: " + ex.getSQLState());
> system.out.println("Message: " + ex.getMessage());
> system.out.println("Vendor Code: " + ex.getErrorCode());
> ex = ex.getNextException();
> }
> }
> catch (Exception e) {
> }
> finally {
> try {
> if (stmt!=null) stmt.close();
> if (conn!=null) conn.close();
> if (ctx!=null) ctx.close();
> }
> catch(Exception ex) {
> // do nothing
> }
> }
>
> %>
>
> ********************
********************
*******************
> Any Ideas as to why this is failing?
> Thanks in advance.
>
|
|
|
|
|