The Artima Developer Community
Sponsored Link

Java Answers Forum
Connect from Java Application to Access DB

1 reply on 1 page. Most recent reply: Feb 12, 2004 4:38 AM by Joe Parks

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
dyry byry

Posts: 1
Nickname: dari
Registered: Feb, 2004

Connect from Java Application to Access DB Posted: Feb 11, 2004 7:10 AM
Reply to this message Reply
Advertisement
Could anybody say how I can make a connection to an Access DB?
I use the following code in JBuilder X Foundation:

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver";
);

}
catch(ClassNotFoundException e){
System.out.println(e.getMessage());
}
try{

conDB = DriverManager.getConnection("jdbc:odbc://c:/mydir/myDB.db);
// d = DriverManager.getDriver("jdbc:odbc:c:/tplbest/tplbest_2000.db");
}
catch(SQLException e){
System.out.println(e.getMessage());
}
At the compilation : "FATAL exception occured"
[Microsoft][ODBC-]"The name of the datasource is not found and there is no standard "


Joe Parks

Posts: 107
Nickname: joeparks
Registered: Aug, 2003

Re: Connect from Java Application to Access DB Posted: Feb 12, 2004 4:38 AM
Reply to this message Reply
The connection url has to include the name of a registered ODBC datasource. (Control Panel->Administrative Tools->Data Sources)
// 'MyDB' was registered to point to c:\mydir\MyDB.db
String url = "jdbc:odbc:MyDB";
connDB = DriverManager.getConnection(url);

Flat View: This topic has 1 reply on 1 page
Topic: Search File Previous Topic   Next Topic Topic: please help! Why not compiling

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use