Detect PorgresSQL Version and support with Alias
This commit is contained in:
parent
d22f887e80
commit
8062e26a3b
|
@ -275,6 +275,8 @@ public interface AdempiereDatabase
|
|||
*/
|
||||
// public String getDataType (int displayType, int precision,
|
||||
// boolean defaultValue)
|
||||
public boolean getSupportAlias();
|
||||
|
||||
|
||||
} // AdempiereDatabase
|
||||
|
||||
|
|
|
@ -837,5 +837,10 @@ public class DB_DB2
|
|||
public Convert getConvert() {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
}
|
||||
|
||||
public boolean getSupportAlias()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // DB_DB2
|
||||
|
|
|
@ -550,6 +550,12 @@ public class DB_Fyracle implements AdempiereDatabase {
|
|||
public boolean isSupported(String sql) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean getSupportAlias()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // DB_Firebird
|
||||
|
||||
|
@ -630,4 +636,5 @@ class DataSourceImpl implements DataSource {
|
|||
}
|
||||
|
||||
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException{return null;}
|
||||
|
||||
}
|
|
@ -1116,5 +1116,10 @@ public class DB_Oracle implements AdempiereDatabase, OracleConnectionCacheCallba
|
|||
public Convert getConvert() {
|
||||
return m_convert;
|
||||
}
|
||||
|
||||
public boolean getSupportAlias()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // DB_Oracle
|
||||
|
|
|
@ -70,6 +70,8 @@ public class DB_PostgreSQL implements AdempiereDatabase
|
|||
private String m_userName = null;
|
||||
/** Connection String */
|
||||
private String m_connectionURL;
|
||||
|
||||
private boolean m_supportAlias = false;
|
||||
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger (DB_PostgreSQL.class);
|
||||
|
@ -645,7 +647,7 @@ public class DB_PostgreSQL implements AdempiereDatabase
|
|||
try
|
||||
{
|
||||
postgresql.getDriver();
|
||||
Connection conn = DriverManager.getConnection (jdbcURL, uid, pwd);
|
||||
Connection conn = DriverManager.getConnection (jdbcURL, uid, pwd);
|
||||
|
||||
//CachedRowSetImpl crs = null;
|
||||
//crs = new CachedRowSetImpl();
|
||||
|
@ -664,5 +666,19 @@ public class DB_PostgreSQL implements AdempiereDatabase
|
|||
ex.printStackTrace();
|
||||
}
|
||||
} // main
|
||||
|
||||
public boolean getSupportAlias()
|
||||
{
|
||||
|
||||
if (s_driver == null)
|
||||
{
|
||||
s_driver = new org.postgresql.Driver();
|
||||
if(s_driver.getVersion().indexOf("PostgreSQL 8.2") != -1)
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
} // DB_PostgreSQL
|
||||
|
|
|
@ -34,6 +34,8 @@ public final class ConvertMap_PostgreSQL {
|
|||
s_pg.put("\\bCLOB\\b", "BYTEA"); // CLOB not directly supported
|
||||
s_pg.put("\\bLIMIT\\b","\"limit\"");
|
||||
s_pg.put("\\bACTION\\b","\"action\"");
|
||||
s_pg.put("\\bold\\b","\"old\"");
|
||||
s_pg.put("\\bnew\\b","\"new\"");
|
||||
//s_pg.put("\\bBLOB\\b", "OID"); // BLOB not directly supported
|
||||
//s_pg.put("\\bCLOB\\b", "OID"); // CLOB not directly supported
|
||||
//end vpj-cd e-evolution 03/11/2005 PostgreSQL
|
||||
|
|
|
@ -1497,6 +1497,11 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
|||
* @return converted statementf
|
||||
*/
|
||||
private String convertAlias(String sqlStatement) {
|
||||
|
||||
|
||||
if (!org.compiere.util.DB.getDatabase().getSupportAlias())
|
||||
return sqlStatement;
|
||||
|
||||
String[] tokens = sqlStatement.split("\\s");
|
||||
String table = null;
|
||||
String alias = null;
|
||||
|
|
|
@ -995,7 +995,7 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
|||
} // remote_executeUpdate
|
||||
|
||||
//remove this commnet if you want use JAVA 6
|
||||
/*
|
||||
|
||||
public void setAsciiStream(int parameterIndex, java.io.InputStream x, long length)
|
||||
throws SQLException
|
||||
{
|
||||
|
@ -1003,6 +1003,7 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
|||
}
|
||||
|
||||
//vpj-cd add support java 6
|
||||
/*
|
||||
public void setBinaryStream(int parameterIndex, java.io.InputStream x,
|
||||
long length) throws SQLException
|
||||
{
|
||||
|
@ -1069,6 +1070,12 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
|||
|
||||
}
|
||||
|
||||
public void setNClob(int i,java.sql.NClob c)
|
||||
throws SQLException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setBlob(int parameterIndex, InputStream inputStream, long length)
|
||||
throws SQLException
|
||||
{
|
||||
|
@ -1087,19 +1094,15 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
|||
|
||||
}
|
||||
|
||||
/* In order to compile in Java 6 you must add these methods
|
||||
|
||||
public void setNClob(int parameterIndex, NClob value) throws SQLException
|
||||
//In order to compile in Java 6 you must add these methods
|
||||
|
||||
|
||||
public void setSQLXML(int parameterIndex, java.sql.SQLXML xmlObject) throws SQLException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setRowId(int parameterIndex, RowId x) throws SQLException{}
|
||||
public void setRowId(int parameterIndex, java.sql.RowId x) throws SQLException{}
|
||||
*/
|
||||
|
||||
} // CPreparedStatement
|
||||
|
|
Loading…
Reference in New Issue