🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.databases.oracle.server
Article #30

How to get started with JDBC?

#30
From: 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);
    }
  }
}

--------------------------------------------------------------------------------
Technical Details
Message-ID: <c9bc36ff.0206240254.bf056cc@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fa4f9,38d841947fd53c5d,start
X-Google-Attributes: gidfa4f9,public
X-Google-Thread: f7ed6,38d841947fd53c5d,start
X-Google-Attributes: gidf7ed6,public
X-Google-Thread: f74b3,38d841947fd53c5d,start
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2002-06-24 03:54:47 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
From: ramon@conexus.net (Ramon F Herrera)
Newsgroups: comp.databases.oracle.server,borland.public.jbuilder.enterprise,borland.public.jbuilder.java.language
Subject: How to get started with JDBC?
Date: 24 Jun 2002 03:54:46 -0700
Organization: http://groups.google.com/
Lines: 76
Message-ID: <c9bc36ff.0206240254.bf056cc@posting.google.com>
NNTP-Posting-Host: 24.147.245.255
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1024916086 27810 127.0.0.1 (24 Jun 2002 10:54:46 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 24 Jun 2002 10:54:46 GMT