Link to home
Create AccountLog in
Avatar of mte01
mte01Flag for Lebanon

asked on

In DB Connection: Error establishing socket

Hey experts,

conn = DriverManager.getConnection(dbURL,user,pwd);

where

static final String dbURL =
    "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=DBServer";
  static final String user = "sa";
  static final String pwd = "sa";

I am getting: "Error establishing socket"......any help??
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Make sure the server is running on that port on the local machine
Avatar of mte01

ASKER

I couldn't find the place where I could verify in Microsoft SQL Server that it is running on port 1433.......but this is what is supposed to be doing, I have just installed it with the default settings.
Are you sure that that is the correct URL for the database?
>>I couldn't find the place where I could verify in Microsoft SQL Server

netstat -a | find "1433"

No output means it's not running
Avatar of mte01

ASKER

Yes....this is the correct URL of the DB (it's name is DBServer, the port is 1433 , and these are the username & pwd & and everything else is from the driver........)
And the output of the command was..?
Avatar of mte01

ASKER

It's not running on port 1433...what do I do now? (I can't find where the service is from the whole netstat list)
As i said, if that command returns  no output then it's not running (at least not on that port)
ASKER CERTIFIED SOLUTION
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
>>what do I do now?

Start it ;-)
Avatar of mte01

ASKER

OK....so do I post a new question in the networking TA, so I can see how I can run it on port 1433??
>>You could also try telnetting to the server on that port ...

No need if the command i gave earlier has been used
>>OK....so do I post a new question in the networking TA, so I can see how I can run it on port 1433??

You just start the server !
Avatar of mte01

ASKER

It is up & running (I can see it from its GUI interface)
Avatar of mte01

ASKER

But it doesn't appear in the telnet list..........weird!!
Find out what port it's set to run on through the gui
Avatar of mte01

ASKER

I just checked it on the GUI...it's 1433.........but it doesn't appear on the netstat list.............
You used the command exactly as i mentioned?
Avatar of mte01

ASKER

Yes CEHJ...........it didn't return anything.........& I also checked the whole list.................does it affect if I am uisng Win XP Home Edition??
Is TCP/IP running?
Avatar of mte01

ASKER

Yes sure...
XP has a firewall but i didn't think it worked outbound. However, in general, make sure you have no firewall preventing a connection
>>make sure you have no firewall preventing a connection

... and also the creation of a socket on that port
Avatar of mte01

ASKER

Yes, I made sure of that.........
Avatar of mte01

ASKER

>> ... and also the creation of a socket on that port

How could I check for that??
Avatar of mte01

ASKER

& this is SP2 by the way...
>>How could I check for that??

The crude way would be to stop any running firewalls
Avatar of mte01

ASKER

Yes, I did that....by the way if I want to change the port what do you suggest??
I think you can do it using the SQL Server Network Utility
Avatar of mte01

ASKER

I know, but what port would you suggest that we would use??
Well i'm not sure if it's going to solve your underlying problem but you could change it to another one that's not already being used
Avatar of mte01

ASKER

We just tried it........same problem

and  bloodredsun

I have tried all the methods mentioned in the forum link that you gave with no avail...........
You're not running it in a limited account are you?

1. Check the system logs for errors
2. If all fails, reinstall it
Avatar of mte01

ASKER

I just re-installed it....same problem...........
Open the SQL Server Network Utility and check that TCP/IP is enabled and that it is listening on the correct port.
What about the first two points of my last comment?
Avatar of mte01

ASKER

>>objects

I checked EVERYTHING objects


>>CEHJ

I chekced both of your two comments...
So what protocols are enabled?
And what port is it listening on?
mte01,

  I ever got a problem that seems to be like your case. If I enabled both Named Pipes and TCP/IP and let TCP/IP on top of the list .. I could start SQL service but nothing running on port 1433 (as I configured). If I enabled only TCP/IP on port 1433 .. I couldn't start the service and an error shown in event viewer .. the error was

Event Type:      Error
Event Source:      MSSQLServer
Event Category:      (8)
Event ID:      19011
Date:            18/1/2548
Time:            9:48:48
User:            N/A
Computer:      gnoon
Description:
SuperSocket info: gethostbyname(MSAFD Tcpip [TCP/IP]) : Error 11001.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

I thought the error telling me that SQL Server couldn't get IP Address of database server by computer name.
It's true! I couldn't ping my computer by computer name. My solution is I open file C:\WINDOWS\system32\drivers\etc\hosts and then put a mapping of computer IP and name there, then started the service again.
Of couse, it worked like a charm ... I could start the service with TCP/IP on port 1433. Then, my java app could connect to the service. Happy ending :-)

Hope my long story help you.
G noon


>>and an error shown in event viewer

I suggested you do that earlier mte01 - did you?
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
> I suggested you do that earlier mte01 - did you?

mte1> I chekced both of your two comments...
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of mte01

ASKER

Hello again guys,

Right now I don't have the computer where the problem is with me,.

>>gnoon
Although I checked the system log for SQL Server, there was no problem, but I'll do the steps that you followed (later), and I'll see what happens.
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of mte01

ASKER

The TCP/IP protocol is enabled (in addition to other protocols that I have forgotten), and it's listening on port 1433.............
What happens when you take the DatabaseName out of the connection String?
Avatar of mte01

ASKER

I haven't tried it, and I can't try it now because the PC with the problem is not with me..........but I tried another DB, and the problem was the same............I'll be trying it if you want later..........
OK
:-)

OK now?
Avatar of mte01

ASKER

Well actually, my friend who had the problem on his pc (which we were working on it) decided that we would work with sql server on another pc, so he removed sql server from his pc