This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Connecting to sql server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Connecting to sql server" Watch "Connecting to sql server" New topic

Connecting to sql server

Sameera Abeysinghe
Ranch Hand

Joined: Nov 15, 2004
Posts: 104
Hi all,

This is my application
import java.sql.*;
import javax.swing.*;

class A{
public void conn(){

JOptionPane.showMessageDialog(null,"Driver Ok");
Connection conn =

JOptionPane.showMessageDialog(null,"SQL Ok");
Statement stmt=conn.createStatement( );
JOptionPane.showMessageDialog(null,"Connect Ok");
catch(Exception e){

public static void main(String [] args){
A a=new A();


after runing


C:\test>java A
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establis
hing socket.

Can any one give a an solution to this error

Thank You
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32481

It looks like the program can't connect to the database. Check the port is correct and that you can connect to the database using the command line.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Have you checked out Aspose?
subject: Connecting to sql server
It's not a secret anymore!