I am trying to connect to a local .mdb file using Java 8. So far I have used UCanAccess's libraries but not all features are supported.
In Java 8 "JDBC/ODBC was scrapped"... So my question is:
What is the new method to connect to .mdb files (without UCanAccess)?
If you really don't want to use UCanAccess then you'll probably have to buy a third-party library
to replace the JDBC-ODBC Bridge that was removed from Java 8, or
to provide direct JDBC connectivity to the Access database.
However, as Marco indicates in his comment to the question, there could very well be UCanAccess (or HSQLDB) workarounds for your "feature not supported" issues if you care to give us a hint as to what they are.
Related
I have a program in c# and need to connect to SQL via JDBC. I read that JDBC works with java and since I need to use it from C#, I found out that there is jni4net that bridges between the two.
I can't seem to find any samples or tutorials on how to do so. Any help will be appreciated. I have read and tried using jni4net, but I couldn't find any sample connecting to a database.
JDBC stands for Java DataBase Connectivity, which means it is for Java (or other languages that can run on the Java Virtual Machine). C# is a different language with its own runtime. Although it may be possible to access Java from C#, doing so for database connections would probably be really cumbersome and slow.
Instead you should look for an ADO.net database provider for your database system(s). Most database systems have one.
You may use the robbiblubber.org JDBC Extension Libaray to connect to a database via JDBC from .NET. Of cource, if there is a native driver for ADO.NET, you should use that.
The question is pretty self-explanatory, but below is some more info about the situation:
I am building a Java program that will be replacing a program that consists of an Excel user interface with an Access database. The Excel program connects to the Access database and communicates with VBA. But, so far there has only ever been one user at a time. Now that the program is due to expand, we need many users to be able to write to any table at the same time.
Access allows multiple users to connect at once, of course. This is not possible in HSQLDB, which is what prompted the question. Obviously, this is better accomplished with a server, but the plan is to build the program using the current database and then accomplish the transition to a server later.
Thanks in advance
In order to support multiple concurrent users (processes) writing to an Access database you must use the Access Database Engine. The options to do that from a Java application are:
Use Java's own JDBC-ODBC Bridge and the Access ODBC driver. (Note that the JDBC-ODBC Bridge was removed from Java 8.)
Use a third-party JDBC-ODBC Bridge and the Access ODBC driver.
Use a third-party JDBC driver that works with the Access Database Engine (if such a thing exists).
Note especially that the UCanAccess JDBC driver does not use the Access Database Engine and therefore does not support multiple concurrent users (processes) writing to the Access database.
You can do it. I have a similar application that I use. In version 1.8 of Java, the ODBC bridge was removed, so you'll have to look into using a separate library to connect, assuming you are using 1.8 or above. For me, it's way slower, but it does work. check out
Removal of JDBC ODBC bridge in java 8
I use "Ucanaccess" for my program, which is one of the suggestions in that question.
i typed a single program to connect to a access database and display a single record.
but when i run the program, there seems to be an issue with the drivers.
(i'm just getting started in java)
** the DNS & table name are correct
The JDBC-ODBC bridge driver has been removed from JDK 8. Any tutorials you see that use Access probably depend on this class. It's been part of Java for 20 years, so I'm sure you'll find lots of examples that are now obsolete.
You'll either have to buy a JDBC driver for Access or use a real database like MySQL, PostgreSQL, etc.
I recently updated from java 7 to 8 and jdbc will no longer run.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // classNotFoundException is thrown
is what i get now when I run it, where did I go wrong?
thanks
UCanAccess is a pure Java JDBC driver that allows us to read from and write to Access databases without using ODBC. It uses two other packages, Jackcess and HSQLDB, to perform these tasks.
sun.jdbc.odbc.JdbcOdbcDriver is Java internal class, it is not documented in the official Java SE javadoc and it should not be used by applications because it may change or totally disappear in a next Java version.
I've been searching for the solution to open a .accdb database and read/write date from and into this file. The file is saved locally and not on a server and the solution should work without additional libraries.
Can someone help me?
Thank you for your advice
My recommendation would be to use UCanAccess.
The other common approach on Windows is was to use the JDBC-ODBC Bridge in conjunction with the Microsoft Access ODBC driver, but
that method has some limitations, particularly with respect to full Unicode support, and
the JDBC-ODBC Bridge has been removed from Java SE 8 and is not supported (ref: here).
For more information on UCanAccess see
Manipulating an Access database from Java without ODBC
There is an Apache Licensed Java library called Jackcess that allows reading/writing MS Access files.