Welcome! Wikis are websites that everyone can build together. It's easy!

JDBC

The Java Database Connectivity API (JDBC) is used to connect Java programs with databases.

The API provides for a call level API for SQL based database access. It allows you to establish a connection with a database, send SQL statements, and process the results.

The JDBC API consists of two major sets of interfaces; the first is for application writers and the second is the JDBC driver for driver writers.

The connection to the database can be through direct connections to the database, through client libraries, or through JDBC-ODBC bridges.

The bridge connection is typically used for a device that does not have client libraries or native connections supported.

The different Oracle JDBC drivers are
  • Thin - pure Java driver used on the client side that does not need an Oracle client installation. It is recommended that you use this driver unless you need support for non-TCP/IP networks because it provides for maximum portability and performance.
  • Oracle Call Interface driver (OCI). This uses the Oracle client installation libraries and interfaces. If you want to support connection pooling or client side caching of requests, use this driver. You will also need this driver if you are using transparent application failover (TAF) from your application as well as strong authentication like Kerberos and PKI certificates.
  • JDBC-ODBC bridge. This uses the ODBC driver in Windows to connect to the database

The JDBC drivers that come with the 10gR2 Client and server are compatible with JDK 1.2.x and later. The JDK 1.0.x and 1.1.x are no longer supported.

A sample code segment for connecting to a database from Java looks like:

String url = "jdbc:odbc:mydatabase";
Connection con = DriverManager.getConnection(url, "userID", "password");
if (con) {
System.out.println(" connection good");
} else {
System.out.println(" connection failed");
}

In this example we use the ODBC-JDBC bridge to connect to the database using the ODBC data source named mydatabase.

We could have used "jdbc:dbnet://mydatabase.oracle.com:1521/mydatabase" to connect directly to the listener.

We could also add attributes to the ODBC connection to define things like CacheSize, AlternatServer, or connection timeout.

To create a failover or load balance definition for a JDBC connection you can do this with the following url definitions

String url = "jdbc:inetora:localhost:1521:mydatabase?failover=true&host1 =standbyDB.oracle.com&port1=1521&host2=remoteDB.oracle.com&port2=1521"; String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=example.com)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)
(HOST=failover.example.com)(PORT=1521))
(FAILOVER=true)(LOAD_BALANCE=false)
(CONNECT_DATA=(SERVER=DEDICATED)(SID=foo)))";



Latest page update: made by osde8info , Mar 4 2008, 11:33 AM EST (about this update About This Update osde8info added spaces - osde8info


view changes

- complete history)
Keyword tags: JDBC
More Info: links to this page

Anonymous  (Get credit for your thread)


Started By Thread Subject Replies Last Post
vlad33 How can I change SDU in jdbc:oracle:thin 0 May 28 2008, 3:07 PM EDT by vlad33
Thread started: May 28 2008, 3:07 PM EDT  Watch
I am using Oracle JDBC thin driver with Oracle10g and need to increase a size of SDU. Is there any way to achieve that in the oracle thin driver?
1  out of 2 found this valuable. Do you?    
Keyword tags: JDBC Thin

Related Content

(what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)
Top Contributors