1 19 package org.lucane.server.database; 20 21 import java.sql.Connection ; 22 import java.sql.SQLException ; 23 24 import javax.sql.DataSource ; 25 26 class PostgresLayer extends DatabaseAbstractionLayer 27 { 28 private DataSource dataSource; 29 30 public PostgresLayer(DataSource dataSource) 31 { 32 this.dataSource = dataSource; 33 } 34 35 public Connection getConnection() 36 throws SQLException 37 { 38 return dataSource.getConnection(); 39 } 40 41 public String resolveType(String type) 42 { 43 if(type.equalsIgnoreCase("SMALLTEXT")) 44 return "VARCHAR(250)"; 45 else if(type.equalsIgnoreCase("TEXT")) 46 return "TEXT"; 47 else if(type.equalsIgnoreCase("SMALLINT")) 48 return "int2"; 49 else if(type.equalsIgnoreCase("INT")) 50 return "int4"; 51 else if(type.equalsIgnoreCase("BIGINT")) 52 return "int8"; 53 else if(type.equalsIgnoreCase("REAL")) 54 return "float8"; 55 else 56 return type; 57 } 58 } 59 | Popular Tags |