Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 8th, 2006, 06:11 PM
Authorized User
 
Join Date: Mar 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connection Problem with Java JDBC

The SQL server was installed in the PC and the JDBC driver jar file was installed also. But when I try to connect to the database, an error is encountered. The error message:
"com.microsoft.sqlserver.jdbc.SQLServerExcepti on: The TCP/IP connection to the host failed".

The 2 basic line of codes:
class.forname("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
Connection con = DriverManager.getConnection( "jdbc:sqlserver://localhost;user=username;passwrod=password);
(as suggested by Microsoft docmention named 'Using the JDBC Driver". Please know also the database name added to the Connection statement still does not make any different neither the port 1433.) Also the things suggested in the Microsoft document had been tried but still failed.

I am able to ping localhost (or ping 127.0.0.1) and TCP/IP is enable within the server, etc. Even setup exception port 1433 on firewall! Just don't know what else I can check or something I forget to setup?

An interesting item is when I use ODBC (configurated as ODBC) with the same Server/datbase, etc., it works perfectly. The other condition is the PC is running XP Pro and eveything is in the same computer.

Please help and thanks in advance for your help.

Best,
Don't Know Much



 
Old March 27th, 2006, 10:21 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 146
Thanks: 0
Thanked 1 Time in 1 Post
Default

Connection con = DriverManager.getConnection( "jdbc:sqlserver://localhost;user=username;passwrod=password);

If this is indeed your connection string it may have faile because you misspelled the password parameter. Instead you typed in "passwrod". Try "password=" instead of "passwrod ="



David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com
 
Old April 3rd, 2006, 02:44 PM
Authorized User
 
Join Date: Mar 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

From dontknowmuch to David Lundell, thanks for the reply. I check my code and it is password (not passwrod in the posting). Thanks very much once again.

 
Old April 4th, 2006, 01:51 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 146
Thanks: 0
Thanked 1 Time in 1 Post
Default

No problem.

David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
JDBC connection problem in RAD6 dshashi1234 BOOK: Professional Crystal Reports for VS.NET 0 December 21st, 2006 02:28 AM
JDBC connection from ASP page aspskk Classic ASP Databases 0 October 18th, 2005 01:52 PM
how do you configure jdbc connection saf01 Crystal Reports 0 September 12th, 2005 07:24 AM
Connection to Oracle via JDBC swaminathanb Java Databases 3 August 9th, 2005 06:37 AM
connection to oracle thru jdbc venkitaraman Java Databases 5 April 6th, 2005 06:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.