odbc driver exception jdk 1.8 - java

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.

Related

Can multiple users connect to a Microsoft Access database at the same time using Java?

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.

Can no longer run jdbc with update

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.

Connect to an Access database from Java 8 without using UCanAccess

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.

How to save user name (simple example of jdbc) in java?

can you please give the steps how to make simple program of jdbc on mac .
I have eclipse on my mac .so I need steps what to do next so that can able to make program of jdbc ?
I do lot of RND but they provide for windows.But I also download Mysql from this link
http://dev.mysql.com/downloads/file.php?id=450342
and download workbench from this link
http://dev.mysql.com/downloads/file.php?id=412161
Then can you please may I right ?
or what next I have to do to make jdbc program ?
Install and start MySql.
Download the MySql JDBC driver. Try here: http://dev.mysql.com/downloads/connector/j/. Extract all the files and add the jar to your eclipse project.
Now you can start coding. Look up the docs for DriverManager, Statement and ResultSet.
There is not much difference at all in using a Mac than other platforms for working with JDBC.
JDK
You need an implementation of Java, a "JDK". See my answer to another question about installing Java 7 and Java 8 on a Mac, including links for downloading a JDK. Before doing the database stuff, be sure this works in the Terminal.app program: java -version
JDBC Driver
You need a JDBC driver specific to your particular database engine.
H2 Database
I suggest trying the H2 database rather than MySQL, only because it may be a gentler easier way to get started. H2 is pure Java, rather simple in terms of installing and administrating, and free-of-cost. H2 comes with its own JDBC driver. The H2 web site has a quick-start page and a tutorial page. It is not written explicitly for Mac OS X, but you should be able to "translate" as needed.
Oracle Tutorial
Then follow the JDBC tutorial provided by Oracle.
Also: StackOverflow is for specific questions on programming, not general or wide-ranging discussion.

Microsoft access database to java

I am considering using a Microsoft access database for a Java project. My question is, if I use a Microsoft access database and I complete my project and run it as a jar file on any computer/operating system, does any computer/ operating system need to have Microsoft access installed on it, particularly if the database needs to be put on a GUI on the java program and the administrator of the program can add and remove entries.
You will have to install the access odbc driver on any machine that accesses the database. I think you can do this by installing the Access runtime stuff without installing all of Access. Keep in mind that this sort of data-access is file-level, so your performance will be very poor. I'd suggest that you use a real database (postgres, mysql, sql server, oracle) or maybe a lightweight one such as SQL Server express and then accessing that database using either an odbc-jdbc bridge or preferably a native jdbc driver. Using a native jdbc driver will let you run your app from a non-windows environment.
You can use a Access Database via the JDBC-ODBC bridge on every Microsoft Windows system without to install Microsoft Access. You only need the Access Database Engine (ACE) formerly known as Jet Database Engine. ACE is part of current Windows versions. For older ones it may be necessary to install the Microsoft Data Access Components (MDAC).
Using a Access Database from Java has some disadvantages:
This is a type 1 driver with native code. Generally pure Java JDBC drivers are more performant.
With JDK 6 the JDBC-OLE bridge was somewhat enhanced. But there are still some problems with charsets and CLOBs.
Your application is restricted to Microsoft Windows operating systems.
According to the JDK 7 JDBC-ODBC bridge guide the JDBC-ODBC bridge will be removed in JDK 8:
The JDBC-ODBC Bridge should be considered a transitional solution; it will be removed in JDK 8. In addition, Oracle does not support the JDBC-ODBC Bridge. Oracle recommends that you use JDBC drivers provided by the vendor of your database instead of the JDBC-ODBC Bridge.
So if there is any chance to use another database for your project, you should avoid using Microsoft Access together with Java.
There are lots of alternatives with far more better JDBC drivers.
If you want a small footprint embedded database, there are:
Java DB (part of the JDK), also known as Apache Derby
H2
HSQLDB
SQLite e.g. with Xerial driver
(Java DB, H2 and HSQLDB are pure Java solutions)
If you prefer a client server solution, for most commercial and open source there exist full-fledged JDBC drivers.
Oracle
Microsoft SQL Server (the server has to run on Windows but your Java client can run on every OS that supports a JVM. See Microsoft JDBC Driver for SQL Server Support Matrix)
PostgreSQL
MySQL

Categories