In my project, I should use both SQLiteDB and MariaDB.
So, I imported jdbc driver files(*.jar) in the eclipse project.
But I got an error like this:
Code:
try {
driver = (Driver) Class.forName("org.sqlite.JDBC").newInstance();
DriverManager.registerDriver(driver);
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
}
Error message:
Exception in thread "main" java.lang.IllegalArgumentException: Invalid connection URL url jdbc:sqlite:data.sqlite
at org.mariadb.jdbc.JDBCUrl.parse(JDBCUrl.java:144)
at org.mariadb.jdbc.Driver.connect(Driver.java:95)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at database.DBHelper.makeConnections(DBHelper.java:96)
at database.DBHelper.<init>(DBHelper.java:60)
at database.DBHelper.getSingleton(DBHelper.java:28)
I clearly registered the jdbc driver with the name "org.sqlite.JDBC". But I don't know why the log message contains "at org.mariadb.jdbc.Driver.connect(...)".
After the MariaDB jdbc file(*.jar) is removed, the program is successfully executed.
Aucun commentaire:
Enregistrer un commentaire