Tech

20121219

Diagnosable Oracle JDBC 11g Driver

The Oracle's 11g JDBC driver comes with a Self-Diagnosable features in which might help on the diagnose connection issue with the Data Base. Base on java.util.logging framework and javax.management MBean framework, in which follow the Java standard for monitoring and management.

  • java.util.logging _ Can be configure from providing a simple issue track, such as running out resource, to something more specific and detail tracing on an internal execution of a system. 
  • javax.management _ Can consult and change system's behavior through MBeans, accumulate statistics and notify in states changes on error's behaviors. 

The OJDBC self-diagnose, is not implemented in all the drivers. Actually you might need to go back to Oracles's driver site and download the following drivers:

  • ojdbc5_g.jar 
  • ojdbc6_g.jar

 *That's is why they have named these drivers with an *_g.jar at the end.

1- To enable the tracing you need to add at the java startup argument the following flag:

-Doracle.jdbc.Trace=true

This flags enable the global logging, if you want to debug the entire application this' the way to go.

2- Now we need to add the following flag on the java startup in which gives a path to an configuration file properties:

-Djava.util.logging.config.file=/jdbc/home/JDBCLogging.properties

3- Create the file /jdbc/home/JDBCLogging.properties; and set as following:

.level=SEVERE
oracle.jdbc.level=INFO
oracle.jdbc.handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

This will throw the output into the console, there fore no log file should be created. If you need to actually to produce a physical log you need to set as following:

.level=SEVERE
oracle.jdbc.level=INFO
oracle.jdbc.handlers=java.util.logging.FileHandler
java.util.logging.FileHandler.level=INFO
java.util.logging.FileHandler.pattern=jdbc.log
java.util.logging.FileHandler.count=1
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter


The amount of details are controlled by choosing bellow values, from less information to most detail information:

  • OFF
  • SEVERE
  • WARNING
  • INFO
  • CONFIG
  • FINE
  • FINER
  • FINEST
  • ALL
The 11g's OJDBC also lets you choose which system or part of the driver in which can be debugged; Is a nice thing, because some times you do not need too much information but specific information, and how to do this is controlling the logging level using the following flags:

  • oracle.jdbc 
  • oracle.jdbc.driver
  • oracle.jdbc.pool
  • oracle.jdbc.rowset
  • oracle.jdbc.xa
  • oracle.sql
*Subject to change by release version.
These flags can be simply add to the  /jdbc/home/JDBCLogging.properties like:

.level=SEVERE
oracle.jdbc.level=INFO
oracle.jdbc.driver.level=ALL *
oracle.jdbc.handlers=java.util.logging.FileHandler
java.util.logging.FileHandler.level=INFO
java.util.logging.FileHandler.pattern=jdbc.log
java.util.logging.FileHandler.count=1
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter


ref: 








No comments:

Post a Comment