This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to sql server

 
Sameera Abeysinghe
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

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


class A{
public void conn(){


try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
JOptionPane.showMessageDialog(null,"Driver Ok");
Connection conn =

DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;user=user;password=pass");
JOptionPane.showMessageDialog(null,"SQL Ok");
Statement stmt=conn.createStatement( );
JOptionPane.showMessageDialog(null,"Connect Ok");
}
catch(Exception e){
JOptionPane.showMessageDialog(null,"Error");
System.out.println(e);
}




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

////////////////////////////////////

after runing

/////////////////////////////
C:\test>javac A.java

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

C:\test>
/////////////////////////////
Can any one give a an solution to this error

Thank You
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sameera,
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic