X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 13520329D68 for ; Thu, 16 Sep 2004 17:26:26 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85138-04 for ; Thu, 16 Sep 2004 16:26:22 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id B5B25329D91 for ; Thu, 16 Sep 2004 17:26:21 +0100 (BST) Received: (qmail 4822 invoked from network); 16 Sep 2004 16:26:43 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 16 Sep 2004 16:26:43 -0000 Subject: Re: multiple out parameters implementation From: Dave Cramer Reply-To: pg@fastcrypt.com To: Barry Lind Cc: Kris Jurka , "pgsql-jdbc@postgresql.org" In-Reply-To: <03E7D3E231BB7B4A915A6581D4296CC69796EE@NSNOVPS00411.nacio.xythos.com> References: <03E7D3E231BB7B4A915A6581D4296CC69796EE@NSNOVPS00411.nacio.xythos.com> Content-Type: multipart/mixed; boundary="=-FkIQ+pOPchQWT4065nbZ" Organization: Cramer Consulting Message-Id: <1095352119.1622.398.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Thu, 16 Sep 2004 12:28:39 -0400 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/82 X-Sequence-Number: 10972 --=-FkIQ+pOPchQWT4065nbZ Content-Type: text/plain Content-Transfer-Encoding: 7bit Barry, Kris, The "hack" is much smaller now thanks to Oliver's changes in the backend. It's now only minor changes. Although, at this point nobody has asked for it. That might change once 8.1 supports them and people start expecting the same behaviour in previous versions. Attached is the proof of concept patch, which when I look at it is larger than I remembered, but alot of the changes would be compatible, ie all of the changes to getXXX() Dave On Thu, 2004-09-16 at 12:01, Barry Lind wrote: > I agree with Kris' reasoning. I haven't liked this hack from the day it > was first proposed by Redhat/Fijitsu. I had come to accept it as a > necessary evil since I had given up on the backend ever supporting this > natively. > > The best situation would be to have this in the backend. Second best > would be to implement Dave's changes and have the backend never support > it. Worst would be to have two incompatible implementations (in both > the driver and the backend) (think bytea vs LO but worse since I am not > sure it would be possible to toggle between two different ways of > dealing with multiple out parameters). > > --Barry > > > -----Original Message----- > From: Kris Jurka [mailto:books@ejurka.com] > Sent: Thursday, September 16, 2004 2:01 AM > To: Dave Cramer > Cc: pgsql-jdbc@postgresql.org > Subject: Re: [JDBC] multiple out parameters implementation > > > > On Wed, 1 Sep 2004, Dave Cramer wrote: > > > I've managed to hack into the jdbc driver the capability for multiple > > out parameters from a postgresql function. > > > > I would like to query the list as to their thoughts, is this a useful > > feature for the driver ? > > > > This is a useful feature because it's currently the only way to port > certain things, but it's clearly not very straightforward and it causes > some non trivial thinking on the parts of the database and Java > developers to get their code to match up. > > Until just today I was in favor of this as we don't have any other > options or any hope for a real procedure interface in the near future, > but today on -hackers Gavin Sherry and Neil Conway indicated that they > have a proposal for implementing this feature in the backend. I'd say > lets take a look at the proposal and if we believe they've got a decent > shot at getting this in 8.1 then we hold off on this hack. The method > you proposed is pretty complicated and would introduce a pretty bad > backwards compatibility problem. > > Kris Jurka > > ---------------------------(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 > -- Dave Cramer 519 939 0336 ICQ # 14675561 www.postgresintl.com --=-FkIQ+pOPchQWT4065nbZ Content-Disposition: attachment; filename=outparm.diff Content-Type: text/x-patch; name=outparm.diff; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Index: org/postgresql/jdbc2/AbstractJdbc2Statement.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v retrieving revision 1.29 diff -c -B -b -r1.29 AbstractJdbc2Statement.java *** org/postgresql/jdbc2/AbstractJdbc2Statement.java 10 Aug 2004 11:27:28 -0000 1.29 --- org/postgresql/jdbc2/AbstractJdbc2Statement.java 1 Sep 2004 01:19:24 -0000 *************** *** 72,82 **** // functionReturnType contains the user supplied value to check // testReturn contains a modified version to make it easier to // check the getXXX methods.. ! private int functionReturnType; ! private int testReturn; // returnTypeSet is true when a proper call to registerOutParameter has been made private boolean returnTypeSet; ! protected Object callResult; protected int maxfieldSize = 0; public ResultSet createDriverResultSet(Field[] fields, Vector tuples) --- 72,83 ---- // functionReturnType contains the user supplied value to check // testReturn contains a modified version to make it easier to // check the getXXX methods.. ! private int []functionReturnType; ! private int []testReturn; // returnTypeSet is true when a proper call to registerOutParameter has been made private boolean returnTypeSet; ! protected Object []callResult; ! protected int maxfieldSize = 0; public ResultSet createDriverResultSet(Field[] fields, Vector tuples) *************** *** 105,110 **** --- 106,114 ---- this.preparedQuery = connection.getQueryExecutor().createParameterizedQuery(parsed_sql); this.preparedParameters = preparedQuery.createParameterList(); + testReturn = new int[preparedParameters.getParameterCount()+1]; + functionReturnType = new int[preparedParameters.getParameterCount()+1]; + resultsettype = rsType; concurrency = rsConcurrency; } *************** *** 303,314 **** if (!rs.next()) throw new PSQLException ("postgresql.call.noreturnval", PSQLState.NO_DATA); ! callResult = rs.getObject(1); int columnType = rs.getMetaData().getColumnType(1); ! if (columnType != functionReturnType) throw new PSQLException ("postgresql.call.wrongrtntype", PSQLState.DATA_TYPE_MISMATCH, null, new Object[]{ "java.sql.Types=" + columnType, "java.sql.Types=" + functionReturnType }); rs.close(); result = null; --- 307,326 ---- if (!rs.next()) throw new PSQLException ("postgresql.call.noreturnval", PSQLState.NO_DATA); ! // figure out how many columns ! int cols = rs.getMetaData().getColumnCount(); ! callResult = new Object[cols]; ! ! // move them into the result set ! for ( int i=0; i < cols; i++) ! { ! callResult[i] = rs.getObject(i+1); int columnType = rs.getMetaData().getColumnType(1); ! if (columnType != functionReturnType[i]) throw new PSQLException ("postgresql.call.wrongrtntype", PSQLState.DATA_TYPE_MISMATCH, null, new Object[]{ "java.sql.Types=" + columnType, "java.sql.Types=" + functionReturnType }); + } rs.close(); result = null; *************** *** 375,380 **** --- 387,393 ---- } private boolean isClosed = false; + private int lastIndex = 0; /* * getUpdateCount returns the current result as an update count, *************** *** 1556,1576 **** public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { checkClosed(); if (parameterIndex != 1) throw new PSQLException ("postgresql.call.noinout", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL); if (!isFunction) throw new PSQLException ("postgresql.call.procasfunc", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL); // functionReturnType contains the user supplied value to check // testReturn contains a modified version to make it easier to // check the getXXX methods.. ! functionReturnType = sqlType; ! testReturn = sqlType; ! if (functionReturnType == Types.CHAR || ! functionReturnType == Types.LONGVARCHAR) ! testReturn = Types.VARCHAR; ! else if (functionReturnType == Types.FLOAT) ! testReturn = Types.REAL; // changes to streamline later error checking returnTypeSet = true; } --- 1569,1595 ---- public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { checkClosed(); + /* if (parameterIndex != 1) throw new PSQLException ("postgresql.call.noinout", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL); + } + */ + if (!isFunction) throw new PSQLException ("postgresql.call.procasfunc", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL); // functionReturnType contains the user supplied value to check // testReturn contains a modified version to make it easier to // check the getXXX methods.. ! functionReturnType[parameterIndex-1] = sqlType; ! testReturn[parameterIndex-1] = sqlType; ! ! if (functionReturnType[parameterIndex-1] == Types.CHAR || ! functionReturnType[parameterIndex-1] == Types.LONGVARCHAR) ! testReturn[parameterIndex-1] = Types.VARCHAR; ! else if (functionReturnType[parameterIndex-1] == Types.FLOAT) ! testReturn[parameterIndex-1] = Types.REAL; // changes to streamline later error checking ! returnTypeSet = true; } *************** *** 1605,1611 **** public boolean wasNull() throws SQLException { // check to see if the last access threw an exception ! return (callResult == null); } /* --- 1624,1630 ---- public boolean wasNull() throws SQLException { // check to see if the last access threw an exception ! return (callResult[lastIndex-1] == null); } /* *************** *** 1620,1626 **** { checkClosed(); checkIndex (parameterIndex, Types.VARCHAR, "String"); ! return (String)callResult; } --- 1639,1645 ---- { checkClosed(); checkIndex (parameterIndex, Types.VARCHAR, "String"); ! return (String)callResult[parameterIndex-1]; } *************** *** 1637,1643 **** checkIndex (parameterIndex, Types.BIT, "Boolean"); if (callResult == null) return false; ! return ((Boolean)callResult).booleanValue (); } /* --- 1656,1662 ---- checkIndex (parameterIndex, Types.BIT, "Boolean"); if (callResult == null) return false; ! return ((Boolean)callResult[parameterIndex-1]).booleanValue (); } /* *************** *** 1653,1659 **** checkIndex (parameterIndex, Types.TINYINT, "Byte"); if (callResult == null) return 0; ! return (byte)((Integer)callResult).intValue (); } /* --- 1672,1678 ---- checkIndex (parameterIndex, Types.TINYINT, "Byte"); if (callResult == null) return 0; ! return (byte)((Integer)callResult[parameterIndex-1]).intValue (); } /* *************** *** 1669,1675 **** checkIndex (parameterIndex, Types.SMALLINT, "Short"); if (callResult == null) return 0; ! return (short)((Integer)callResult).intValue (); } --- 1688,1694 ---- checkIndex (parameterIndex, Types.SMALLINT, "Short"); if (callResult == null) return 0; ! return (short)((Integer)callResult[parameterIndex-1]).intValue (); } *************** *** 1686,1692 **** checkIndex (parameterIndex, Types.INTEGER, "Int"); if (callResult == null) return 0; ! return ((Integer)callResult).intValue (); } /* --- 1705,1711 ---- checkIndex (parameterIndex, Types.INTEGER, "Int"); if (callResult == null) return 0; ! return ((Integer)callResult[parameterIndex-1]).intValue (); } /* *************** *** 1702,1708 **** checkIndex (parameterIndex, Types.BIGINT, "Long"); if (callResult == null) return 0; ! return ((Long)callResult).longValue (); } /* --- 1721,1727 ---- checkIndex (parameterIndex, Types.BIGINT, "Long"); if (callResult == null) return 0; ! return ((Long)callResult[parameterIndex-1]).longValue (); } /* *************** *** 1718,1724 **** checkIndex (parameterIndex, Types.REAL, "Float"); if (callResult == null) return 0; ! return ((Float)callResult).floatValue (); } /* --- 1737,1743 ---- checkIndex (parameterIndex, Types.REAL, "Float"); if (callResult == null) return 0; ! return ((Float)callResult[parameterIndex-1]).floatValue (); } /* *************** *** 1734,1740 **** checkIndex (parameterIndex, Types.DOUBLE, "Double"); if (callResult == null) return 0; ! return ((Double)callResult).doubleValue (); } /* --- 1753,1759 ---- checkIndex (parameterIndex, Types.DOUBLE, "Double"); if (callResult == null) return 0; ! return ((Double)callResult[parameterIndex-1]).doubleValue (); } /* *************** *** 1753,1759 **** { checkClosed(); checkIndex (parameterIndex, Types.NUMERIC, "BigDecimal"); ! return ((BigDecimal)callResult); } /* --- 1772,1779 ---- { checkClosed(); checkIndex (parameterIndex, Types.NUMERIC, "BigDecimal"); ! setLastIndex(parameterIndex); ! return ((BigDecimal)callResult[parameterIndex-1]); } /* *************** *** 1768,1774 **** { checkClosed(); checkIndex (parameterIndex, Types.VARBINARY, Types.BINARY, "Bytes"); ! return ((byte [])callResult); } --- 1788,1795 ---- { checkClosed(); checkIndex (parameterIndex, Types.VARBINARY, Types.BINARY, "Bytes"); ! setLastIndex(parameterIndex); ! return ((byte [])callResult[parameterIndex-1]); } *************** *** 1783,1789 **** { checkClosed(); checkIndex (parameterIndex, Types.DATE, "Date"); ! return (java.sql.Date)callResult; } /* --- 1804,1811 ---- { checkClosed(); checkIndex (parameterIndex, Types.DATE, "Date"); ! setLastIndex(parameterIndex); ! return (java.sql.Date)callResult[parameterIndex-1]; } /* *************** *** 1797,1803 **** { checkClosed(); checkIndex (parameterIndex, Types.TIME, "Time"); ! return (java.sql.Time)callResult; } /* --- 1819,1826 ---- { checkClosed(); checkIndex (parameterIndex, Types.TIME, "Time"); ! setLastIndex(parameterIndex); ! return (java.sql.Time)callResult[parameterIndex-1]; } /* *************** *** 1812,1818 **** { checkClosed(); checkIndex (parameterIndex, Types.TIMESTAMP, "Timestamp"); ! return (java.sql.Timestamp)callResult; } // getObject returns a Java object for the parameter. --- 1835,1842 ---- { checkClosed(); checkIndex (parameterIndex, Types.TIMESTAMP, "Timestamp"); ! setLastIndex(parameterIndex); ! return (java.sql.Timestamp)callResult[parameterIndex-1]; } // getObject returns a Java object for the parameter. *************** *** 1840,1846 **** { checkClosed(); checkIndex (parameterIndex); ! return callResult; } /* --- 1864,1871 ---- { checkClosed(); checkIndex (parameterIndex); ! setLastIndex(parameterIndex); ! return callResult[parameterIndex-1]; } /* *************** *** 2051,2057 **** throws SQLException { checkIndex (parameterIndex); ! if (type1 != this.testReturn && type2 != this.testReturn) throw new PSQLException("postgresql.call.wrongget", PSQLState.MOST_SPECIFIC_TYPE_DOES_NOT_MATCH, new Object[]{"java.sql.Types=" + testReturn, getName, --- 2076,2082 ---- throws SQLException { checkIndex (parameterIndex); ! if (type1 != this.testReturn[parameterIndex-1] && type2 != this.testReturn[parameterIndex-1]) throw new PSQLException("postgresql.call.wrongget", PSQLState.MOST_SPECIFIC_TYPE_DOES_NOT_MATCH, new Object[]{"java.sql.Types=" + testReturn, getName, *************** *** 2064,2070 **** throws SQLException { checkIndex (parameterIndex); ! if (type != this.testReturn) throw new PSQLException("postgresql.call.wrongget", PSQLState.MOST_SPECIFIC_TYPE_DOES_NOT_MATCH, new Object[]{"java.sql.Types=" + testReturn, getName, --- 2089,2095 ---- throws SQLException { checkIndex (parameterIndex); ! if (type != this.testReturn[parameterIndex-1]) throw new PSQLException("postgresql.call.wrongget", PSQLState.MOST_SPECIFIC_TYPE_DOES_NOT_MATCH, new Object[]{"java.sql.Types=" + testReturn, getName, *************** *** 2079,2087 **** --- 2104,2115 ---- { if (!isFunction) throw new PSQLException("postgresql.call.noreturntype", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL); + /* if (parameterIndex != 1) throw new PSQLException("postgresql.call.noinout", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL); } + */ + } public void setPrepareThreshold(int newThreshold) throws SQLException { checkClosed(); *************** *** 2630,2641 **** { throw Driver.notImplemented(); } ! public java.math.BigDecimal getBigDecimal(int parameterIndex) throws SQLException { checkClosed(); checkIndex (parameterIndex, Types.NUMERIC, "BigDecimal"); ! return ((BigDecimal)callResult); } public Blob getBlob(int i) throws SQLException --- 2658,2673 ---- { throw Driver.notImplemented(); } ! private void setLastIndex(int index) ! { ! lastIndex = index; ! } public java.math.BigDecimal getBigDecimal(int parameterIndex) throws SQLException { checkClosed(); checkIndex (parameterIndex, Types.NUMERIC, "BigDecimal"); ! setLastIndex(parameterIndex); ! return ((BigDecimal)callResult[parameterIndex-1]); } public Blob getBlob(int i) throws SQLException *************** *** 2660,2665 **** --- 2692,2698 ---- public java.sql.Date getDate(int i, java.util.Calendar cal) throws SQLException { + setLastIndex(i); if (cal == null) return getDate(i); java.util.Date tmp = getDate(i); *************** *** 2671,2676 **** --- 2704,2710 ---- public Time getTime(int i, java.util.Calendar cal) throws SQLException { + setLastIndex(i); if (cal == null) return getTime(i); java.util.Date tmp = getTime(i); *************** *** 2682,2687 **** --- 2716,2722 ---- public Timestamp getTimestamp(int i, java.util.Calendar cal) throws SQLException { + setLastIndex(i); if (cal == null) return getTimestamp(i); java.util.Date tmp = getTimestamp(i); Index: org/postgresql/test/TestUtil.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/TestUtil.java,v retrieving revision 1.11 diff -c -B -b -r1.11 TestUtil.java *** org/postgresql/test/TestUtil.java 16 Jul 2004 06:14:28 -0000 1.11 --- org/postgresql/test/TestUtil.java 1 Sep 2004 01:19:25 -0000 *************** *** 83,90 **** props.setProperty("password",getPassword()); // this allows loads the class. ! // org.postgresql.Driver.setLogLevel(org.postgresql.Driver.DEBUG); ! // java.sql.DriverManager.setLogWriter(new java.io.PrintWriter(System.err)); return java.sql.DriverManager.getConnection(getURL(), props); } --- 83,92 ---- props.setProperty("password",getPassword()); // this allows loads the class. ! //org.postgresql.Driver.setLogLevel(org.postgresql.Driver.DEBUG); ! //java.sql.DriverManager.setLogWriter(new java.io.PrintWriter(System.err)); ! String url = getURL(); ! return java.sql.DriverManager.getConnection(getURL(), props); } Index: org/postgresql/test/jdbc2/CallableStmtTest.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/CallableStmtTest.java,v retrieving revision 1.5 diff -c -B -b -r1.5 CallableStmtTest.java *** org/postgresql/test/jdbc2/CallableStmtTest.java 29 May 2003 04:39:48 -0000 1.5 --- org/postgresql/test/jdbc2/CallableStmtTest.java 1 Sep 2004 01:19:25 -0000 *************** *** 38,43 **** --- 38,51 ---- stmt.execute ("CREATE OR REPLACE FUNCTION testspg__getNumeric (numeric) " + "RETURNS numeric AS ' DECLARE inString alias for $1; " + "begin return 42; end; ' LANGUAGE 'plpgsql';"); + stmt.execute("create temp table numeric_tab (MAX_VAL NUMERIC(30,15), MIN_VAL NUMERIC(30,15), NULL_VAL NUMERIC(30,15) NULL)"); + stmt.execute("insert into numeric_tab values ( 999999999999999,0.000000000000001, null)"); + stmt.execute("create type Numeric_Proc_RetType as(it1 numeric(30,15),it2 numeric(30,15),it3 numeric(30,15));"); + boolean ret = stmt.execute("create function " + + "Numeric_Proc(numeric(30,15),numeric(30,15),numeric(30,15)) returns Numeric_Proc_RetType as " + + "'declare work_ret record; begin select * into work_ret from Numeric_Tab; return work_ret; end;' " + + "language 'plpgsql';"); + int x = stmt.getUpdateCount(); stmt.close (); } *************** *** 48,53 **** --- 56,63 ---- stmt.execute ("drop FUNCTION testspg__getDouble (float);"); stmt.execute ("drop FUNCTION testspg__getInt (int);"); stmt.execute ("drop FUNCTION testspg__getNumeric (numeric);"); + stmt.execute("drop function Numeric_Proc(numeric, numeric, numeric)"); + stmt.execute("drop type Numeric_Proc_RetType"); TestUtil.closeDB(con); } *************** *** 58,63 **** --- 68,103 ---- //testGetString (); //} + public void testNumeric() throws Throwable + { + CallableStatement call = con.prepareCall( func + "Numeric_Proc(?,?,?) }" ) ; + + call.registerOutParameter(1,Types.NUMERIC); + call.registerOutParameter(2,Types.NUMERIC); + call.registerOutParameter(3,Types.NUMERIC); + + call.setBigDecimal(2,new java.math.BigDecimal(1)); + call.setBigDecimal(3,new java.math.BigDecimal(2)); + call.setBigDecimal(4,new java.math.BigDecimal(3)); + + call.execute(); + java.math.BigDecimal ret = call.getBigDecimal(1); + assertTrue ("correct return from getNumeric () should be 999999999999999.000000000000000 but returned " + ret.toString(), + ret.equals (new java.math.BigDecimal("999999999999999.000000000000000"))); + + ret=call.getBigDecimal(2); + assertTrue ("correct return from getNumeric ()", + ret.equals (new java.math.BigDecimal("0.000000000000001"))); + try + { + ret = call.getBigDecimal(3); + }catch(NullPointerException ex) + { + assertTrue("This should be null",call.wasNull()); + } + + + } public void testGetDouble () throws Throwable { CallableStatement call = con.prepareCall (func + pkgName + "getDouble (?) }"); Index: org/postgresql/test/jdbc2/DateTest.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/DateTest.java,v retrieving revision 1.7 diff -c -B -b -r1.7 DateTest.java *** org/postgresql/test/jdbc2/DateTest.java 29 Nov 2003 22:41:23 -0000 1.7 --- org/postgresql/test/jdbc2/DateTest.java 1 Sep 2004 01:19:25 -0000 *************** *** 59,69 **** assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1971-12-15'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1984-12-03'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'2000-01-01'"))); /* dateTest() contains all of the tests */ dateTest(); ! assertEquals(16, stmt.executeUpdate("DELETE FROM " + "testdate")); stmt.close(); } catch (Exception ex) --- 59,70 ---- assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1971-12-15'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1984-12-03'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'2000-01-01'"))); + assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'2000-1-1'"))); /* dateTest() contains all of the tests */ dateTest(); ! assertEquals(17, stmt.executeUpdate("DELETE FROM " + "testdate")); stmt.close(); } catch (Exception ex) *************** *** 130,135 **** --- 131,141 ---- ps.setObject(1, java.sql.Date.valueOf("2000-1-1"), java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); + // try single digit month and day + ps.setObject(1,"2000-1-1",java.sql.Types.DATE); + assertEquals(1, ps.executeUpdate()); + + ps.setObject(1, "1944-4-04-01", java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); *************** *** 150,156 **** dateTest(); testingSetDate = false; ! assertEquals(20, stmt.executeUpdate("DELETE FROM testdate")); stmt.close(); } catch (Exception ex) --- 156,162 ---- dateTest(); testingSetDate = false; ! assertEquals(21, stmt.executeUpdate("DELETE FROM testdate")); stmt.close(); } catch (Exception ex) *************** *** 251,256 **** --- 257,268 ---- assertNotNull(d); assertEquals(d, makeDate(2000, 1, 1)); + assertTrue(rs.next()); + d = rs.getDate(1); + assertNotNull(d); + assertEquals(d, makeDate(2000, 1, 1)); + + //now we have to convert the date, cause I fed it a timezone. IF it used it. hence the check if (testingSetDate) { *************** *** 306,312 **** tmpDate.setTime(tmpDate.getTime() + Dateoffset + localoffset); assertEquals(d, makeDate(tmpDate.getYear() + 1900, tmpDate.getMonth()+1, tmpDate.getDate())); } - assertTrue(!rs.next()); rs.close(); --- 318,323 ---- --=-FkIQ+pOPchQWT4065nbZ--