Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I have a question for sql server2000 JDBC

 
Deyu Wang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Error message:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory ([Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.)

Tomcat5.5.9+sql server2000+jdk1.5



$Tomcat_home$\conf\server.xml:
<GlobalNamingResources>
...
<Resource name="jdbc/sa"
type="javax.sql.DataSource"
password="123456"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
maxIdle="2"
maxWait="5000"
username="sa"
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=eshop"
maxActive="4"
/>
...
</GlobalNamingResources>

//eshop is my web application catalog.

$Tomcat_home%\conf\Catalina\localhost\eshop.xml
<Context>
<Resource name="jdbc/sa"
type="javax.sql.DataSource"
password="123456"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
maxIdle="2"
maxWait="5000"
username="sa"
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=eshop" maxActive="4"
/>
</Context>


$Tomcat_home\webapps\eshop\WEB-INF\web.xml
<web-app>
...
<resource-ref>
  <description>sqlserverDB Connection</description>
  <res-ref-name>jdbc/sa</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>
...
</web-app>

$Tomcat_home\webapps\eshop\dataSource.jsp
<%
DataSource ds=null;
Context ctx=null;

try{
ctx=new InitialContext();
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/sa");
out.print(ds+"<br>");
Connection conn=ds.getConnection();
}catch(Exception ex){
out.print(ex+"<br>");
}
if(conn!=null)
conn.close();
%>

please help me.

Thanks.

[ September 26, 2006: Message edited by: wang deyu ]
[ September 26, 2006: Message edited by: wang deyu ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using Microsoft's own JDBC driver for SQL Server 2000? First off you probably want to change to jTDS or the newer 2005 driver. Next you need to verify that you can actually connect to a database on your local server called eshop - is it running? Does it allow TCP/IP connections? Is it using SQL Server authentication, rather than Windows Integrated security (not an issue if you use jTDS)? Is there any port blocking software runing that might stop you connecting?
 
Deyu Wang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
May be I should change the Sql Server JDBc!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic