Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8c17e4e

Browse files
author
Dave Cramer
committed
This patch fixes the exception thrown to inform the user the method
getColumnClassName(int) is not implemented. This will futher fixes method ResultSet.getObject(int) since it requires the getColumnClassName(int) method to return the proper java class used to map the database column. auther Ed Yu
1 parent deaad93 commit 8c17e4e

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,66 @@ private Field getField(int columnIndex) throws SQLException
473473
// This can hook into our PG_Object mechanism
474474
public String getColumnClassName(int column) throws SQLException
475475
{
476-
throw org.postgresql.Driver.notImplemented();
477-
}
476+
/*
477+
The following data type mapping came from ../Field.java.
478+
479+
"int2",
480+
"int4","oid",
481+
"int8",
482+
"cash","money",
483+
"numeric",
484+
"float4",
485+
"float8",
486+
"bpchar","char","char2","char4","char8","char16",
487+
"varchar","text","name","filename",
488+
"bool",
489+
"date",
490+
"time",
491+
"abstime","timestamp"
492+
493+
Types.SMALLINT,
494+
Types.INTEGER,Types.INTEGER,
495+
Types.BIGINT,
496+
Types.DOUBLE,Types.DOUBLE,
497+
Types.NUMERIC,
498+
Types.REAL,
499+
Types.DOUBLE,
500+
Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,
501+
Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,
502+
Types.BIT,
503+
Types.DATE,
504+
Types.TIME,
505+
Types.TIMESTAMP,Types.TIMESTAMP
506+
*/
478507

508+
int sql_type = getField(column).getSQLType();
509+
510+
switch (sql_type)
511+
{
512+
case Types.BIT:
513+
return("java.lang.Boolean");
514+
case Types.SMALLINT:
515+
return("java.lang.Integer");
516+
case Types.INTEGER:
517+
return("java.lang.Integer");
518+
case Types.BIGINT:
519+
return("java.lang.Long");
520+
case Types.NUMERIC:
521+
return("java.math.BigDecimal");
522+
case Types.REAL:
523+
return("java.lang.Float");
524+
case Types.DOUBLE:
525+
return("java.lang.Double");
526+
case Types.CHAR:
527+
case Types.VARCHAR:
528+
return("java.lang.String");
529+
case Types.DATE:
530+
case Types.TIME:
531+
case Types.TIMESTAMP:
532+
return("java.sql.Timestamp");
533+
default:
534+
throw org.postgresql.Driver.notImplemented();
535+
}
536+
479537
}
480538

0 commit comments

Comments
 (0)