return "postgresql";
}
public SQLTypeInfo newSQLTypeInfo(ResultSet rs)
{
SQLTypeInfo info = new PostgresqlTypeInfo(rs);
// Since PostgreSQL supports many user defined data types and uses many type aliases the
// default methods have trouble finding the right associations between JDBC and PostgreSQL
// data types. We filter the returned type info to be sure we use the appropriate base
// PostgreSQL types for the important JDBC types.*/
if (psqlTypes == null)
{
psqlTypes = new Hashtable();
psqlTypes.put("" + Types.BIT, "bool");
psqlTypes.put("" + Types.TIMESTAMP, "timestamptz");
psqlTypes.put("" + Types.BIGINT, "int8");
psqlTypes.put("" + Types.CHAR, "char");
psqlTypes.put("" + Types.DATE, "date");
psqlTypes.put("" + Types.DOUBLE, "float8");
psqlTypes.put("" + Types.INTEGER, "int4");
psqlTypes.put("" + Types.LONGVARCHAR, "text");
psqlTypes.put("" + Types.CLOB, "text");
psqlTypes.put("" + Types.BLOB, "bytea");
psqlTypes.put("" + Types.NUMERIC, "numeric");
psqlTypes.put("" + Types.REAL, "float4");
psqlTypes.put("" + Types.SMALLINT, "int2");
psqlTypes.put("" + Types.TIME, "time");
psqlTypes.put("" + Types.VARCHAR, "varchar");
psqlTypes.put("" + Types.OTHER, "***TOTALRUBBISH***");
// PostgreSQL provides 2 types for "char" mappings - "char" and "bpchar". PostgreSQL recommend
// bpchar for default usage, but sadly you cannot say "bpchar(200)" in an SQL statement. Due to
// this we use "char" since you can say "char(100)" (and internally in PostgreSQL it becomes bpchar)
// PostgreSQL 8.1 JDBC driver somehow puts "char" as Types.OTHER rather than Types.CHAR ! so this is
// faked in createTypeInfo() above.
// PostgreSQL (7.3, 7.4) doesn't provide a SQL type to map to JDBC types FLOAT, DECIMAL, BLOB, BOOLEAN
}
Object obj = psqlTypes.get("" + info.getDataType());
if (obj != null)
{
String psql_type_name = (String)obj;
if (!info.getTypeName().equalsIgnoreCase(psql_type_name))
{
// We don't support this JDBC type using *this* PostgreSQL SQL type
NucleusLogger.DATASTORE.debug(LOCALISER.msg("051007", info.getTypeName(),
JDBCUtils.getNameForJDBCType(info.getDataType())));
return null;
}
}
return info;
}