Thread: Re: Fw: Druid problems

Re: Fw: Druid problems

From
Bruce Momjian
Date:
I have applied the following patch that fixes Druid to work with our
jdbc driver.  Applied to jdbc1 and jdbc2.

> This get's us past the first problem. I have emailed the author for any
> other problems.
>
> I also found on the sun site a test suite for 1.2 driver, and the j2see
> driver. This will go a long ways to getting the driver solid.
> Now the challenge will be getting the j2see stuff to work ;)
>
> Dave

[ Attachment, skipping... ]

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: DatabaseMetaData.java
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java,v
retrieving revision 1.22
diff -c -r1.22 DatabaseMetaData.java
*** DatabaseMetaData.java    2001/05/17 11:54:04    1.22
--- DatabaseMetaData.java    2001/05/30 04:50:32
***************
*** 1489,1495 ****
      f[0] = new Field(connection, "PROCEDURE_CAT",   iVarcharOid, 32);
      f[1] = new Field(connection, "PROCEDURE_SCHEM", iVarcharOid, 32);
      f[2] = new Field(connection, "PROCEDURE_NAME",  iVarcharOid, 32);
!     f[3] = f[4] = f[5] = null;    // reserved, must be null for now
      f[6] = new Field(connection, "REMARKS",       iVarcharOid, 8192);
      f[7] = new Field(connection, "PROCEDURE_TYPE", iInt2Oid,    2);

--- 1489,1495 ----
      f[0] = new Field(connection, "PROCEDURE_CAT",   iVarcharOid, 32);
      f[1] = new Field(connection, "PROCEDURE_SCHEM", iVarcharOid, 32);
      f[2] = new Field(connection, "PROCEDURE_NAME",  iVarcharOid, 32);
!     f[3] = f[4] = f[5] = new Field(connection,"reserved",iVarcharOid,32);    // null;    // reserved, must be null
fornow 
      f[6] = new Field(connection, "REMARKS",       iVarcharOid, 8192);
      f[7] = new Field(connection, "PROCEDURE_TYPE", iInt2Oid,    2);


getDate() and getTime() fails with columns of type 'TimeStamp'

From
Michael Stephenson
Date:
In org.postgresql.jdbc2.ResultSet, both getDate() and getTime() fail on
columns of type 'timestamp', which is against the jdbc spec, patch below
fixes it.

Michael Stephenson      mstephenson@openworld.co.uk
Developer   -    Web Applications    -   Open World
Tel: +44 1225 444 950         Fax: +44 1225 336 738



--- ResultSet.java.old    Wed May 30 16:32:48 2001
+++ ResultSet.java    Wed May 30 16:41:33 2001
@@ -423,6 +423,8 @@
     String s = getString(columnIndex);
     if(s==null)
       return null;
+    if (s.length() > 10)
+    return new java.sql.Date(getTimeStamp(columnIndex).getTime())

     return java.sql.Date.valueOf(s);
   }
@@ -441,6 +443,8 @@

     if(s==null)
       return null; // SQL NULL
+    if (s.length() > 8)
+    return new java.sql.Time(getTimeStamp(columnIndex).getTime());

     return java.sql.Time.valueOf(s);
   }


Re: Fw: Druid problems

From
Tony Grant
Date:
Thanks!

Now I'll have to dive into the config files again so that it will let me
connect...

Cheers

Tony

--
RedHat Linux on Sony Vaio C1XD/S
http://www.animaproductions.com/linux2.html
Macromedia UltraDev with PostgreSQL
http://www.animaproductions.com/ultra.html


Re: getDate() and getTime() fails with columns of type 'TimeStamp'

From
Bruce Momjian
Date:
I just applied this patch sent in by someone else to the current CVS
tree.

>
> In org.postgresql.jdbc2.ResultSet, both getDate() and getTime() fail on
> columns of type 'timestamp', which is against the jdbc spec, patch below
> fixes it.
>
> Michael Stephenson      mstephenson@openworld.co.uk
> Developer   -    Web Applications    -   Open World
> Tel: +44 1225 444 950         Fax: +44 1225 336 738
>
>
>
> --- ResultSet.java.old    Wed May 30 16:32:48 2001
> +++ ResultSet.java    Wed May 30 16:41:33 2001
> @@ -423,6 +423,8 @@
>      String s = getString(columnIndex);
>      if(s==null)
>        return null;
> +    if (s.length() > 10)
> +    return new java.sql.Date(getTimeStamp(columnIndex).getTime())
>
>      return java.sql.Date.valueOf(s);
>    }
> @@ -441,6 +443,8 @@
>
>      if(s==null)
>        return null; // SQL NULL
> +    if (s.length() > 8)
> +    return new java.sql.Time(getTimeStamp(columnIndex).getTime());
>
>      return java.sql.Time.valueOf(s);
>    }
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
--- src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java~    Fri Feb 23 19:12:23 2001
+++ src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java    Wed May  9 04:31:11 2001
@@ -423,8 +423,13 @@
     String s = getString(columnIndex);
     if(s==null)
       return null;
-
-    return java.sql.Date.valueOf(s);
+    // length == 10: SQL Date
+    // length >  10: SQL Timestamp, assumes PGDATESTYLE=ISO
+    try {
+      return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0,10));
+    } catch (NumberFormatException e) {
+      throw new PSQLException("postgresql.res.baddate", s);
+    }
   }

   /**
@@ -441,8 +446,13 @@

     if(s==null)
       return null; // SQL NULL
-
-    return java.sql.Time.valueOf(s);
+    // length == 8: SQL Time
+    // length >  8: SQL Timestamp
+    try {
+      return java.sql.Time.valueOf((s.length() == 8) ? s : s.substring(11,19));
+    } catch (NumberFormatException e) {
+      throw new PSQLException("postgresql.res.badtime",s);
+    }
   }

   /**