Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DSN on one terminal and JDBC connection on another terminal, how to connect?

 
Nitin Jawarkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I m using j2sdk1.4.0._03 for my I/O application, problem is system DSN is on one terminal(system) and JDBC code is on another terminal then how should i write code to connect to database(SQL Server) through JDBC.
current code is look like....

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("Jdbcdbc:employee");
System.out.println("Connection Successful.....");
st = con.createStatement();
}
catch(SQLException e)
{
System.out.println(e);
}
}

[edited to disable smilies]
[ December 22, 2004: Message edited by: Jeanne Boyarsky ]
 
Yu Tao
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use DataSource and lookup is OK!
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may be wrong, but I don't believe the JDBC-ODBC bridge is network capable. Even if it is, you should get a SQL SErver Type-4 driver and use that instead. Then you just add the machine name, port and dbName in the JDBC URL and everything is sweet.

As an additional pointer, I like to use the SquirrelSQL client to debug JDBC connection settings outside the application so I can just paste them into the application. It's much easier.

You can search Sun's Driver Database for the driver you need.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:
You can search Sun's Driver Database for the driver you need.


or go to this thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic