🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.databases.oracle.server
1 messages
1 total messages Started by Ramon F Herrera Mon, 24 Jun 2002 10:54
How to get started with JDBC?
#30
Author: Ramon F Herrera
Date: Mon, 24 Jun 2002 10:54
76 lines
3223 bytes
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:

  - it will run on Windows XP
  - it will NOT make use of a browser
  - there will be a single SQL query
  - the result is just one row

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:

  - Are the Enterprise Editions required or just more convenient?
    I am refering to both Borland's JBuilder EE and Sun's J2EE

  - Can I just download Oracle's JDBC driver and somehow (how?)
    make it available to JBuilder SE?

  - Do I need to install the Oracle 9i Client on the Windows PC?

A tutorial program from the Nutshell J2EE book is included
below, that's pretty much what I neeed (plus the GUI stuff,
of course).

  - Where can I find the documentation for the method
    DriverManager.getConnection?  

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;
    }
    try {
      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();
    }
    catch (SQLException se){
      System.out.println("SQL Exception: " + se.getMessage());
      se.printStackTrace(System.out);
    }
  }
}

--------------------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads