I am trying to create a very simple connection to an access database (.accdb) in my jave maven project using ucanaccess. The database is an external database and I just need to read the contect of some tables for a migration task. That means, I shouldn't change the database.
The java code, that I used is totally simple:*
Hi Marco,
I can't post the database, because it is a very complex database with many tables and relationships and it doesn't belonge to me. I am not allowed to share it (even without data) because of General Data Protection Regulation.
Furthermore I didn't want to change anything in the database, therefore I wanted to turn off the constraint checks to be able to just connect to the database and just READ the rows of some tables.
I also made a copy of the database and delete all the relationships between the tables and the code could then connect to the db, BUT IT TOOK 30 MINUTES TO CONNECT!!!! So, even if, I would have managed to make a copy from the database and delete all relationships between all tables each time I want to run my code (which actually isn't possible in my task), I should have waited 30 minutes to just open a connection!!!
I find it really ridiculous, that there is no possibility to turn off the constraint checks and open the connection for reading data, when some constraint aren't satisfied!!!
But anyway, at the end (after two days searching!) I found a solution for my work. I don't use any kind of Connection of DriverManager of this type:
Instead I use a DatabaseBuilder to open my database and get the tables and read the rows!
For anyone else, who have the same problem and just wants to connect to a MS-Access database in order to READ some data, without changing anything, I suggest this way. It is very easy and fast!
I am trying to create a very simple connection to an access database (.accdb) in my jave maven project using ucanaccess. The database is an external database and I just need to read the contect of some tables for a migration task. That means, I shouldn't change the database.
The java code, that I used is totally simple:*
But the connection fails right at the beginning with the following exception:
I tried to make my connection "readonly", so that it doesn't check for this constraint and doesn't throw an exception. But I didn't have any success.
Is there any way to turn off this constraint check, while creating the connection for reading some tables?
Hi Anne,
please post along in attachment the database (without data) so that I can reproduce the issue
Hi Marco,
I can't post the database, because it is a very complex database with many tables and relationships and it doesn't belonge to me. I am not allowed to share it (even without data) because of General Data Protection Regulation.
Furthermore I didn't want to change anything in the database, therefore I wanted to turn off the constraint checks to be able to just connect to the database and just READ the rows of some tables.
I also made a copy of the database and delete all the relationships between the tables and the code could then connect to the db, BUT IT TOOK 30 MINUTES TO CONNECT!!!! So, even if, I would have managed to make a copy from the database and delete all relationships between all tables each time I want to run my code (which actually isn't possible in my task), I should have waited 30 minutes to just open a connection!!!
I find it really ridiculous, that there is no possibility to turn off the constraint checks and open the connection for reading data, when some constraint aren't satisfied!!!
But anyway, at the end (after two days searching!) I found a solution for my work. I don't use any kind of Connection of DriverManager of this type:
Instead I use a DatabaseBuilder to open my database and get the tables and read the rows!
For anyone else, who have the same problem and just wants to connect to a MS-Access database in order to READ some data, without changing anything, I suggest this way. It is very easy and fast!
The Database, DatabaseBuilder, Row and Table are from "jackcess".
Here are some examples which use this way:
https://www.programcreek.com/java-api-examples/?api=com.healthmarketscience.jackcess.Database
http://ucanaccess.sourceforge.net/site.html#examples
Last edit: Anne 2020-02-05