• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Connect to MS SQl Server

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to connect to SQL server Express DB installed on localbox from my java program. I am using jtds driver and the sample code is below.




When I try to run the program, I get an error saying "java.sql.SQLException: Network error IOException: Connection refused: connect"

If I use



I get an error "java.sql.SQLException: Server localhost has no instance named SQLEXPRESS."

I have the driver jar in class path and my VM args are "-Djava.library.path=C:\jtds-1.2.5-dist\x64\SSO" pointing to the NTLM dll.
I am able to connect to the DB from the MS SQL Server Management Studio.

Can somebody help me to solve this?






 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help on this?
 
Sheriff
Posts: 28413
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first message invariably means that you don't have a server listening at the specified port. So do you have your database server running on the same computer where your application is running? (That's what "localhost" means.) And is it listening at port 1433? I'm not sure about the Express version, but by default SQL Server is configured to not listen for TCP/IP connections. It expects to be contacted by some proprietary Windows method which isn't supported in Java. So check that configuration and turn on the TCP/IP option if it's not already on.
 
reply
    Bookmark Topic Watch Topic
  • New Topic