Re: jdbc connection
- From: Joe Weinstein <joeNOSPAM@xxxxxxx>
- Date: Sun, 26 Feb 2006 07:48:59 -0800
lukhenry@xxxxxxxxx wrote:
Hi,
I am a beginner on JDBC with SQL Server 2005. I tried to write a
simple program to connect to the SQL Server 2005 that I installed on my
machine (localhost). Here is the program:
import java.sql.*;
public class JdbcTest {
public static void main(String[] args) {
try {
DriverManager.registerDriver(new
com.microsoft.sqlserver.jdbc.SQLServerDriver());
Connection connection =
DriverManager.getConnection("jdbc:sqlserver://localhost:1433",
"myusername", "mypasswd");
if (null == connection)
{
System.out.println("Connection is null...");
}
} catch(SQLException se) {
System.out.println("ERROR: " + se.getMessage());
}
}
}
However, I got the following error:
ERROR: The TCP/IP connection to the host has failed.
java.net.ConnectException: Connection refused: connect
Hi. Your program is fine. You just need to check the setup
of your DBMS, to seeif it is configured to accept connections
in 'mixed mode', ie: allowing the simple TCP socket connections
the driver makes.
HTH,
Joe Weinstein at BEA Systems
Should I use localhost as the server name in this case? Since my SQL
server is installed on my local machine. Also, what is an instance
name? How can I find out the instance name?
.
- Follow-Ups:
- Re: jdbc connection
- From: coollll...
- Re: jdbc connection
- References:
- jdbc connection
- From: lukhenry
- jdbc connection
- Prev by Date: jdbc connection
- Next by Date: Re: jdbc connection
- Previous by thread: jdbc connection
- Next by thread: Re: jdbc connection
- Index(es):
Relevant Pages
|
Loading