Detect PorgresSQL Version and support with Alias

This commit is contained in:
vpj-cd 2007-01-11 17:53:50 +00:00
parent d22f887e80
commit 8062e26a3b
8 changed files with 56 additions and 11 deletions

View File

@ -275,6 +275,8 @@ public interface AdempiereDatabase
*/ */
// public String getDataType (int displayType, int precision, // public String getDataType (int displayType, int precision,
// boolean defaultValue) // boolean defaultValue)
public boolean getSupportAlias();
} // AdempiereDatabase } // AdempiereDatabase

View File

@ -837,5 +837,10 @@ public class DB_DB2
public Convert getConvert() { public Convert getConvert() {
throw new UnsupportedOperationException("Not implemented."); throw new UnsupportedOperationException("Not implemented.");
} }
public boolean getSupportAlias()
{
return false;
}
} // DB_DB2 } // DB_DB2

View File

@ -550,6 +550,12 @@ public class DB_Fyracle implements AdempiereDatabase {
public boolean isSupported(String sql) { public boolean isSupported(String sql) {
return true; return true;
} }
public boolean getSupportAlias()
{
return false;
}
} // DB_Firebird } // 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;} public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException{return null;}
} }

View File

@ -1116,5 +1116,10 @@ public class DB_Oracle implements AdempiereDatabase, OracleConnectionCacheCallba
public Convert getConvert() { public Convert getConvert() {
return m_convert; return m_convert;
} }
public boolean getSupportAlias()
{
return false;
}
} // DB_Oracle } // DB_Oracle

View File

@ -70,6 +70,8 @@ public class DB_PostgreSQL implements AdempiereDatabase
private String m_userName = null; private String m_userName = null;
/** Connection String */ /** Connection String */
private String m_connectionURL; private String m_connectionURL;
private boolean m_supportAlias = false;
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger (DB_PostgreSQL.class); private static CLogger log = CLogger.getCLogger (DB_PostgreSQL.class);
@ -645,7 +647,7 @@ public class DB_PostgreSQL implements AdempiereDatabase
try try
{ {
postgresql.getDriver(); postgresql.getDriver();
Connection conn = DriverManager.getConnection (jdbcURL, uid, pwd); Connection conn = DriverManager.getConnection (jdbcURL, uid, pwd);
//CachedRowSetImpl crs = null; //CachedRowSetImpl crs = null;
//crs = new CachedRowSetImpl(); //crs = new CachedRowSetImpl();
@ -664,5 +666,19 @@ public class DB_PostgreSQL implements AdempiereDatabase
ex.printStackTrace(); ex.printStackTrace();
} }
} // main } // 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 } // DB_PostgreSQL

View File

@ -34,6 +34,8 @@ public final class ConvertMap_PostgreSQL {
s_pg.put("\\bCLOB\\b", "BYTEA"); // CLOB not directly supported s_pg.put("\\bCLOB\\b", "BYTEA"); // CLOB not directly supported
s_pg.put("\\bLIMIT\\b","\"limit\""); s_pg.put("\\bLIMIT\\b","\"limit\"");
s_pg.put("\\bACTION\\b","\"action\""); 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("\\bBLOB\\b", "OID"); // BLOB not directly supported
//s_pg.put("\\bCLOB\\b", "OID"); // CLOB not directly supported //s_pg.put("\\bCLOB\\b", "OID"); // CLOB not directly supported
//end vpj-cd e-evolution 03/11/2005 PostgreSQL //end vpj-cd e-evolution 03/11/2005 PostgreSQL

View File

@ -1497,6 +1497,11 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
* @return converted statementf * @return converted statementf
*/ */
private String convertAlias(String sqlStatement) { private String convertAlias(String sqlStatement) {
if (!org.compiere.util.DB.getDatabase().getSupportAlias())
return sqlStatement;
String[] tokens = sqlStatement.split("\\s"); String[] tokens = sqlStatement.split("\\s");
String table = null; String table = null;
String alias = null; String alias = null;

View File

@ -995,7 +995,7 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
} // remote_executeUpdate } // remote_executeUpdate
//remove this commnet if you want use JAVA 6 //remove this commnet if you want use JAVA 6
/*
public void setAsciiStream(int parameterIndex, java.io.InputStream x, long length) public void setAsciiStream(int parameterIndex, java.io.InputStream x, long length)
throws SQLException throws SQLException
{ {
@ -1003,6 +1003,7 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
} }
//vpj-cd add support java 6 //vpj-cd add support java 6
/*
public void setBinaryStream(int parameterIndex, java.io.InputStream x, public void setBinaryStream(int parameterIndex, java.io.InputStream x,
long length) throws SQLException 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) public void setBlob(int parameterIndex, InputStream inputStream, long length)
throws SQLException 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 //In order to compile in Java 6 you must add these methods
public void setNClob(int parameterIndex, NClob value) throws SQLException
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, java.sql.RowId x) throws SQLException{}
{
}
public void setRowId(int parameterIndex, RowId x) throws SQLException{}
*/ */
} // CPreparedStatement } // CPreparedStatement