File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes I have a question for sql server2000 JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "I have a question for sql server2000 JDBC" Watch "I have a question for sql server2000 JDBC" New topic
Author

I have a question for sql server2000 JDBC

Deyu Wang
Greenhorn

Joined: Sep 26, 2006
Posts: 6
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 ]

SCJP
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Deyu Wang
Greenhorn

Joined: Sep 26, 2006
Posts: 6
Thanks!
May be I should change the Sql Server JDBc!
 
GeeCON Prague 2014
 
subject: I have a question for sql server2000 JDBC