p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Apache Tomcat (http://p2p.wrox.com/forumdisplay.php?f=107)
-   -   JNDI connection not working (http://p2p.wrox.com/showthread.php?t=93833)

ajfarroll November 19th, 2014 07:39 AM

JNDI connection not working
 
Hi all,

I maintain a Java servlet running on Tomcat 7 on Windows. One of the database interrogations handled by the servlet was a SQL Server 2005 database and we used a JNDI connection and had SSL certificated encryption. This all worked fine but recently we had to migrate the SQL Server database to a new server running SQL Server 2008 R2. After receiving the server details and port number etc I was able to make a successful connection through SQL Server Management Studio Express as well as setting up a datasource in the Eclipse IDE we use for development. However, I cannot get the JNDI connection to work. When I change the JNDI to use the relevant connection credentials the relevant Web Service request in SoapUI just hangs and times out. My initial investigation indicated upgrading the jdbc driver from sqljdbc1.2 to sqljdbc4 which I downloaded and follwoed all instructions but it still does not work. What am I doing wrong? Can anyone help? Here is the JNDI entry but with certain details such as password amended.

<Resource auth="Container" driverClassName="com.microsoft.sqlserver.jdbc.SQLS erverDriver" factory="org.moss.jdj.dbcp.EncryptedDataSourceFact ory" maxActive="100" maxIdle="30" maxWait="-1" name="jdbc/edrms" password="*******" type="javax.sql.DataSource" url="jdbc:sqlserver://edmssql\ngedm:2369;databaseName=********" username="********" />

Thanks in advance

ajfarroll

ajfarroll December 2nd, 2014 07:31 AM

Successful Connection
 
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/1...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.EncryptedDataSourceFact ory" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/edrms" password="password" type="javax.sql.DataSource"
url="jdbc:jtds:sqlserver://myservername:2369:\mySQLdatabaseinstance;databaseN ame=mydatabasename" username="username" />

Thanks to all who viewed

Ajfarroll


All times are GMT -4. The time now is 04:37 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.