I am trying to write a really simple graphical application for inserting some records into a database and reading some records (nothing unusual, just 1 table with 3 rows, no relationship). A source...
package EntryProg; import java.sql.*; import com.microsoft.sqlserver.jdbc.*; public class CourseDataEntryHandler { private Connection connect; private CallableStatement callState; private ResultSet rSet; private SQLServerDataSource dSource; public CourseDataEntryHandler() { rSet = null; callState = null; dSource = new SQLServerDataSource(); dSource.setUser(REDACTED); dSource.setPassword(REDACTED); dSource.setServerName(REDACTED); dSource.setPortNumber(REDACTED); dSource.setDatabaseName(REDACTED); dSource.setEncrypt(true); dSource.setTrustServerCertificate(true); try {
Error here
connect = dSource.getConnection();
mistake of the end
} catch (SQLServerException e) { //TODO Figure out how to handle -- logging for now, console do { System.out.println(e.getErrorCode()); System.out.println(e.getMessage()); System.out.println(e.getSQLState()); e = (SQLServerException) e.getNextException(); } while (e != null); System.out.println("END"); System.out.println(); } }
I get the following error ...
(code) 0
(message) SQL Server did not respond. The connection was closed.
(condition) 08S01
I verified that the username, password, server name, port and database name are accurate. If I change the username to invalid, I get the error "failed to log in", so I know that Iโm pushing the server.
I was not able to fully connect once, so I know that this is not a โtoo many connectionsโ problem, since the only person who is currently registered on the server is me through sql management studio. It does not work when I exit this, so there is definitely no problem with the connections.
The application user also has datareader / datawriter permissions. (I use Eclipse if that matters. And reference the sqljdbc4.jar library).
I donโt understand where to go to fix this problem. Any help would be greatly appreciated.
EDIT Update. I also tried the connection string and used DriverManager.getConnection (connString) to establish a connection that also does not work. The result is the same. In addition, SQL Server 2008 r2 is the version of SQL Server that I use.
EDIT I โโwrote a quick C # program to test the connection, I am sure that the connection works fine in .net, unfortunately, I have to use java for this project (this is a project that I chose for myself for the class, only this requirement in Java ... the teacher does not know what is happening).