Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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("Jdbc:odbc: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 ]
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use DataSource and lookup is OK!
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
See where your hand is? Not there. It's next to this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic