Prerequirements to start with JDBC - java

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

Related

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.

java odbc foxpro

I am attempting to build some java apps that use a FoxPro database that is part of a large Visual FoxPro product. I have been able to read the data using a jdbc-odbc bridge. While I had to search long and hard to find out how to accomplish that task, what I haven't been able to find out is if I can safely insert/delete/edit the tables. I don't know if the index files are used by the jdbc-odbc libraries.
On a related note, does anyone know if you use MS SqlServer to set up a link to the foxpro data will make the FoxPro data "act" like a real relational db, or if the functionality doing things that way is the same as using the odbc solution.
I'm not replacing the current Visual FoxPro product, just trying to add some functionality, and I don't want to break the existing product.
Thanks.
I would imagine the JDBC-ODBC bridge handles indexes transparently, it wouldn't be much use otherwise.
You might be better looking at StelsDBF or Hxtt's native JDBC drivers.
Visual FoxPro is already a relational database. Not sure what you would achieve via the MSSQL approach.

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.

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.

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