|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javasimon.jdbc.Driver
public final class Driver
Simon JDBC Proxy Driver.
An application should not use this class directly. The application (if standalone)
should use DriverManager only. For example:
Connection conn = DriverManager.getConnection("jdbc:simon:oracle:thin:...", "scott", "tiger");
Simon driver has following format of JDBC connection string:
jdbc:simon:<real driver conn string>;<param1>=<value1>;...Simon driver recognizes two parameters:
SIMON_REAL_DRV - if you don't want or can't register real driver for any
reason, you can use this parameter and Simon proxy driver will do the registration
for you. You don't need to specify real driver parameter for some well known databases.
Simon proxy driver recognize database by first key word after JDBC and register.
SIMON_PREFIX - setting this parameter you can choose different prefix
for all monitors for one instance of driver. For example, setting
SIMON_PREFIX=com.foo will ensure that all proxy related Simons are located
under the subtree specified by the prefix, e.g. com.foo.conn, com.foo.stmt,
com.foo.select, etc. If no prefix is set, default org.javasimon.jdbc prefix
is used.
SIMON_LOGFILE - setting this parameter you can enable logging events (JDBC activity)
to specified file, for example ...;simon_logfile=c:\jdbc.log or
...;simon_logfile=/tmp/jdbc.log.
SIMON_LOGGER - setting this you can enable logging events (JDBC activity) to specified JDK14
logger (@{link java.util.logging.Logger}), for example ...;simon_logger=my.package.logger.
SIMON_CONSOLE - setting this you can enable logging events (JDBC activity) to console, which is
(System.err) using standard ConsoleHandler, for example
...;simon_console=y or ...;simon_console=true.
SIMON_FORMAT - by this parameter you can set format of log. There are two build-in formats:
human and csv. Custom format is also possible by specifing clasname. Custom formatter
must by derived from SimonFormatter. For example
...;simon_format=csv or ...;simon_format=my.package.MyFormmater
DriverManager).
If this is not a case for any reason, you need to register Simon proxy driver at least.
For real driver Simon proxy driver contains following procedure for find and register it:
Class.forName("oracle.jdbc.driver.OracleDriver"); // loads real driver
Class.forName("org.javasimon.jdbc.Driver"); // loads Simon proxy driver
Connection conn = DriverManager.getConnection(
"jdbc:simon:oracle:thin:...", "scott", "tiger");
DriverManager.getConnection(String)| Nested Class Summary | |
|---|---|
(package private) static class |
Driver.Url
Class Url represents Simon JDBC url. |
| Field Summary | |
|---|---|
private static String |
CONSOLE
Name for the driver property enabling JDBC logging to console ( System.err)
using ConsoleHandler. |
static String |
DEFAULT_PREFIX
Default hierarchy prefix for Simon JDBC driver. |
private Properties |
drivers
|
private static String |
FORMAT
Name for the driver property setting format for logs. |
private static String |
LOGFILE
Name for the driver property enabling JDBC logging to specified file. |
private static String |
LOGGER
Name for the driver property enabling JDBC logging to specified JDK14 logger (@{link java.util.logging.Logger}). |
static String |
PREFIX
Name for the driver property holding the hierarchy prefix given to JDBC Simons. |
static String |
REAL_DRIVER
Name for the property holding the real driver class value. |
| Constructor Summary | |
|---|---|
Driver()
Class constructor. |
|
| Method Summary | |
|---|---|
boolean |
acceptsURL(String url)
|
Connection |
connect(String simonUrl,
Properties info)
Opens new Simon proxy driver connection associated with real connection to specified database. |
int |
getMajorVersion()
|
int |
getMinorVersion()
|
DriverPropertyInfo[] |
getPropertyInfo(String s,
Properties properties)
|
private Driver |
getRealDriver(Driver.Url url,
Properties info)
Tries to determine driver class, instantiate it and register if already not registered. |
boolean |
jdbcCompliant()
|
private Driver |
registerDriver(String name)
Registers real driver through DriverManager. |
private void |
registerLoggingCallback(Driver.Url url)
Registers JDBC logging callback to Simon manager. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String REAL_DRIVER
public static final String DEFAULT_PREFIX
public static final String PREFIX
private static final String LOGFILE
private static final String LOGGER
private static final String CONSOLE
System.err)
using ConsoleHandler.
private static final String FORMAT
human and
csv. Custom format is also possible by specifing clasname, must by derived from
SimonFormatter.
private final Properties drivers
| Constructor Detail |
|---|
public Driver()
| Method Detail |
|---|
public Connection connect(String simonUrl,
Properties info)
throws SQLException
connect in interface DriversimonUrl - JDBC connection string (i.e. jdbc:simon:h2:file:test)info - properties for connection
SQLException - if there is no real driver registered/recognized or opening real connection failsDriverprivate void registerLoggingCallback(Driver.Url url)
url - instance of Driver.UrlSimonManager.callback(),
Callback.addCallback(org.javasimon.Callback)
private Driver getRealDriver(Driver.Url url,
Properties info)
throws SQLException
Driver class javadoc.
url - instance of url object that represents urlinfo - parameters from connect(String, java.util.Properties) method
SQLException - if real driver can't be determined or is not registerd
private Driver registerDriver(String name)
throws SQLException
DriverManager.
name - real driver class name
SQLException - if registration fails
public boolean acceptsURL(String url)
throws SQLException
acceptsURL in interface DriverSQLException
public DriverPropertyInfo[] getPropertyInfo(String s,
Properties properties)
throws SQLException
getPropertyInfo in interface DriverSQLExceptionpublic int getMajorVersion()
getMajorVersion in interface Driverpublic int getMinorVersion()
getMinorVersion in interface Driverpublic boolean jdbcCompliant()
jdbcCompliant in interface Driver
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||