logo       

[Fwd: [Fwd: Re: [JDBC] Patch for ResultSetMetaData.getColumnClassName(), Re: msg#00216

Subject: [Fwd: [Fwd: Re: [JDBC] Patch for ResultSetMetaData.getColumnClassName(), ResultSet.getObject()]]


Patch applied.

thanks,
--Barry

-------- Original Message --------
Subject: Re: [JDBC] Patch for ResultSetMetaData.getColumnClassName(), ResultSet.getObject()
Date: Sat, 15 Jun 2002 20:42:14 -0400 (EDT)
From: Bruce Momjian To: Jason Davies CC: PostgreSQL JDBC

Jdbc folks, have you reviewed this patch?

---------------------------------------------------------------------------

Jason Davies wrote:
> Hi,
>
> This patch handles Types.{SMALLINT,DATE,TIME,BINARY,VARBINARY,ARRAY}
> properly in ResultSetMetaData.getColumnClassName(int col). The
> default return value has been improved slightly too.
>
> In the case of Types.{BINARY,VARBINARY} it should be a byte[]
> class name, but AFAIK no such thing exists therefore I used
> "java.lang.Object" instead.
>
> Also I optimized just a couple of things in ResultSet.getObject:
> there's no need to create a new Boolean object every time and
> there's no need to use (short)getInt(...) since getShort(...)
> does the same thing :-)
>
> Thank you, --Jase
>
> -- Jason Davies
>
> jason@xxxxxxxxxxxx

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister
> command
>     (send "unregister YourEmailAddressHere" to majordomo@xxxxxxxxxxxxxx)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@xxxxxxxxxxxxxxxx               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



? build
? jars
? patch.diff
? org/postgresql/Driver.java
? org/postgresql/jdbc2/ResultSetMetaData.java.diff
Index: org/postgresql/jdbc1/ResultSet.java
===================================================================
RCS file: 
/projects/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java,v
retrieving revision 1.33
diff -c -r1.33 ResultSet.java
*** org/postgresql/jdbc1/ResultSet.java 2002/06/07 16:46:23     1.33
--- org/postgresql/jdbc1/ResultSet.java 2002/06/08 23:58:45
***************
*** 927,935 ****
                switch (field.getSQLType())
                {
                        case Types.BIT:
!                               return new Boolean(getBoolean(columnIndex));
                        case Types.SMALLINT:
!                               return new Short((short)getInt(columnIndex));
                        case Types.INTEGER:
                                return new Integer(getInt(columnIndex));
                        case Types.BIGINT:
--- 927,935 ----
                switch (field.getSQLType())
                {
                        case Types.BIT:
!                               return getBoolean(columnIndex) ? Boolean.TRUE : 
Boolean.FALSE;
                        case Types.SMALLINT:
!                               return new Short(getShort(columnIndex));
                        case Types.INTEGER:
                                return new Integer(getInt(columnIndex));
                        case Types.BIGINT:
Index: org/postgresql/jdbc2/ResultSet.java
===================================================================
RCS file: 
/projects/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java,v
retrieving revision 1.52
diff -c -r1.52 ResultSet.java
*** org/postgresql/jdbc2/ResultSet.java 2002/06/07 16:46:24     1.52
--- org/postgresql/jdbc2/ResultSet.java 2002/06/08 23:58:47
***************
*** 744,752 ****
                switch (field.getSQLType())
                {
                        case Types.BIT:
!                               return new Boolean(getBoolean(columnIndex));
                        case Types.SMALLINT:
!                               return new Short((short)getInt(columnIndex));
                        case Types.INTEGER:
                                return new Integer(getInt(columnIndex));
                        case Types.BIGINT:
--- 744,752 ----
                switch (field.getSQLType())
                {
                        case Types.BIT:
!                               return getBoolean(columnIndex) ? Boolean.TRUE : 
Boolean.FALSE;
                        case Types.SMALLINT:
!                               return new Short(getShort(columnIndex));
                        case Types.INTEGER:
                                return new Integer(getInt(columnIndex));
                        case Types.BIGINT:
Index: org/postgresql/jdbc2/ResultSetMetaData.java
===================================================================
RCS file: 
/projects/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java,v
retrieving revision 1.11
diff -c -r1.11 ResultSetMetaData.java
*** org/postgresql/jdbc2/ResultSetMetaData.java 2002/02/22 03:22:31     1.11
--- org/postgresql/jdbc2/ResultSetMetaData.java 2002/06/08 23:58:59
***************
*** 471,476 ****
--- 471,491 ----
        // ** JDBC 2 Extensions **
  
        // This can hook into our PG_Object mechanism
+       /**
+        * Returns the fully-qualified name of the Java class whose instances 
+        * are manufactured if the method <code>ResultSet.getObject</code>
+        * is called to retrieve a value from the column.
+        * 
+        * <code>ResultSet.getObject</code> may return a subclass of the class
+        * returned by this method.
+        *
+        * @param column the first column is 1, the second is 2, ...
+        * @return the fully-qualified name of the class in the Java programming
+        *         language that would be used by the method
+        *         <code>ResultSet.getObject</code> to retrieve the value in 
the specified
+        *         column. This is the class name used for custom mapping.
+        * @exception SQLException if a database access error occurs
+        */
        public String getColumnClassName(int column) throws SQLException
        {
   /*
***************
*** 505,538 ****
       Types.TIMESTAMP,Types.TIMESTAMP
   */
  
!       int sql_type = getField(column).getSQLType();
  
!       switch (sql_type)
!         {
!                       case Types.BIT:
!                       return("java.lang.Boolean");
!                       case Types.SMALLINT:
!                       return("java.lang.Integer");
!                       case Types.INTEGER:
!                       return("java.lang.Integer");
!                       case Types.BIGINT:
!                       return("java.lang.Long");
!                       case Types.NUMERIC:
!                       return("java.math.BigDecimal");
!                       case Types.REAL:
!                       return("java.lang.Float");
!                       case Types.DOUBLE:
!                       return("java.lang.Double");
!                       case Types.CHAR:
!                       case Types.VARCHAR:
!                       return("java.lang.String");
!                       case Types.DATE:
!                       case Types.TIME:
!                       case Types.TIMESTAMP:
!                       return("java.sql.Timestamp");
!                       default:
!                       throw org.postgresql.Driver.notImplemented();
!        }
!    }       
  }
  
--- 520,566 ----
       Types.TIMESTAMP,Types.TIMESTAMP
   */
  
!               Field field = getField(column);
!               int sql_type = field.getSQLType();
  
!               switch (sql_type)
!               {
!                       case Types.BIT:
!                               return("java.lang.Boolean");
!                       case Types.SMALLINT:
!                               return("java.lang.Short");
!                       case Types.INTEGER:
!                               return("java.lang.Integer");
!                       case Types.BIGINT:
!                               return("java.lang.Long");
!                       case Types.NUMERIC:
!                               return("java.math.BigDecimal");
!                       case Types.REAL:
!                               return("java.lang.Float");
!                       case Types.DOUBLE:
!                               return("java.lang.Double");
!                       case Types.CHAR:
!                       case Types.VARCHAR:
!                               return("java.lang.String");
!                       case Types.DATE:
!                               return("java.sql.Date");
!                       case Types.TIME:
!                               return("java.sql.Time");
!                       case Types.TIMESTAMP:
!                               return("java.sql.Timestamp");
!                       case Types.BINARY:
!                       case Types.VARBINARY:
!                               return("java.sql.Object");
!                       case Types.ARRAY:
!                               return("java.sql.Array");
!                       default:
!                               String type = field.getPGType();
!                               if ("unknown".equals(type))
!                               {
!                                       return("java.lang.String");
!                               }
!                               return("java.lang.Object");
!               }
!       }
  }
  


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
message can get through to the mailing list cleanly
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe