Click to See Complete Forum and Search --> : Urgent help to C++ programmer about JDBC


AlexTAI
May 3rd, 2000, 02:41 PM
I am using Java 1.1 (from Sun) on Windows98 platform. I have a problem that I cannot connect to a database through Jdbc:Odbc and I need it urgently (very).
Suppose I have a MS Access database called "FirstTry.MDB" stored for example in the path c:\My Documents\aaa\bbb.
So the full path is "c:\My Documents\aaa\bbb\FirstTry.MDB"
Is anybody able to write a piece of Java code (Java 1.1) that will connect me to it.
I will thank for any help.
Thank you.

There is no need to markup

May 8th, 2000, 07:28 AM
As far as I know, you first have to regiser your ODBC-source. Do this by selecting "ODBC data sources" in the system settings window, clicking the "System DSN" tab and specifying "Acess driver", your path and a name for the data source(eg. "FirstTry"). Then, in your Applet, the following lines of code should establish a connection:

import java.sql.*;
void init() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:FirstTry", "", "");
} catch(Exception e) {
//display error message
}