? cloudscape.LOG Index: org/postgresql/errors.properties =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/errors.properties,v retrieving revision 1.21 diff -c -p -c -p -r1.21 errors.properties *** org/postgresql/errors.properties 30 Jun 2003 16:38:30 -0000 1.21 --- org/postgresql/errors.properties 2 Jul 2003 18:26:53 -0000 *************** postgresql.call.wrongrtntype:A CallableS *** 100,102 **** --- 100,105 ---- postgresql.input.fetch.gt0:Fetch size must be a value greater than or equal to 0. postgresql.input.query.gt0:Query Timeout must be a value greater than or equal to 0. postgresql.input.rows.gt0:Maximum number of rows must be a value greater than or equal to 0. + postgresql.format.baddate:The date given: {0} does not match the format required: {1}. + postgresql.format.badtime:The time given: {0} does not match the format required: {1}. + postgresql.format.badtimestamp:The timestamp given {0} does not match the format required: {1}. Index: org/postgresql/jdbc1/AbstractJdbc1Statement.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java,v retrieving revision 1.26 diff -c -p -c -p -r1.26 AbstractJdbc1Statement.java *** org/postgresql/jdbc1/AbstractJdbc1Statement.java 30 Jun 2003 21:10:55 -0000 1.26 --- org/postgresql/jdbc1/AbstractJdbc1Statement.java 2 Jul 2003 18:26:55 -0000 *************** public abstract class AbstractJdbc1State *** 1488,1500 **** setString(parameterIndex, x.toString()); break; case Types.DATE: ! setDate(parameterIndex, (java.sql.Date)x); break; case Types.TIME: ! setTime(parameterIndex, (Time)x); break; case Types.TIMESTAMP: ! setTimestamp(parameterIndex, (Timestamp)x); break; case Types.BIT: if (x instanceof Boolean) --- 1488,1503 ---- setString(parameterIndex, x.toString()); break; case Types.DATE: ! java.sql.Date tmpd = (x instanceof java.util.Date) ? new java.sql.Date(((java.util.Date)x).getTime()) : DateFromString(x.toString()); ! setDate(parameterIndex, tmpd); break; case Types.TIME: ! java.sql.Time tmpt = (x instanceof java.util.Date) ? new java.sql.Time(((java.util.Date)x).getTime()) : TimeFromString(x.toString()); ! setTime(parameterIndex, tmpt); break; case Types.TIMESTAMP: ! java.sql.Timestamp tmpts = (x instanceof java.util.Date) ? new java.sql.Timestamp(((java.util.Date)x).getTime()) : TimestampFromString(x.toString()); ! setTimestamp(parameterIndex, tmpts); break; case Types.BIT: if (x instanceof Boolean) *************** public abstract class AbstractJdbc1State *** 2032,2038 **** return m_useServerPrepare; } ! private static final String PG_TEXT = "text"; private static final String PG_INTEGER = "integer"; private static final String PG_INT2 = "int2"; --- 2035,2148 ---- return m_useServerPrepare; } ! private java.sql.Date DateFromString (String s) throws SQLException ! { ! int timezone = 0; ! long millis = 0; ! long localoffset = 0; ! int timezoneLocation = (s.indexOf('+') == -1) ? s.lastIndexOf("-") : s.indexOf('+'); ! //if the last index of '-' or '+' is past 8. we are guaranteed that it is a timezone marker ! //shortest = yyyy-m-d ! //longest = yyyy-mm-dd ! try ! { ! timezone = (timezoneLocation>7) ? timezoneLocation : s.length(); ! millis = java.sql.Date.valueOf(s.substring(0,timezone)).getTime(); ! } ! catch (Exception e) ! { ! throw new PSQLException("postgresql.format.baddate",s , new String("yyyy-MM-dd[-tz]")); ! } ! timezone = 0; ! if (timezoneLocation>7 && timezoneLocation+3 == s.length()) ! { ! timezone = Integer.parseInt(s.substring(timezoneLocation+1,s.length())); ! localoffset = java.util.Calendar.getInstance().getTimeZone().getOffset(millis); ! if (s.charAt(timezoneLocation)=='+') ! timezone*=-1; ! } ! millis = millis + timezone*60*60*1000 + localoffset; ! return new java.sql.Date(millis); ! } ! ! private java.sql.Time TimeFromString (String s) throws SQLException ! { ! int timezone = 0; ! long millis = 0; ! long localoffset = 0; ! int timezoneLocation = (s.indexOf('+') == -1) ? s.lastIndexOf("-") : s.indexOf('+'); ! //if the index of the last '-' or '+' is greater than 0 that means this time has a timezone. ! //everything earlier than that position, we treat as the time and parse it as such. ! try ! { ! timezone = (timezoneLocation==-1) ? s.length() : timezoneLocation; ! millis = java.sql.Time.valueOf(s.substring(0,timezone)).getTime(); ! } ! catch (Exception e) ! { ! throw new PSQLException("postgresql.format.badtime",s, new String("HH:mm:ss[-tz]")); ! } ! timezone = 0; ! if (timezoneLocation != -1 && timezoneLocation+3 == s.length()) ! { ! timezone = Integer.parseInt(s.substring(timezoneLocation+1,s.length())); ! localoffset = java.util.Calendar.getInstance().getTimeZone().getOffset(millis); ! if (s.charAt(timezoneLocation)=='+') ! timezone*=-1; ! } ! millis = millis + timezone*60*60*1000 + localoffset; ! return new java.sql.Time(millis); ! } ! ! private java.sql.Timestamp TimestampFromString (String s) throws SQLException ! { ! int timezone = 0; ! long millis = 0; ! long localoffset = 0; ! int nanos = s.length(); ! int nanosVal = 0; ! int timezoneLocation = (s.indexOf('+') == -1) ? s.lastIndexOf("-") : s.indexOf('+'); ! int nanospos = s.indexOf("."); ! //if there is a '.', that means there are nanos info, and we take the timestamp up to that point ! //if not, then we check to see if the last +/- (to indicate a timezone) is greater than 8 ! //8 is because the shortest date, will have last '-' at position 7. e.g yyyy-x-x ! try ! { ! if (nanospos != -1) ! timezone = nanospos; ! else if (timezoneLocation > 8) ! timezone = timezoneLocation; ! else ! timezone = s.length(); ! millis = java.sql.Timestamp.valueOf(s.substring(0,timezone)).getTime(); ! } ! catch (Exception e) ! { ! throw new PSQLException("postgresql.format.badtimestamp", s, new String("yyyy-MM-dd HH:mm:ss[.xxxxxx][-tz]")); ! } ! timezone = 0; ! if (nanospos != -1) ! { ! int tmploc = (timezoneLocation > 8) ? timezoneLocation : s.length(); ! nanosVal = Integer.parseInt(s.substring(nanospos+1,tmploc)); ! int diff = 8-((tmploc-1)-(nanospos+1)); ! for (int i=0;i8 && timezoneLocation+3 == s.length()) ! { ! timezone = Integer.parseInt(s.substring(timezoneLocation+1,s.length())); ! localoffset = java.util.Calendar.getInstance().getTimeZone().getOffset(millis); ! if (s.charAt(timezoneLocation)=='+') ! timezone*=-1; ! } ! millis = millis + timezone*60*60*1000 + localoffset; ! java.sql.Timestamp tmpts = new java.sql.Timestamp(millis); ! tmpts.setNanos(nanosVal); ! return tmpts; ! } ! ! private static final String PG_TEXT = "text"; private static final String PG_INTEGER = "integer"; private static final String PG_INT2 = "int2";