File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Error Establishing Socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error Establishing Socket" Watch "Error Establishing Socket" New topic
Author

Error Establishing Socket

Hope Zhu
Ranch Hand

Joined: May 11, 2004
Posts: 32
I have a stand alone app to connect to a remote SQL server db. It worked fine until I changed the database URL to "jdbc:microsoft:sqlserver://10.XXX.XXX.XX\\ENGINE:1433;DatabaseName=TEST". I keep getting "SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket" whenever I call DriverManager.getConnection. I don't know if it's because of "\\" in url. I am stuck here, can someone please help.
Thanks in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

"Hope",
We're pleased to have you here with us in the JDBC forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

The most obvious question is: can you ping the remote machine?
The second most obvious is: is there a database server running on that machine?
Hope Zhu
Ranch Hand

Joined: May 11, 2004
Posts: 32
Bear,
Thanks for reminding me to add my last name. But I can't change my first name. You may think "Hope" is obviously fictitious, but it has been my English name for more than 10 years.
Hope
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

"Hope" is absolutely fine, Hope. It was the lack of a last name that triggered the reminder.
thanks for complying!
bear
Hope Zhu
Ranch Hand

Joined: May 11, 2004
Posts: 32
David,
Thanks for your prompt reply. To your questions, my answer is:
Yes, I can ping the remote machine and I am 100% sure there is a SQL server database running on that machine. Actually I can connect to that database from my machine via Enterprise Manager if a server alias has been created for that server.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I'm not sure your database URL is correct. I don't use sqlserver very often, but from searching around it looks like the format should be more like:

I'm not sure what 'ENGINE' refers to, but try:

My guess is that ENGINE is the machine name, and you only need the IP or the name, not both.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

A handy way to debug JDBC URL problems without needing to recompile is to use a Java Database client like Squirrel SQL. You can put in your connection details to see if it works, ad just try again if it doesn't.
You can get Squirrel (for free) here
Hope Zhu
Ranch Hand

Joined: May 11, 2004
Posts: 32
Thanks a lot, David! You are correct, I was given a wrong server name.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error Establishing Socket