DSN on one terminal and JDBC connection on another terminal, how to connect?
Nitin Jawarkar
Ranch Hand
Joined: Dec 18, 2004
Posts: 79
posted
0
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 ]
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.