JDBC-Intro - Basics of JAVA programming using JDBC In this...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Basics of JAVA programming using JDBC In this document, we assume you will use the Oracle database engine set up in cse‐ ora.cse.usf.edu for your projects. You will write and test your Java code in a client computer, which can be a different machine. 1. Download a JDBC client side driver from the following page: http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.ht ml Make sure you have the right version of JDBC that matches your Oracle server. Our Oracle system is of version, therefore we choose the second link with following URL: http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/j dbc_10201.html Here you have to choose the right driver that matches the Java version you use in the client machine. For example, you should download ojdbc14.jar if you use JDK 1.4 or higher. To know your Java version, you can type the following in a UNIX‐flavor console: java –version 2. Copy the driver to wherever you want in the client machine. Record the path of the location of the driver. For example, if you want to use cse‐ora for your programming tasks, I have already put a copy of the driver as: /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/jdbc/lib/ojdbc14.jar 3. Now you can write your Java code to query a database via JDBC. An sample Java does this is posted on the project website with the name create_table.java . 4. To run the above example, you first need to compile it. Generally, the following will do: javac create_table.java This will generate a java bytecode file named create_table.class 5. To run the above program, you need to type: java –cp "xxx":. create_table where xxx is the exact path of the JDBC driver. This path in cse‐ora was shown above in item 2. ...
View Full Document

This note was uploaded on 07/31/2011 for the course EEL 4852c taught by Professor Tu during the Fall '08 term at University of South Florida - Tampa.

Ask a homework question - tutors are online