Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> How to get started with JDBC?
Oracle 9iR2
Java 1.4
Windows XP
JBuilder 7 SE
I am going to write a Java program which will perform a SQL query to an Oracle server and display the result, and would like to review all my alternatives.
The program will be relatively simple:
This is going to be my first non-trivial Java application. I recently purchased Borland's JBuilder 7 SE. I also downloaded Oracle's JDeveloper, but haven't tried it out yet.
Some of my concerns/questions are:
A tutorial program from the Nutshell J2EE book is included below, that's pretty much what I neeed (plus the GUI stuff, of course).
TIA for your assistance.
Regards,
-Ramon F. Herrera
import java.sql.*;
public class JDBCSample {
public static void main(java.lang.String[] args) {
try {
Class.forName("oracle.java");
}
catch (ClassNotFoundException e) {
System.out.println("Unable to load driver class"); return;
Connection con = DriverManager.getConnection("jdbc:odbc:companydb", "", ""); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT FIRST_NAME FROM EMPLOYEES"); while (rs.next()) { System.out.println(rs.getString("FIRST_NAME")); } rs.close(); stmt.close(); con.close();
System.out.println("SQL Exception: " + se.getMessage()); se.printStackTrace(System.out);