I followed some tutorials on the internet on java-access database and I tried the following code...
import java.sql.*;
public class Db_101 {
public Db_101(){
connect();
}
public static void main(String[] args) {
Db_101();
}
public void connect() {
Connection con;
Statement st;
ResultSet rs;
try{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver);
String db = "jdbc.odbc.Database_1";
con = DriverManager.getConnection(db);
st = con.createStatement();
String sql = "Select * from Table";
rs = st.executeQuery(sql);
while(rs.next()){
String fname = rs.getString("Firstname");
System.out.print(fname);
}
}catch(Exception ex){
System.out.print("Error occured when connecting...\n"+ex.getMessage());
}
}
}
But when I run it, it came up with an error.
I knew that I could not create the connection to the database.
Can anyone help me to figure this out?
How to get it done?
I tried doing ...
Microsoft Access Driver and settings and all the stuff, but it wasn't successful.
Because the drivers were not there. And I downloaded AccessDatabase Engine.exe and run it.But the result was nothing else.
How can I get the connection to the database???
The error message I received is "Nope. I cannot get the connection to the database that I have created using access...here is the error message .." Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: Db_101 at Db_101.main(Db_101.java:15) Java Result: 1 "
This post has been edited by vbabey: 27 August 2012 - 06:53 PM

New Topic/Question
Reply




MultiQuote



|