org.ChinaVO.FITSManager.Util
Class DriverShim

java.lang.Object
  extended by org.ChinaVO.FITSManager.Util.DriverShim
All Implemented Interfaces:
java.sql.Driver

public class DriverShim
extends java.lang.Object
implements java.sql.Driver

a proxy driver to trick the security mechanism of driver manager.

example:
String strDrv = ss.getStringValue("config/database/driver",
"org.apache.derby.jdbc.EmbeddedDriver");
URL url;
try {
// url = new
// URL("file:/D:/Program Files/Develop/Java/eclipse/./derby.jar");
File f = new File(ss.getStringValue(
"config/database/driverFileURL", "./derby.jar"));
url = f.toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
url = null;
}
URLClassLoader ucl = new URLClassLoader(new URL[] { url },
DBOperator.class.getClassLoader());
Driver drv = (Driver) Class.forName(strDrv, true, ucl)
.newInstance();
DriverManager.registerDriver(new DriverShim(drv));


Constructor Summary
DriverShim(java.sql.Driver d)
           
 
Method Summary
 boolean acceptsURL(java.lang.String u)
           
 java.sql.Connection connect(java.lang.String u, java.util.Properties p)
           
 int getMajorVersion()
           
 int getMinorVersion()
           
 java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String u, java.util.Properties p)
           
 boolean jdbcCompliant()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DriverShim

public DriverShim(java.sql.Driver d)
Method Detail

acceptsURL

public boolean acceptsURL(java.lang.String u)
                   throws java.sql.SQLException
Specified by:
acceptsURL in interface java.sql.Driver
Throws:
java.sql.SQLException

connect

public java.sql.Connection connect(java.lang.String u,
                                   java.util.Properties p)
                            throws java.sql.SQLException
Specified by:
connect in interface java.sql.Driver
Throws:
java.sql.SQLException

getMajorVersion

public int getMajorVersion()
Specified by:
getMajorVersion in interface java.sql.Driver

getMinorVersion

public int getMinorVersion()
Specified by:
getMinorVersion in interface java.sql.Driver

getPropertyInfo

public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String u,
                                                     java.util.Properties p)
                                              throws java.sql.SQLException
Specified by:
getPropertyInfo in interface java.sql.Driver
Throws:
java.sql.SQLException

jdbcCompliant

public boolean jdbcCompliant()
Specified by:
jdbcCompliant in interface java.sql.Driver