This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes Connect to db, simple question !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connect to db, simple question !! " Watch "Connect to db, simple question !! " New topic
Author

Connect to db, simple question !!

Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
I must connect to a remote Sql Server DB througth java !
I have these data:

IP Server: 192.168.3.6
Server Name: TEST
DB Name: db_test
Login: sa
Password: sa

Is it this ip address correct ?
I think this is a local address

With this code



I have error "java.sql.SQLException: Network error IOException: Connection refused: connect"

Telnet 192.168.3.6 1433 give an error !!!
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2497
    
    8

Can you check if the tcpip protocol is enabled on that MSSQL server?


OCUP UML fundamental and ITIL foundation
youtube channel
Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
I resolved my problem, correct connection url is



Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
New problem

Server admin change sql server authentication mode from sql to windows mode !
Web server and sql server are on different machines in same local network but not in domain !

How can I change my connection string to use windows authentication ?

I found this on jtds documentation but my sql server isn't on a domain !!!


domain
Specifies the Windows domain to authenticate in. If present and the user name and password are provided, jTDS uses Windows (NTLM) authentication instead of the usual SQL Server authentication (i.e. the user and password provided are the domain user and password). This allows non-Windows clients to log in to servers which are only configured to accept Windoes authentication.
If the domain parameter is present but no user name and password are provided, jTDS uses its native Single-Sign-On library and logs in with the logged Windows user's credentials (for this to work one would obviously need to be on Windows, logged into a domain, and also have the SSO library installed -- consult README.SSO in the distribution on how to do this).

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You can connect to it via SQL Server's management console using windows integrated authentication? What domain is the user you do that in?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
Paul Sturrock wrote:
You can connect to it via SQL Server's management console using windows integrated authentication? What domain is the user you do that in?


I can't understand your questions

I can't connect to sql server with Sql Server Management Studio !
Web server (my machine) and Sql Server are on the same local network 192.168.3
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You can't connect at all? Speak to your database administrator. If you need access to work she/he should be able to give it to you.
Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
I can access to sql server only with remote connection + sql server management studio (on sql server) !
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

OK. Who do you connect as? What domain is that user in?
Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
Mmm
From remote desktop access (windows xp)

computer : 192.168.3.6
username : username
password : password
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Ah, you RDP to the server and connect as admin? Speak to your SQL Server administrator. No point trying to guess what valid credentials could be when there is someone who could just tell you.
Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
Paul Sturrock wrote:
Ah, you RDP to the server and connect as admin?


Yes

Paul Sturrock wrote:
Speak to your SQL Server administrator. No point trying to guess what valid credentials could be when there is someone who could just tell you.


Server admin give me only

1) sql server url
2) db name
3) instance name
4) username
5) password

He said me that sql server is not on a domain !!
What can I ask him to solve my problem ?

Thank you very much for your help
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Connect to db, simple question !!