Index Search Add FAQ Ask Question |
---|
$Date: 10-Oct-1999 $
$Revision: 1.11 $
$Author: Frank Naudé $
Person B. Wake up and smell the Java you IDIOT!!!
|
What is JDBC and what is it good for?
JDBC is a set of classes and interfaces written in Java to allow other Java
programs to send SQL statements to a relational database management system.
Oracle provides three categories of JDBC drivers:
The Oracle Call Interface (OCI) is an application programming interface to Oracle databases. It consists of a library of C language routines to allow C programs (or programs written in other third generation languages) to send SQL statements to the database and interact with it in other ways.
Oracle's JDBC OCI drivers are Type 2 JDBC drivers. They provide an implementation of the JDBC interfaces that uses the OCI to interact with an Oracle database. You must use a JDBC OCI driver appropriate to your Oracle client installation. The OCI driver works through either SQL*Net or Net8.
The JDBC OCI drivers allow you to call the OCI directly from Java, thereby providing a high degree of compatibility with a specific Version of Oracle. Because they use native methods, they are platform specific.
Oracle's JDBC KBPR driver is used equivalent to the server side OCI driver. The KBRP driver is mainly used for writing Java stored procedures and triggers.
All three drivers support the same syntax and API's. Oracle needs three drivers to support different deployment options. Looking at source code, they will only differ in the way you connect to the database. Remember, you must use a JDBC version that matches your Java Development Kit.
SQLJ is more concise and thus easier to write than JDBC, and provides compile-time schema validation and syntax checking for easier debugging. SQLJ reads input either from a SQLJ file, or a Java source file in which SQLJ statements are embedded. The SQLJ precompiler translates the SQLJ statements into their equivalent JDBC calls. SQLJ supports static SQL.
Applets:
Applets do not live in a page as is commonly perceived. Applets are actually Java classes identified via HyperText Markup Langauge (HTML) tags within Web documents, it is these HTML tags that are embedded within Web documents. Java Applets are loaded from Web Servers somewhere on the Internet or within your corporate Intranet or Extranet.
Applications:
Java applications fit the traditional application model in the sense that they are executed from a command line and need to be installed on, or migrated to, each application host machine and then executed within that machine's JVM using the following command line construct:
Sample Java Application:
/** * The HelloWorldApp class implements an application that * simply displays "Hello World!" to the standard output. */ class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); //Display the string. } }Sample Java Applet:
import java.applet.Applet; import java.awt.Graphics; public class HelloWorld extends Applet { public void paint(Graphics g) { g.drawString("Hello world!", 50, 25); } }
import java.sql.*; class dbAccess { public static void main (String args []) throws SQLException { DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@qit-uq-cbiw:1526:orcl", "scott", "tiger"); // @machineName:port:SID, userid, password Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION"); while (rset.next()) System.out.println (rset.getString(1)); // Print col 1 stmt.close(); } }
import java.sql.*; class dbAccess { public static void main (String args []) throws SQLException { try { Class.forName ("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } Connection conn = DriverManager.getConnection ("jdbc:oracle:oci8:@qit-uq-cbiw_orcl", "scott", "tiger"); // or oci7 @TNSNames_Entry, userid, password Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION"); while (rset.next()) System.out.println (rset.getString(1)); // Print col 1 stmt.close(); } }
General: |
Home |
Index |
Preamble |
Glossary |
OraCorp |
Papers |
Fun |
News |
Events |
Y2000 |
Books |
Links |
Forums
Products: |
SQL |
Plus |
Loader |
PL/SQL |
PreComp |
OPO |
OMO |
OO4OLE |
DBA |
PQO |
PSO |
OCO |
Net |
ODBC |
WebServer |
Des2k |
Dev2k
| Systems: |
MVS |
Unix |
Windows |
WindowsNT |
NetWare |
VMS
| |