Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble connecting tomcat to MSSQL 2008 R2
    text
    copied!<p>I am trying to connect my tomcat servers to a MS SQL 2008 R2 server. Network connectivity is not the issue here.</p> <p>I can successfully connect in a simple java app, but when I try to connect via tomcat7 (tried on my Windows 7 workstation as well as my Ubuntu 12.04 server.</p> <p>I am able to run the example servlets on both tomcat servers.</p> <p>My code:</p> <pre><code> public class DBConnector{` private java.sql.Connection con = null;` private final String url = "jdbc:sqlserver://my.domain.com:";` </code></pre> <p>//PORT NUMBER, CREDENTIALS, ETC. These all work in standard java app.</p> <pre><code>public DBConnector(){} private String getConnectionUrl(){ return url+ portNumber +";databaseName="+databaseName+";selectMethod="+selectMethod+";"; } private java.sql.Connection getConnection(){ try{ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password); if(con!=null) System.out.println(getConnectionUrl()); }catch(Exception e){ e.printStackTrace(); System.out.println("Error Trace in getConnection() : " + e.getMessage()); } return con; } public void queryDB(){ try{ System.out.println("Connecting..."); con= this.getConnection(); if(con!=null){ System.out.println("NotNull"); java.sql.Statement statement = con.createStatement(); String query="Select * from CAFE"; java.sql.ResultSet rs = null; System.out.println("made rs"); rs = statement.executeQuery(query); System.out.println("Established what it is"); java.sql.ResultSetMetaData rsmd = rs.getMetaData(); System.out.println("Getting MetaData");` //Omitted the rest. </code></pre> <p>It stops responding in tomcat at: rs = statement.executeQuery(query); because on the console, I never see "Established what it is".</p> <p>I am using the correct mssql driver version for Java 6.</p> <p>I am very new to this so quite likely made an obvious mistake here. Any suggestions?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload