I'm a beginner with java. Today I've tried to make an application to editing mdb databases. I decided to use Jackcess but I always have some errors. I'm a beginner so I use text editor to write a code and then I use javac from cmd (it's not the most effective solution but it allows you to better understand the whole idea about java). My problem is that I can't make any application which will be compilable and work correctly.
Example_1: Create an Access database file (.mdb or .accdb) using Java in this link Sarath Kumar Sivan tells that you need to install Jackcess, commons-logging, commons-lang jars, and try the code. I downloaded these jars. Then I moved them to this directory:
C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext
After it I tried to compile the code but I got this error:
JackcessLibrary.java:20: error: cannot find symbol
return Database.create(new File(databaseName));
^
symbol: method create(File)
location: interface Database
1 error
I have no idea what it does mean.
Example_2: on the official page of Jackcess you can read that you can start with simple command:
Database db = DatabaseBuilder.open(new File("mydb.mdb"));
so I wrote this:
import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.*;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.TableBuilder;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Types;
class Jackcess2 {
public static void main (String[] args) {
Database db = DatabaseBuilder.open(new File("mydb.mdb"));
}
}
which gave me this error:
Jackcess2.java:21: error: unreported exception IOException; must be caught or declared to be thrown
Database db = DatabaseBuilder.open(new File("mydb.mdb"));
^
1 error
so I edited it to this:
import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.*;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.TableBuilder;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Types;
class Jackcess2 {
public static void main (String[] args) {
try {
Database db = DatabaseBuilder.open(new File("Uruchom.odb"));
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Done.");
}
}
and now I can compile it but after run it I have this message:
Error: Could not find or load main class Jackcess2.java
I suppose that I need to include Jackcess class but I have no idea how to do it. I've never seen anything like that before.
I've tried other various ways to use Jackcess but nothing work properly. Can you explain me how to use Jackcess and what I've missed?