@@ -65,14 +65,6 @@ public PreparedStatement(Connection connection, String sql) throws SQLException
65
65
this .sql = sql ;
66
66
this .connection = connection ;
67
67
68
- // might just as well create it here, so we don't take the hit later
69
-
70
- SimpleDateFormat df = new SimpleDateFormat ("''yyyy-MM-dd''" );
71
- tl_df .set (df );
72
-
73
- df = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss" );
74
- tl_tsdf .set (df );
75
-
76
68
for (i = 0 ; i < sql .length (); ++i )
77
69
{
78
70
int c = sql .charAt (i );
@@ -95,17 +87,6 @@ public PreparedStatement(Connection connection, String sql) throws SQLException
95
87
templateStrings [i ] = (String )v .elementAt (i );
96
88
}
97
89
98
- /**
99
- * New in 7.1 - overides Statement.close() to dispose of a few local objects
100
- */
101
- public void close () throws SQLException
102
- {
103
- // free the ThreadLocal caches
104
- tl_df .set (null );
105
- tl_tsdf .set (null );
106
- super .close ();
107
- }
108
-
109
90
/**
110
91
* A Prepared SQL query is executed and its ResultSet is returned
111
92
*
@@ -343,6 +324,10 @@ public void setBytes(int parameterIndex, byte x[]) throws SQLException
343
324
public void setDate (int parameterIndex , java .sql .Date x ) throws SQLException
344
325
{
345
326
SimpleDateFormat df = (SimpleDateFormat ) tl_df .get ();
327
+ if (df ==null ) {
328
+ df = new SimpleDateFormat ("''yyyy-MM-dd''" );
329
+ tl_df .set (df );
330
+ }
346
331
347
332
set (parameterIndex , df .format (x ));
348
333
@@ -382,6 +367,10 @@ public void setTime(int parameterIndex, Time x) throws SQLException
382
367
public void setTimestamp (int parameterIndex , Timestamp x ) throws SQLException
383
368
{
384
369
SimpleDateFormat df = (SimpleDateFormat ) tl_tsdf .get ();
370
+ if (df ==null ) {
371
+ df = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss" );
372
+ tl_tsdf .set (df );
373
+ }
385
374
df .setTimeZone (TimeZone .getTimeZone ("GMT" ));
386
375
387
376
// Use the shared StringBuffer
0 commit comments