Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JDBC Connection to MS SQL Server Express

807605Oct 6 2006 — edited Sep 4 2007
Hi all,
I've spent 7 hours straight trying to connect to my local MS SQL Server Express through JDBC, and didnt get it

here's my code
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			
			SQLServerDataSource ds = new SQLServerDataSource();
			ds.setUser("sa");
			ds.setPassword("ph4r400h");
			ds.setServerName("localhost");
			ds.setDatabaseName("PDV");
			ds.setPortNumber(1433);
			ds.setServerName("ANDRE-9580A17BA\\SQLEXPRESS");
			ds.setIntegratedSecurity(true);
			
			Connection con = ds.getConnection();
I tried to switch these settings.. but nothing changed.. I made some server configurations tough but still didnt work.

I did imported correctly the JDBC driver.

The error message sometimes is "The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect", but if I comment the ds.setPort method the error turns to "The connection to the named instance has failed. Error: java.net.SocketTimeoutException: Receive timed out."

If you know some good tutorial about this kind of connection, please send to me...

Any help is welcome!

thanks so much
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 2 2007
Added on Oct 6 2006
2 comments
394 views