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

ODBC Connection - Please Help

 
sunilkumar ssuparasmul
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to make a connection to ODBC
TEST 1:-
Instead of creating a system dsn like "TestDSN" below
String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbServer = "jdbc dbc:TestDSN";
String dbLogin = "";
String dbPassword = "";
Class.forName(dbDriver);
return DriverManager.getConnection(dbServer, dbLogin, dbPassword);


TEST 2":-
Is it possible to directly specify the mdb file instaead of creating dsn
and connecting as below

String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbServer = "jdbc dbc:MYDB.mdb";
String dbLogin = "";
String dbPassword = "";
Class.forName(dbDriver);
return DriverManager.getConnection(dbServer, dbLogin, dbPassword);


TEST1 Works where as TEST 2 Do not Please Help and clarify
Or is it possible ot exstablish a connection without creating dsn.

Thanks in advance
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AFAIK, there is no direct Jet driver for Java. You second test did not work because it is still using the ODBC drivers to try and connect directly to the file.
 
sunilkumar ssuparasmul
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But how do i directly connect without using odbc-jdbc bridge
I would appreciate if there are nay pointers of if someone can send me the
code snippet.
Thanks in advance
Sunil
 
G Raghavan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Sunil,
As for my knowledge, if you are connecting to a access database the only way is to use the jdbc odbc bridge like the 1st one you have created.
regards,
Raghavan
 
Samuel C. Michaelis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sunil,
the very principle of ODBC is the access to a datasource by a DSN, so you can't acceed the mdb-file directly via the JDBC-ODBC-Bridge.
I never heard of a JDBC-driver for MS Access yet. I think it wouldn't change a lot, because when accessing MS Access your local JET engine has to do all database related computation, so some little overhead created by the JDBC-ODBC-bridge won't kill the rat (or whatever
Greetings,
Samuel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic