Patch from Manfred: Allow arbitrary properties to be passed to the JDBC driver.
This commit is contained in:
parent
2a7fe39e24
commit
1a5c665579
1 changed files with 22 additions and 9 deletions
|
@ -21,18 +21,19 @@ import helma.util.SystemProperties;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class describes a releational data source (URL, driver, user and password).
|
* This class describes a releational data source (URL, driver, user and password).
|
||||||
*/
|
*/
|
||||||
public class DbSource {
|
public class DbSource {
|
||||||
private static SystemProperties defaultProps = null;
|
private static SystemProperties defaultProps = null;
|
||||||
|
private Properties conProps;
|
||||||
private String name;
|
private String name;
|
||||||
private SystemProperties props;
|
private SystemProperties props;
|
||||||
protected String url;
|
protected String url;
|
||||||
private String driver;
|
private String driver;
|
||||||
protected String user;
|
|
||||||
private String password;
|
|
||||||
private boolean isOracle;
|
private boolean isOracle;
|
||||||
private long lastRead = 0L;
|
private long lastRead = 0L;
|
||||||
|
|
||||||
|
@ -71,7 +72,8 @@ public class DbSource {
|
||||||
if ((con == null) || con.isClosed() || fileUpdated) {
|
if ((con == null) || con.isClosed() || fileUpdated) {
|
||||||
init();
|
init();
|
||||||
Class.forName(driver);
|
Class.forName(driver);
|
||||||
con = DriverManager.getConnection(url, user, password);
|
con = DriverManager.getConnection(url, conProps);
|
||||||
|
// con = DriverManager.getConnection(url, user, password);
|
||||||
|
|
||||||
// If we wanted to use SQL transactions, we'd set autoCommit to
|
// If we wanted to use SQL transactions, we'd set autoCommit to
|
||||||
// false here and make commit/rollback invocations in Transactor methods;
|
// false here and make commit/rollback invocations in Transactor methods;
|
||||||
|
@ -86,12 +88,23 @@ public class DbSource {
|
||||||
lastRead = (defaultProps == null) ? props.lastModified()
|
lastRead = (defaultProps == null) ? props.lastModified()
|
||||||
: Math.max(props.lastModified(),
|
: Math.max(props.lastModified(),
|
||||||
defaultProps.lastModified());
|
defaultProps.lastModified());
|
||||||
url = props.getProperty(name + ".url");
|
conProps=new Properties();
|
||||||
driver = props.getProperty(name + ".driver");
|
for (Enumeration e = props.keys(); e.hasMoreElements(); ) {
|
||||||
isOracle = driver != null && driver.startsWith("oracle.jdbc.driver");
|
String key = (String) e.nextElement();
|
||||||
Class.forName(driver);
|
if (!key.startsWith(name))
|
||||||
user = props.getProperty(name + ".user");
|
continue;
|
||||||
password = props.getProperty(name + ".password");
|
if (key.equals(name + ".url")) {
|
||||||
|
url = props.getProperty(name + ".url");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key.equals(name + ".driver")) {
|
||||||
|
driver = props.getProperty(name + ".driver");
|
||||||
|
isOracle = driver != null && driver.startsWith("oracle.jdbc");
|
||||||
|
Class.forName(driver);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
conProps.setProperty(key.substring(name.length()+1), props.getProperty(key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue