1 14 package org.compiere.db; 15 16 import java.sql.*; 17 import javax.sql.RowSet ; 18 19 21 import org.compiere.dbPort.*; 22 23 29 public class DB_PostgreSQL implements CompiereDatabase 30 { 31 34 public DB_PostgreSQL() 35 { 36 try 37 { 38 if (s_driver == null) 39 s_driver = new org.postgresql.Driver(); 40 } 41 catch (SQLException e) 42 { 43 System.err.println(e); 44 } 45 } 47 48 private org.postgresql.Driver s_driver = null; 49 50 51 public static final int DEFAULT_PORT = 5432; 52 53 54 private Convert m_convert = new Convert(Database.DB_POSTGRESQL, null); 55 56 private String m_connection; 57 58 62 public String getName() 63 { 64 return Database.DB_POSTGRESQL; 65 } 67 71 public String getDescription() 72 { 73 return s_driver.toString(); 74 } 76 80 public int getStandardPort() 81 { 82 return DEFAULT_PORT; 83 } 85 89 public java.sql.Driver getDriver() 90 { 91 return s_driver; 92 } 94 101 public String getConnectionURL (CConnection connection) 102 { 103 StringBuffer sb = new StringBuffer ("jdbc:postgresql:"); 105 sb.append("//").append(connection.getDbHost()) 106 .append(":").append(connection.getDbPort()) 107 .append("/").append(connection.getDbName()) 108 .append("?encoding=UNICODE"); 109 m_connection = sb.toString(); 110 return m_connection; 111 } 113 117 public boolean supportsBLOB() 118 { 119 return false; 120 } 122 126 public String toString() 127 { 128 StringBuffer sb = new StringBuffer ("DB_PostgreSQL["); 129 sb.append(m_connection) 130 .append("]"); 131 return sb.toString(); 132 } 134 135 136 143 public String convertStatement (String oraStatement) 144 { 145 String retValue[] = m_convert.convert(oraStatement); 146 if (retValue == null) 147 throw new IllegalArgumentException 148 ("DB_PostgreSQL.convertStatement - Not Converted (" + oraStatement + ") - " 149 + m_convert.getConversionError()); 150 if (retValue.length != 1) 151 throw new IllegalArgumentException 152 ("DB_PostgreSQL.convertStatement - Convert Command Number=" + retValue.length 153 + " (" + oraStatement + ") - " + m_convert.getConversionError()); 154 if (!oraStatement.equals(retValue[0]) && retValue[0].indexOf("AD_Error") == -1) 156 System.out.println("PostgreSQL =>" + retValue[0] + "<= <" + oraStatement + ">"); 157 return retValue[0]; 159 } 161 162 163 170 public void setRowID (PreparedStatement pstmt, int pos, Object rowID) throws SQLException 171 { 172 pstmt.setString (pos, (String )rowID); 173 } 175 182 public Object getRowID (java.sql.ResultSet rs, int pos) throws SQLException 183 { 184 return rs.getString (pos); 185 } 187 193 public RowSet getRowSet (java.sql.ResultSet rs) throws SQLException 194 { 195 throw new UnsupportedOperationException ("PostgreSQL does not support RowSets"); 196 } 198 } | Popular Tags |