Reputation: 23
I downloaded and installed the uCanAccess jars by following instructions from here: Manipulating an Access database from Java without ODBC I'm learning how to use the microsoft access db for java and this is the coding I used
package Main.Net;
import java.sql.*;
public class DataBase {
Connection con;
Statement st;
ResultSet rs;
public DataBase() {
}
private void connect() {
try {
//String driver = "sun.jdbc.odbc.jdbcodbcdriver";
//Class.forName(driver);
String db = "jdbc:ucanaccess://C:/Users/MyUser/workspace/Connectors_DB.accdb";
con = DriverManager.getConnection(db);
st = con.createStatement();
String sql = "select * from Table";
rs = st.executeQuery(sql);
while(rs.next()) {
String username = rs.getString("Username");
String password = rs.getString("Password");
System.out.println(username + "\t" + password);
}
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new DataBase().connect();
}
}
and when I run the java program, it comes with this error
Exception in thread "main" java.lang.NoSuchMethodError: org.hsqldb.DatabaseURL.parseURL(Ljava/lang/String;ZZ)Lorg/hsqldb/persist/HsqlProperties;
at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at net.ucanaccess.jdbc.DBReference.getHSQLDBConnection(DBReference.java:354)
at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:206)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Main.Net.DataBase.connect(DataBase.java:23)
at Main.Net.DataBase.main(DataBase.java:42)
error is at this code:
String db = "jdbc:ucanaccess://C:/Users/MyUser/workspace/Connectors_DB.accdb";
con = DriverManager.getConnection(db);
does it have something to do with the version of the hsqldb? because if it does I already tried downloading other versions of hsqldb and the same error appears
here are the jars I'm using:
ucanaccess-2.0.9.3.jar
commons-lang-2.6.jar
commons-logging-1.1.1.jar
hsqldb.jar
jackcess-2.0.8.jar
so... how can I fix this?
Upvotes: 2
Views: 2554
Reputation: 1328
The answers in this thread suggest, that there are multiple hsqldb-versions on your classpath. Maybe one of the other involved jars contains hsqldb as well? You can inspect them using a zip tool of your choice, or the command jar -tf foo.jar
.
Upvotes: 3