This essay developed out of conversations I've had with several other programmers about why Java smelled suspicious. It's not a critique of Java!
Sycorax - complete tutorials
Programming Tutorials
" Java provides the industry - software companies and customer alike , an opportunity to create a true open computing environment where software is portable,
and customers benefit from increase competition. "
Java and the Future
December 1, 2008-LEJB 3.1: EJB New and Improved!
The EJB 3.0 specification was a huge improvement from what you were used to in the early versions of EJB. Available as an early draft, EJB 3.1 has many more features and is even easier to use.
December 1, 2008-Should Java Assert that Network I/O Can't Occur on the UI Thread?
Doing network I/O on the user interface (UI) thread is bad. Most developers know that and can tell you why; unfortunately, it's still done.
Register now to recieve special alert and latest technology news!
Registering a JDBC Driver
You must register the Oracle driver, oracle.jdbc.driver.OracleDriver, in your program before you use it. At this point, you may be confused because we've been talking about the OCI and Thin drivers, but now we refer only to one class when registering. That's because the same class file implements both drivers.
Registering the driver is the process by which the Oracle driver's class file is loaded into memory
so it can be utilized as an implementation of the JDBC interfaces. You need to do this only once
in your program. You can register a driver in one of three ways. The most common approach is to
use Java's Class.forName( ) method to dynamically load the driver's class file into memory,
which automatically registers it. This method is preferable because it allows you to make the
driver registration configurable and portable.
The following example uses Class.forName( ) to register the Oracle driver:
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException e) {
System.out.println("Oops! Can't find class
oracle.jdbc.driver.OracleDriver");
System.exit(1);
}
The second approach you can use to register a driver is to use the static
DriverManager.registerDriver( ) method. Use the registerDriver( ) method if you
are using a non-JDK compliant JVM, such as the one provided by Microsoft. For example:
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver( ));
}
catch(SQLException e) {
System.out.println("Oops! Got a SQL error: " + e.getMessage( ));
System.exit(1);
}
The third approach is to use a combination of Class.forName( ) to dynamically load the
Oracle driver and then the driver classes' getInstance( ) method to work around
noncompliant JVMs, but then you'll have to code for two extra Exceptions. To call the
getInstance( ) method for the dynamically loaded class, you can code the call as
Class.forName().newInstance( ):
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance( );
}
catch(ClassNotFoundException e) {
System.out.println("Oops! Can't find class
oracle.jdbc.driver.OracleDriver");
System.exit(1);
}
catch(IllegalAccessException e) {
System.out.println("Uh Oh! You can't load
oracle.jdbc.driver.OracleDriver");
System.exit(2);
}
catch(InstantiationException e) {
System.out.println("Geez! Can't instantiate
oracle.jdbc.driver.OracleDriver");
System.exit(3);
}