i have a problem creating a new database file with ucanaccess.
Here is my code:
if (db.equals("ms-access")) {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
cn = DriverManager.getConnection("jdbc:ucanaccess://"
+ database.getAbsolutePath());
}
'database' is a File Object an not yet existing. So the DriverManager should create the file. But instead i get the error:
net.ucanaccess.jdbc.UcanaccessSQLException: given file does not exist: C:\folder\example.mdb
at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:204)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
The almost same code works fine with sqllite database and the file is created automatically if its not existing.
Anybody got an idea why this happens?
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Artur,
That the "DriverManager should create the file" isn't correct.
It's the driver that could do that, but you have to specify the format version:
through the Newdatabaseversion parameter.
Valid values are V2000, V2003, V2007, V2010.
e.g.
DriverManager.getConnection("jdbc:ucanaccess://"
+ database.getAbsolutePath()+";newdatabaseversion=V2010");
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey everybody,
i have a problem creating a new database file with ucanaccess.
Here is my code:
if (db.equals("ms-access")) {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
cn = DriverManager.getConnection("jdbc:ucanaccess://"
+ database.getAbsolutePath());
}
'database' is a File Object an not yet existing. So the DriverManager should create the file. But instead i get the error:
The almost same code works fine with sqllite database and the file is created automatically if its not existing.
Anybody got an idea why this happens?
Thank you.
Hi Artur,
That the "DriverManager should create the file" isn't correct.
It's the driver that could do that, but you have to specify the format version:
through the Newdatabaseversion parameter.
Valid values are V2000, V2003, V2007, V2010.
e.g.
DriverManager.getConnection("jdbc:ucanaccess://"
+ database.getAbsolutePath()+";newdatabaseversion=V2010");