what databases can be used with java? - 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.

Related

What is ojdbc6.jar file?

For school project I had to make program in Java that uses data base and to do so I had to import to that project file ojdbc6.jar. I know that without it I couldn't use data bases but I don't really know what is this file. Could someone explain? How such file is called and what exactly is its purpose?
Simply stated, a JDBC driver is a suite of classes that map the functionality required by the JDBC API onto the functionality provided by a specific kind of database.
Each database uses a different "wire protocol" to communicate between code running in a database client and the database server. JDBC "abstracts that away" so that a Java program can talk to any vendor's database (more or less1). The JDBC driver is the "glue" that makes the abstraction work.
In the Oracle case, there are multiple JDBC drivers, for various purposes including
Thin drivers versus OCI or server-native drivers (OCI & server-native drivers depend on platform specific native libraries)
Client-side versus server-side drivers (server-side libraries are optimized for cases where the client code is running on the database server machine ... for example.)
Drivers for different versions of Java; e.g. supporting different JDBC conformance levels.
The "ojdbc6.jar" file constitutes the Oracle thin client-side JDBC driver which is compatible with Java 6 (JDBC level 4.0).
For more information, read the Oracle JDBC FAQ.
1 - There are a couple of issues that make cross-database compatibility difficulty. Firstly, different databases support different dialects of SQL and provide different sets of SQL data types. Secondly, certain database vendors (including Oracle, before they bought Sun) have implemented non-standard extensions to JDBC.

Java database compatibility

Will code that communicates with a Ms Access 2007 database work with a Ms Access 2003 database as well? And vice versa. How compatible is all the JDBC stuff with different versions?
Thanks.
There is an odbc-jdbc bridge, so Java can connect to everything you can setup an ODBC driver to.
Of course, the drivers mostly just "pass" the SQL to the database, so if your code used querys specific of a database they will work on that database but won't on anything else.
Although SQL is a standard, db vendors provide "extra" functionality that is not necessarily standard. Depends on your usage. I am not an expert in MS Access, but I would say assume it is not compatible until you are able to prove that it is
It would depend on your jdbc driver, but as long as you're not doing any vender specific calls, (ie: custom types for cursors or vender specific sql) you shouldn't have any problems.
So to answer your question, the jdbc code will port, but the sql may not.
Is the MS Access 2007 database in ACCDB format? If so you need to use the appropriate ACE driver. Now this will work just against an Access 2003 format database file so long as ACE is installed on the client system. If not then you'll want to use Jet 4.0 which is part of every Windows OS since Windows 2000.

jdbc odbc connectivity

am a newbie to java. I want to create a table in MYSQL and insert images into it.I have to write code in java to insert the images. can anyone tell me how to give connectivity between mySQL and java code. Can u suggest some materials for jdbc odbc connectivity.
Don't even think about mentioning ODBC when you're talking Java. JDBC-ODBC bridges were useful once, when we didn't have proper drivers but they should be considered a crime against humanity nowadays :-)
What you want is a type-4 (pure Java) JDBC driver and the "official" one is MySQL Connector/J.
That page also has links to a short JDBC Basics course and a more in-depth one, for your education.

Prerequirements to start with JDBC

I am new to JDBC. I would like to know what I should install in my machine before starting off with JDBC. It would be most appreciated if you can also give me links to find them.
read the tutorial first.
http://download.oracle.com/javase/tutorial/jdbc/index.html
Besides a working database, all you need is the JDK and the database-specific JDBC driver. You'll need to find and download the driver for the database you're going to use.
If you want to learn JDBC and don't care about a specific database, I can recommend HSQLDB, which is a lightweight DB that you can run on your machine or even from your process.
And I agree with qrtt1's advice - the best place to start is Sun/Oracle's JDBC tutorial.
Read "Before you Begin" in this JDBC Tutorial; for use with any JDBC Database, including Oracle, PostgreSQL, MySQL, etc.
Pretty much all you need is:
JDK 1.6 or greater installed and ready to go.
A text editor.
A JDBC Database Driver contained in products such as MySQL or PostgreSQL

Selecting a JDBC Driver

I'm trying to select a JDBC driver for an application I'm building and I've found lots of drivers, but I can't seem to narrow the selection down to one. The driver I select should have the following features:
Free for commercial use
Easy to install (eg. single jar file, no drivers to install)
Easy to use (well documented)
No database server required
Multi-user / Network support
What JDBC database drivers would you suggest?
So far I've considered TinySQL and SQLite.
The database is not very large think maybe 10k records.
The JDBC driver depends on the database you want to use. Some free databases include:
Derby (small, lightweight, comes with Java 1.6)
MySQL (bigger, lots of features)
PostgreSQL (bigger, lots of features)
I'm sure there are others.
When you install the database, the documentation will tell you where to get the JDBC driver.
Unless you have specific requirements, I would have suggested that you use MySQL, it is free and very popular. Also, it is very easy to use through JDBC. However, I then saw your comment:
I want to use a JDBC driver so if I
change databases the database will
have the same interface. Right now I
need a database that meets the above
requirements.
The problem is that, as far as I know, JDBC alone isn't that flexible. With JDBC you basically pass strings to and fro the application and the database engine. If you want something that allows you to change the database but doesn't impact the way that your application and database communicate, you should consider and ORM tool like Hibernate.
The OP asked for 'no database server'. That means that there are two options in common use: Derby and HSQLDB that integrate well into Java.

Categories