+ 1

what is the error of access db in this java code?

package accessdb1; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class AccessDB1 { public static void main(String[] args) { // variables Connection connection = null; Statement statement = null; ResultSet resultSet = null; // Step 1: Loading or registering Oracle JDBC driver class try { Class.forName("net.ucanaccess.jdbc.UcanaccessDriver"); } catch (ClassNotFoundException cnfex) { System.out.println("Problem in loading or " + "registering MS Access JDBC driver"); cnfex.printStackTrace(); } // Step 2: Opening database connection try { String msAccDB = "D:/Player.accdb"; String dbURL = "jdbc:ucanaccess://" + msAccDB; // Step 2.A: Create and get connection using DriverManager class connection = DriverManager.getConnection(dbURL); //Step 2.B: Creating JDBC Statement try { Statement stmt = connection.createStatement(); //String data = "INSERT INTO Player VALUES(4,'hasan',18,90)"; String insert = "INSERT INTO Player (Player_ID, Name, Age, Matches)" +"VALUES (4, 'mary', '18', '5')"; //PreparedStatement st = connection.prepareStatement(q); stmt.executeUpdate(insert); } catch (SQLException e) { System.out.println(e.getMessage()); System.exit(0); } // Step 2.C: Executing SQL & retrieve data into ResultSet resultSet = statement.executeQuery("SELECT * FROM PLAYER"); System.out.println("ID\tName\tAge\tMatches"); System.out.println("==\t=====\t===\t==="); // processing returned data a

29th May 2017, 12:12 PM
hamid
hamid - avatar
2 Respuestas
+ 1
I solved: use new version of ucanaccess, commons-lang-2.6, commons-logging-1.1.3, hsqldb-2.3.1, jackcess-2.1.7
29th May 2017, 7:38 PM
hamid
hamid - avatar
0
the error: UCAExc:::4.0.2 java.lang.NoSuchMethodError: com.healthmarketscience.jackcess.Table.isAllowAutoNumberInsert()Z java.lang.NoSuchMethodError: com.healthmarketscience.jackcess.Table.isAllowAutoNumberInsert()Z
29th May 2017, 12:18 PM
hamid
hamid - avatar