Article View: comp.databases.oracle.server
Article #31How to get started with JDBC?
From: Ramon F Herrera
Date: Mon, 24 Jun 2002 11:05
Date: Mon, 24 Jun 2002 11:05
76 lines
3223 bytes
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("sun.jdbc.odbc.JdbcOdbcDriver");
}
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.0206240305.4c0531a0@posting.google.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa4f9,38d841947fd53c5d X-Google-Attributes: gidfa4f9,public X-Google-Thread: f7ed6,38d841947fd53c5d X-Google-Attributes: gidf7ed6,public X-Google-Thread: f74b3,38d841947fd53c5d X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2002-06-24 04:05:58 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 04:05:57 -0700 Organization: http://groups.google.com/ Lines: 76 Message-ID: <c9bc36ff.0206240305.4c0531a0@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 1024916758 28575 127.0.0.1 (24 Jun 2002 11:05:58 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 24 Jun 2002 11:05:58 GMT