Re: Recommended Data Mappings

From: "Carl Olivier" <carl(at)zero-one(dot)co(dot)za>
To: "Larry D(dot) Johnson" <ll(dot)cj(at)cox(dot)net>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Recommended Data Mappings
Date: 2003-03-08 15:44:02
Message-ID: BCEKIKAMLDKFEKBNELFKCENHCGAA.carl@zero-one.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hey.
This is the method I wrote to do thios for POSTGRESql:

public String getDataTypeName( int type, int size, int decimals )
{
switch (type)
{
case Types.BIT: return "BOOLEAN";
case Types.TINYINT: return "SMALLINT";
case Types.BIGINT: return "INT";
case Types.LONGVARBINARY: return "LONG BYTE";
case Types.VARBINARY: return "VARCHAR(" + size + ") BYTE";
case Types.BINARY: return "CHAR(" + size + ") BYTE";
case Types.LONGVARCHAR: return "TEXT";
case Types.CHAR: return "CHAR(" + size + ")";
case Types.NUMERIC: return "DECIMAL(" + size + "," + decimals +
")";
case Types.DECIMAL: return "DECIMAL(" + size + "," + decimals +
")";
case Types.INTEGER: return "INT";
case Types.SMALLINT: return "SMALLINT";
case Types.FLOAT: return "FLOAT";
case Types.REAL: return "REAL";
case Types.DOUBLE: return "DOUBLE PRECISION";
case Types.VARCHAR: return "VARCHAR(" + size + ")";
case Types.DATE: return "DATE";
case Types.TIME: return "TIME";
case Types.TIMESTAMP: return "TIMESTAMP";
default: return "TEXT";
}
}

where the Types is the java.sql.Types class..

Hope that helps

Carl

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org]On Behalf Of Larry D. Johnson
Sent: 08 March 2003 05:23 PM
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [JDBC] Recommended Data Mappings

All,

I have been looking for a table that specifies the recommended mappings
for the internal PostgreSQL data types to Java data types. I can make a
good stab a most of them; however, would like to know the recommeded
ones. I have looked in the docs, and performed several searches on the
web to try and find; but alas, not success.

Any help would be appreciated.
TIA

--
Regards,
Larry

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kyung Lee 2003-03-09 04:43:13 How are Unicode characters stored internally, in Postgres?
Previous Message Larry D. Johnson 2003-03-08 15:22:44 Recommended Data Mappings