Scusami LeleFt
Non avevo letto con attenzione il suggerimento di AndiBin relativo alla rimozione di "JDBC-ODBC".
Ho scaricato quindi ucanaccess-4.0.4
Utilizzo Eclipse come IDE.
probabilmente ho sbagliato a inserire i moduli di ucanaccess-4.0.4
Li ho inseriti in Programmi/jdk-10.0.2/bin
perchè non funziona ancora.
il codice aggiornato è:
import java.sql.*;
public class ConnDb {
public static void main(String[] args) throws Exception {
Connection conn = null;
Statement s = null;
ResultSet rs = null;
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
}
catch(ClassNotFoundException ex) {
System.out.println("Problem in loading MS Access JDBC driver");
ex.printStackTrace();
System.out.println(ex.getMessage());
}
try
{
String msAccDB = "C:\\Archivi\\Sif.accdb";
String database = "jdbc:ucanaccess://" + msAccDB;
conn = DriverManager.getConnection(database);
System.out.println("Eseguita correttamente la connessione");
s = conn.createStatement();
// Fetch table
String selTable = "SELECT * FROM Anadip";
s.execute(selTable);
rs = s.getResultSet();
while((rs!=null) && (rs.next()))
{
System.out.println(rs.getString(1) + " : " + rs.getString(2));
}
s.close();
conn.close();
}
catch(Exception ex)
{
ex.printStackTrace();
System.out.println(ex.getMessage());
}
finally {
// Step 3: Closing database connection
try {
if(null != conn) {
// cleanup resources, once after processing
rs.close();
s.close();
// and then finally close connection
conn.close();
}
}
catch (SQLException sqlex) {
sqlex.printStackTrace();
}
}
}
}
errore:
java.lang.ClassNotFoundException: net.ucanaccess.jdbc.UcanaccessDriver
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
at InternetDbConn.main(InternetDbConn.java:92)
java.sql.SQLException: No suitable driver found for jdbc:ucanaccess://C:\Archivi\Sif.accdb
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at InternetDbConn.main(InternetDbConn.java:107)
Problem in loading MS Access JDBC driver
net.ucanaccess.jdbc.UcanaccessDriver
No suitable driver found for jdbc:ucanaccess://C:\Archivi\Sif.accdb
hO DIMENTICATO QUALCHE iMPORT ?
grazie
Moreno