* Add isPostgreSQL() method to DbSource and DbMapping.

This commit is contained in:
hns 2006-06-17 11:50:59 +00:00
parent 332f98cbd0
commit 1213c464e3
2 changed files with 25 additions and 1 deletions

View file

@ -1200,6 +1200,21 @@ public final class DbMapping {
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
*

View file

@ -35,7 +35,7 @@ public class DbSource {
private ResourceProperties props;
protected String url;
private String driver;
private boolean isOracle, isMySQL;
private boolean isOracle, isMySQL, isPostgreSQL;
private long lastRead = 0L;
private Hashtable dbmappings = new Hashtable();
@ -115,6 +115,7 @@ public class DbSource {
isOracle = driver.startsWith("oracle.jdbc.driver");
isMySQL = driver.startsWith("com.mysql.jdbc") ||
driver.startsWith("org.gjt.mm.mysql");
isPostgreSQL = driver.equals("org.postgresql.Driver");
// test if driver class is available
Class.forName(driver);
@ -195,6 +196,14 @@ public class DbSource {
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.
*