Recommended Data Mappings

Поиск
Список
Период
Сортировка
Искать

Recommended Data Mappings

От:
"Larry D. Johnson" <ll.cj@cox.net>
Дата:
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

Re: Recommended Data Mappings

От:
"Carl Olivier" <carl@zero-one.co.za>
Дата:
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@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Larry D. Johnson
Sent: 08 March 2003 05:23 PM
To: pgsql-jdbc@postgresql.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@postgresql.org so that your
message can get through to the mailing list cleanly

FAQ