Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » Servlet JNDI sqljdbc failed(sqljdbc connection not working after migration)
Servlet JNDI sqljdbc failed [message #1467879] Mon, 10 November 2014 11:33 Go to next message
Alan Farroll is currently offline Alan FarrollFriend
Messages: 60
Registered: June 2012
Member
Hi,

A Java servlet I maintain connects to a SQL server database that was migrated to a new server recently. The database previously run on Sql Server 2005 SP2 but now runs on SQL Server 2008 R2 SP2 and the connection has stopped working. It was developed on Eclipse Helios and runs through Tomcat 7.0 using JNDI connections.

When the database was migrated I ensured a connection could be made by setting up a Data Source in Eclipse and it connects successfully using the credentials and port number etc. But the actual connection through JNDI will no longer work even though I have updated the JNDI tag with the new information that connects fine through the Eclipse Data Source

My investigation initially pointed to using the driver sqljdbc4-3.0.jar instead of sqljdbc1-2.0.jar. I have placed the sqljdbc4.3.0.jar in the tomcat \lib directory and removed the sqljdbc1-2.0.jar but it still doesn't work. I have also added to the "Windows" classpath environment variable the value %CATALINA_HOME%\lib\sqljdbc4-3.0.jar but again still does not work. I have also added the sqljdbc4.3.0.jar to the classpath in Eclipse but none of these things have worked. I have also applied the new SSL certificates to the key store.

Can someone please advise me of what I am missing or doing wrong?

Thanks in advance

AJF
Re: Servlet JNDI sqljdbc failed [message #1495640 is a reply to message #1467879] Tue, 02 December 2014 11:34 Go to previous message
Alan Farroll is currently offline Alan FarrollFriend
Messages: 60
Registered: June 2012
Member
I managed to find a solution and managed to create a successful connection. It appears that when attempting to connect to SQL Server 2008 R2 using the Microsoft sqljdbc driver can cause huge problems as outlined in this link I finally found below and they also suggest an alternative third party driver named jtds;

http://stackoverflow.com/questions/1310536/how-to-make-java-work-with-sql-serve

The driver is available from this URL;

http://jtds.sourceforge.net/

I downloaded the driver but required an earlier version so downloaded version 1.2.7 and simply placed the jar file in tomcat/lib directory. Then changed the Tomcat context.xml's JNDI entry to be the following and it is connecting;

<Resource auth="Container" driverClassName="net.sourceforge.jtds.jdbc.Driver" factory="org.moss.jdj.dbcp.EncryptedDataSourceFactory" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/edrms" password="password" type="javax.sql.DataSource"
url="jdbc:jtds:sqlserver://myservername:2369:\mySQLdatabaseinstance;databaseName=mydatabasename" username="username" />

Thanks to all who viewed

Ajfarroll
Previous Topic:Oracle - Unable to use new syntax connection string when using Database Development Perspective
Next Topic:Eclipse preloading wrong JDBC driver without asking
Goto Forum:
  


Current Time: Thu Apr 25 09:57:43 GMT 2024

Powered by FUDForum. Page generated in 5.02486 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top