Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By Toll

Thread: MS SQL Express/JDBC

  1. #1
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default 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:

    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
    String url="jdbc:sqlserver://localhost";
    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 04:40 PM.

  2. #2
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default 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...
    Fubarable likes this.

Similar Threads

  1. express string?
    By jiml in forum New To Java
    Replies: 2
    Last Post: 07-10-2012, 03:49 PM
  2. sql server express + tomcat 7 + jtds driver
    By DJSKYLINE in forum JDBC
    Replies: 3
    Last Post: 07-14-2011, 11:11 AM
  3. Express 240 as'Two hundred and forty'
    By j3sr in forum New To Java
    Replies: 2
    Last Post: 01-28-2010, 12:11 PM
  4. SQL server express edition connection
    By pbaudru in forum JDBC
    Replies: 1
    Last Post: 01-19-2010, 10:59 AM
  5. how to properly express adding...
    By paul in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •