* Add isPostgreSQL() method to DbSource and DbMapping.
This commit is contained in:
parent
332f98cbd0
commit
1213c464e3
2 changed files with 25 additions and 1 deletions
|
@ -1200,6 +1200,21 @@ public final class DbMapping {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the database behind this a PostgreSQL db?
|
||||||
|
*
|
||||||
|
* @return true if the dbsource is using a PostgreSQL JDBC driver
|
||||||
|
*/
|
||||||
|
public boolean isPostgreSQL() {
|
||||||
|
if (dbSource != null) {
|
||||||
|
return dbSource.isPostgreSQL();
|
||||||
|
}
|
||||||
|
if (parentMapping != null) {
|
||||||
|
return parentMapping.isPostgreSQL();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a string representation for this DbMapping
|
* Return a string representation for this DbMapping
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class DbSource {
|
||||||
private ResourceProperties props;
|
private ResourceProperties props;
|
||||||
protected String url;
|
protected String url;
|
||||||
private String driver;
|
private String driver;
|
||||||
private boolean isOracle, isMySQL;
|
private boolean isOracle, isMySQL, isPostgreSQL;
|
||||||
private long lastRead = 0L;
|
private long lastRead = 0L;
|
||||||
private Hashtable dbmappings = new Hashtable();
|
private Hashtable dbmappings = new Hashtable();
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ public class DbSource {
|
||||||
isOracle = driver.startsWith("oracle.jdbc.driver");
|
isOracle = driver.startsWith("oracle.jdbc.driver");
|
||||||
isMySQL = driver.startsWith("com.mysql.jdbc") ||
|
isMySQL = driver.startsWith("com.mysql.jdbc") ||
|
||||||
driver.startsWith("org.gjt.mm.mysql");
|
driver.startsWith("org.gjt.mm.mysql");
|
||||||
|
isPostgreSQL = driver.equals("org.postgresql.Driver");
|
||||||
// test if driver class is available
|
// test if driver class is available
|
||||||
Class.forName(driver);
|
Class.forName(driver);
|
||||||
|
|
||||||
|
@ -195,6 +196,14 @@ public class DbSource {
|
||||||
return isMySQL;
|
return isMySQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this DbSource represents a PostgreSQL database
|
||||||
|
*
|
||||||
|
* @return true if we're using a PostgreSQL JDBC driver
|
||||||
|
*/
|
||||||
|
public boolean isPostgreSQL() {
|
||||||
|
return isPostgreSQL;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Register a dbmapping by its table name.
|
* Register a dbmapping by its table name.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue