How to Java Persistence Api with MS Access? - java

I could not find any jdbc driver for ms access.So how can I connect MS Access with JPA ?

AFAIK, the only free drivers available are JDBC-ODBC bridges (type 1).
The JDBC-ODBC Bridge Driver distributed by Sun is sun.jdbc.odbc.JdbcOdbcDriver and this is what they write about it:
Note that the bridge driver included in the Java Platform Standard Edition (Java SE) 6 is appropriate only for experimental use or when no other driver is available.
And if this is not enough, here is what Ted Neward writes in Item 49 of Effective Enterprise Java:
(...) the JDBC-ODBC driver is an unsupported, bug-ridden 1.0 driver that is incredibly slow and is rumored to leak memory in some ODBC driver configurations (...)
Things may be a bit better with the Microsoft one (which is com.ms.jdbc.odbc.JdbcOdbcDriver) but I wouldn't expect a miracle.
So, if this is for a corporate application, maybe consider spending a few dollars for a commercial type 4 JDBC Driver. See this previous answer for some options.

It doesn't look like you need a MS driver at all. Just use a sun ODBC driver.
Look at the article here.

I've never needed it, but I've heard good things about this one: http://jackcess.sourceforge.net/

You can use UcanAccess: http://ucanaccess.sourceforge.net/site.html
It is a good replacement for the ODBC driver since Java 8

Related

odbc driver exception jdk 1.8

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.

Difference among OCI driver, Thin driver, Data Source - OracleDataSource?

I am Using Oracle Database 10g Express Edition with Java.
Link:
http://srikanthtechnologies.com/articles/oracle/java.html
3 types of connections with different drivers are depicted
i want to know that can all these 3 connection be made in any situation or these are used in specific cases ?
The 2/3 are almost the same. Both of them uses jdbc:oracle:thin driver. The only difference is the invoker (DriverManager vs. OracleDataSource).
The 1st uses oci driver (jdbc:oracle:oci8). This is totally different with thin driver. Thin driver is 100% implemented in Java. So no more library is needed. But OCI driver needs Oracle OCI client, which is implemented in C/C++ (You must install it before you use the oci driver). As a result, it is platform dependent (C/C++ library).
Some people thinks the performance of OCI is better than thin, because OCI is implemented in native C/C++. But Oracle never releases an official document to prove that.
Now most apps use thin driver, because it is easy to deploy (Do not need the Oracle OCI client). And to be decoupled with the Oracle classes (OracleDatasource), most people use DriverManager to load the oracle thin driver, or a Connection Pool.

Sample MS Access database

For JDBC-ODBC Bridge, I use a self-made School.mdb database with no more than 5 records.
One of the community members told me to use a 'real' database like HL2D (if I got the name right).
Where is this database located?
If it is available on the internet, where can I get it?
They might have meant Hypersonic SQL. You can also try Derby, which is part of JDK 7 and higher. Or SQL Lite.
I'd prefer all of them to MS Access. All have type IV, pure Java JDBC drivers that will work on 64 bit operating systems. The JDBC-ODBC bridge driver uses native code for 32 bit operating systems that hasn't been ported to 64 bit.
Five records? You don't need a database. A simple file on the file system loaded into a Map will do for that.

Oracle thin driver vs. OCI driver. Pros and Cons?

When you develop a Java application that talks to oracle DBs, there are 2 options right? One is oracle thin driver, and the other is OCI driver that requires its own installation (please correct if I'm misunderstanding).
Now, what are the pros and cons? Obviously thin driver sounds much better in terms of installation, but is there anything that OCI can and the thin one can't?
Develop environment is Tomcat6 + Spring 3.0 + JPA(Hibernate) + apache-DBCP
The choice of the driver depends several factors. The nature of your calls to database (e.g. it seem like your app won't be using lots of stored proc calls), requirements for failover (e.g. clustered Oracle servers) and distributed transactions. Generally it is recommended to use the thin driver, but if there is some specific feature of the OCI driver that you just must have you may have to consider the OCI driver. It also been said that drivers in Oracle 10 and higher do have matching capabilities and there is practically no performance difference on modern JVMs.
Unless you have a dependency on a feature that is only available in the JDBC-OCI driver and not in the JDBC-thin driver, the recommendation from Oracle is to use thin. The most recent Oracle Database features such as Transaction Guard or Application Continuity are only available in the JDBC-thin driver. The thin driver is also more used than the JDBC-OCI driver so bugs will be fixed more quickly. It's considered as more stable. If you're still not convinced think that Oracle Weblogic Server ships with the JDBC-thin driver only.

what databases can be used with java?

I am doing an undergrad final project, and need to justify my choice of MySQL for the database element of my project. Truth is, it's the only one I can really use, and hence I went for it.
What other database systems could I have used? Any advantages and disadvantages of these over MySQL?
In fact, you can use every database which is accessible through a JDBC driver. Almost all self-respected RDBMS vendors provides a fullworthy JDBC driver for download at their homepage. Just Google "[vendorname] jdbc driver download" to find it. Here's an overview:
MySQL JDBC driver
PostgreSQL JDBC driver (note: older versions doesn't support generated keys).
Oracle JDBC driver (note: older versions doesn't support generated keys).
MSSQL JDBC driver (or performancewise better, the jTDS JDBC driver)
DB2 JDBC driver is hard to find in IBM's online forest, but it's usually already included in the /java folder of the DB2 installation.
This way you can use the JDBC API transparently to access either of the databases.
As to which database to choose, just look at the features, robustness, performance, etc the RDBMS provides and the budget you have -if it isn't freeware. I myself tend to prefer PostgreSQL.
Instead of a fullfledged database server, you can also consider an embedded Javabased database, such as Sun Oracle JavaDB, Apache Derby, HSQLDB or SQLite, each which are of course accessible through the JDBC API the usual way.
You can use any relational database that has a JDBC driver. These would include PostgreSQL, Hypersonic SQL, MySQL, SQLLite on the free side and Oracle, MS SQL Server, and others on the paid side.
The biggest advantage accrued to MySQL in your case is that it's free and you know it. That's enough to make it suitable for what you want to accomplish.
You could have used pretty much ANY database. MSSQL, SQLite, Postgre, Oracle or [put your choice here]
There's a driver for pretty much any database to integrate with Java. This is a great place to find out all the DB's java support, as well as how to integrate
Hope this helps
Have a look at the list of vendors who have endorsed the JDBC API maintained by Sun. Also see the list of third-party JDBC technology-enabled drivers which are currently shipping.
You mentioned MySQL and database. For the case you are free to usa a non RDBMS you can check db4o.
Advantage: pure OO/Java persistence.
Many have said this already, but pretty much any database will work. Consider including the top 5 (based on rankings, popularity) in your writeup.

Categories