Search code examples
sql-serverservletstomcat7jndiwindows-server-2008-r2

Why won't one JNDI connection to SQL server work


My project is a Java servlet with serveral database connections, one of which connects to a SQL server database. Recently the SQL Server database was migrated and upgraded from SQL Server 2005 to SQL Server 2008 R2 and onto a server running Windows Server 2008R2. I created a successful JNDI connection using SSL encryption from my development PC once I upgraded the driver to sqljdbc4.jar and similarly successfully on the test server However the Live server (Windows 2008 Server R2) just states "could not open connection" in the tomcat logs no matter what I try. We are using Tomcat 7 as the servlet container. The Live server is outside our company network, however the connection worked before we migrated the database. I am obviously missing a network or server configuration here but I cannot find what it is. Can anyone think of what the problem is please? What am I missing here?


Solution

  • I changed the server name in the JNDI entry to the IP address and this communicated a successful response. However, this exposed an IP address on the Live server so investigated why this change would work and the solution was to add an entry for the application server into the known hosts on the database server.