Hopefully, I post this thread in the right area. I am learning how to use a database in Java. I am trying to connect to an access database. I have researched the internet and found out that I need to use Ucanaccess. I have followed several tutorials on using Ucanaccess and have been successful. However when I try to distribute my application and move to another computer. I get an error. From the tutorials, I found it said that you need to use the full path to the database. I was wondering if there is a way to access the database without having to use the full path or is another Java-based library that I can use to access the database. I just want to have the flex ability to distribute my application.
I don't have information about Ucanaccess, but am I right in assuming that you can write some code which figures out what the full path to the database is before you make the connection? I think that's quite likely. And if that's the case then you could modify your application to do that figuring out. Without knowing how you distribute the application it's impossible to advise you on how to do that, but it might involve popping up a file chooser so that the user can tell you where it is. Or it might be in the same folder as the application... or many other possibilities.
It's actually as simple as what Paul said, if you keep you're accesdatabase i, ypur projectfolder (in the resource package for example) you can use a relative path and then it dosn't mather where the program is moved to;
An alternative, but kinda the same, A friend of mine's, when writting his thesis, client was also using an acces db, he used the data of the accesfile to create a H2 embedded database, but that writes also everything to a file, so weather you keep your accesfile in your project or you keep de H2file in your project dosn't make that mutch difference, although you can direct H2 as anny real db, so you could use JpaRepositories and stuff, I doubt that's possible with acces, but I also never usd UcanAcces so I could be mistaking
It's good to be able to use someting, it's better to understand how it works.
The Microsoft Access and Microsoft FoxPro databases were designed for single-user operation and should not be used for any sort of multi-user application, including web applications, because having multiple users hit an Access database at one time may corrupt the database. For those sorts of applications, a multi-user database server is recommended and there are many to choose from, ranging from Microsoft's own SQL Server to IBM's DB2 to Oracle, to the open-source MySQL/MariaDB and PostgreSQL, Apache Derby, SQLite, and on and on and on.
All of the major SQL databases can be accessed via a universal interface: The Java Database Connection interface (JDBC). It's a lot like ODBC, except that ODBC really only works with Windows, whereas JDBC drivers can be found for every major OS, making the Java database app "write once/run anywhere".
The ucanaccess driver is a JDBC driver for MS Access, and you can definitely talk to your MS-Access database using that, and it's a lot more suited than the JDBC-ODBC bridge driver that people used to use for that purpose.
Just remember what I said initially - no matter what driver you use, MS-Access is not designed for multi-user applications, so limit its use to learning purposes.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.
posted 2 months ago
Thanks, everyone for the advice. The application will be used just for a single user. Currently, we do not have the option to set up a SQL server at this time. I will keep on researching the usage for Ucanaccess for the time being.