1010import postgresql .util .*;
1111
1212/**
13- * $Id: Connection.java,v 1.15 1999/04/11 18:03:00 peter Exp $
13+ * $Id: Connection.java,v 1.16 1999/05/17 22:43:23 peter Exp $
1414 *
1515 * This abstract class is used by postgresql.Driver to open either the JDBC1 or
1616 * JDBC2 versions of the Connection class.
@@ -67,38 +67,6 @@ public abstract class Connection
6767// be across all connections, which could be to different backends.
6868public Hashtable fieldCache =new Hashtable ();
6969
70- /**
71- * This is the current date style of the backend
72- */
73- public int currentDateStyle ;
74-
75- /**
76- * This defines the formats for dates, according to the various date styles.
77- *
78- * <p>There are two strings for each entry. The first is the string to search
79- * for in the datestyle message, and the second the format to use.
80- *
81- * <p>To add a new date style, work out the format. Then with psql running
82- * in the date style you wish to add, type: show datestyle;
83- *
84- * <p>eg:
85- * <br><pre>
86- * => show datestyle;
87- * NOTICE: Datestyle is SQL with European conventions
88- * ^^^^^^^^^^^^^^^^^
89- * </pre>The marked part of the string is the first string below. The second
90- * is your format. If a style (like ISO) ignores the US/European variants,
91- * then you can ignore the "with" part of the string.
92- */
93- protected static final String dateStyles [] = {
94- "Postgres with European" ,"dd-MM-yyyy" ,
95- "Postgres with US" ,"MM-dd-yyyy" ,
96- "ISO" ,"yyyy-MM-dd" ,
97- "SQL with European" ,"dd/MM/yyyy" ,
98- "SQL with US" ,"MM/dd/yyyy" ,
99- "German" ,"dd.MM.yyyy"
100- };
101-
10270// Now handle notices as warnings, so things like "show" now work
10371public SQLWarning firstWarning =null ;
10472
@@ -242,22 +210,24 @@ protected void openConnection(String host, int port, Properties info, String dat
242210throw new SQLException ("Connection failed: " +e .toString ());
243211}
244212
245- // Find out the date style by issuing the SQL: show datestyle
246- // This actually issues a warning, and our own warning handling
247- // code handles this itself.
248- //
249- // Also, this query replaced the NULL query issued to test the
250- // connection.
251- //
213+ // Originally we issued a SHOW DATESTYLE statement to find the databases default
214+ // datestyle. However, this caused some problems with timestamps, so in 6.5, we
215+ // went the way of ODBC, and set the connection to ISO.
216+ //
217+ // This may cause some clients to break when they assume anything other than ISO,
218+ // but then - they should be using the proper methods ;-)
219+ //
220+ //
252221firstWarning =null ;
253- ExecSQL ("show datestyle" );
254-
255- // Initialise object handling
256- initObjectTypes ();
257-
258- // Mark the connection as ok, and cleanup
222+
223+ ExecSQL ("set datestyle to 'ISO'" );
224+
225+ // Initialise object handling
226+ initObjectTypes ();
227+
228+ // Mark the connection as ok, and cleanup
259229firstWarning =null ;
260- PG_STATUS =CONNECTION_OK ;
230+ PG_STATUS =CONNECTION_OK ;
261231 }
262232
263233// These methods used to be in the main Connection implementation. As they
@@ -280,23 +250,18 @@ public void addWarning(String msg)
280250
281251// Now check for some specific messages
282252
253+ // This is obsolete in 6.5, but I've left it in here so if we need to use this
254+ // technique again, we'll know where to place it.
255+ //
283256// This is generated by the SQL "show datestyle"
284- if (msg .startsWith ("NOTICE:" ) &&msg .indexOf ("DateStyle" )>0 ) {
285- // 13 is the length off "DateStyle is "
286- msg =msg .substring (msg .indexOf ("DateStyle is " )+13 );
287-
288- for (int i =0 ;i <dateStyles .length ;i +=2 )
289- if (msg .startsWith (dateStyles [i ]))
290- currentDateStyle =i +1 ;// this is the index of the format
291- }
292- }
293-
294- /**
295- * @return the date format for the current date style of the backend
296- */
297- public String getDateStyle ()
298- {
299- return dateStyles [currentDateStyle ];
257+ //if(msg.startsWith("NOTICE:") && msg.indexOf("DateStyle")>0) {
258+ //// 13 is the length off "DateStyle is "
259+ //msg = msg.substring(msg.indexOf("DateStyle is ")+13);
260+ //
261+ //for(int i=0;i<dateStyles.length;i+=2)
262+ //if(msg.startsWith(dateStyles[i]))
263+ //currentDateStyle=i+1; // this is the index of the format
264+ //}
300265 }
301266
302267/**