Results 1 to 2 of 2
- 10-21-2012, 03:08 PM #1
MS SQL Express/JDBC
So, I downloaded and installed MS SQL Express and its JDBC. Everything compiles and runs sortof correctly... but it can't connect to the database. As far as I can tell, it should allow TCP/IP connections to be made to the database, but no luck at all. The error I get (roughly translated) is:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 failed. Error: "Connection refused: connect. Verify the connection properties. Make sure an instance of the SQL Server is running on the host and is accepting TCP/IP connections on the port and that any firewall allows traffic on the port."
Anyone familiar enough with MS SQL that can help me make sure the settings are okay? I can connect to the database through the tools distributed with the database, so I know that's up and running at least.
EDIT: Or if anyone can find a fault with the first three lines of code in my program:
Connection con=DriverManager.getConnection(url, "user", "pass");
(and no, they're not actually called "user" and "pass", but it doesn't even seem to get far enough to check those). I've tried specifying port 1433 as well (standard port and whatnot), but no luck.
Last edited by Toll; 10-21-2012 at 03:40 PM.
- 10-21-2012, 06:58 PM #2
Re: MS SQL Express/JDBC
Well, managed to solve it on my own... First, it actually needed an instance-name at the end of the URL (so it became jdbc:sqlserver://localhost\\SQLEXPRESS). It wasn't optional, as the documentation said it was. When that was added, I got another piece of text in the error message: "Make sure the service SQL Server Browser is running on the host computer"... which, of course, it wasn't. Activate that one, and it at least connected. Now to solve all the syntax errors in the SQL statements. Apparently MS SQL doesn't use the same syntax as MySQL does...
- By jiml in forum New To JavaReplies: 2Last Post: 07-10-2012, 02:49 PM
- By DJSKYLINE in forum JDBCReplies: 3Last Post: 07-14-2011, 10:11 AM
- By j3sr in forum New To JavaReplies: 2Last Post: 01-28-2010, 12:11 PM
- By pbaudru in forum JDBCReplies: 1Last Post: 01-19-2010, 10:59 AM
- By paul in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:08 AM