1 Replies - 1244 Views - Last Post: 27 August 2012 - 07:21 PM Rate Topic: -----

#1 vbabey  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 30-July 12

Access Database in Java

Posted 27 August 2012 - 06:48 PM

I want to create an access database to maintain a database application in java.
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(){
    public static void main(String[] args) {

    public void connect() {
        Connection con;
        Statement st;
        ResultSet rs;
            String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
            String db = "jdbc.odbc.Database_1";
            con = DriverManager.getConnection(db);
            st = con.createStatement();
            String sql = "Select * from Table";
            rs = st.executeQuery(sql);
            String fname = rs.getString("Firstname");
        }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

Is This A Good Question/Topic? 0
  • +

Replies To: Access Database in Java

#2 ILoveJava  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 389
  • Joined: 12-March 12

Re: Access Database in Java

Posted 27 August 2012 - 07:21 PM

What's your problem? You need to be a bit more clear on what's wrong?

Also I will personally suggest using this tutorial, and using a MySQL database rather than access.

This post has been edited by ILoveJava: 27 August 2012 - 07:23 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1