This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting with SQL 2000

 
Devavrat Bagayat
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to connect to SQL 2000 database, I tried it with -
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc dbc:A");
Statement stmt=conn1.createStatement();
but its not working.
Does anyone have the code to connect java to SQL 2000, the might be 4-5 line code ?
 
Patrick Mugabe
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con;
//establish the connection with the data source
String url = "jdbc dbc:MyDataSource";
con = DriverManager.getConnection(url, "loginName" ,"password");
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>> String url = "jdbc dbc:MyDataSource";

How to code "MyDataSource"?

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic