Re: jdbc connection





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?


.



Relevant Pages

  • Re: Error "SQL Server does not allow remote connections"
    ... The application could not connect to the sql server db. ... network is blocking the connection. ... SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 ... integratedSecurity, SqlConnection owningObject) +737554 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: easy sql connection
    ... On my local machine. ... privilages to access an instance of Northwind. ... > Do you have a named instance of SQL Server or default instance? ... >> Connection failed to open. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Connection from remote computer to network SQL Server
    ... There is no firewall on the W2K machine acting as the SQL server. ... I tried making the SQL machine a "trusted" on the router. ... connection works. ... To find the IP address of your computer inside the network, ...
    (microsoft.public.access.adp.sqlserver)
  • ADO.net Orcas Samples Install Problem
    ... An error has occurred while establishing a connection to the server. ... When connecting to SQL Server 2005, this failure may be caused by the ... SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, ... or am I better off with a full SQL Server install. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: OpenDataSource SQL Server xpress problem
    ... I tried your suggestions with some success. ... I tried setting up the .odc file through the Word Mail Merge wizard as ... If I work through the dialog to connect and then click the 'Test Connection' ... but I suspect it's because until recently most SQL Server ...
    (microsoft.public.word.mailmerge.fields)

Loading