KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > protocol > PreparedStatementSerialization


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
4  * Contact: sequoia@continuent.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Initial developer(s): Emmanuel Cecchet.
19  * Contributor(s): ______________________.
20  */

21
22 package org.continuent.sequoia.controller.protocol;
23
24 import java.io.ByteArrayInputStream JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.io.ObjectInputStream JavaDoc;
27 import java.math.BigDecimal JavaDoc;
28 import java.net.MalformedURLException JavaDoc;
29 import java.net.URL JavaDoc;
30 import java.sql.CallableStatement JavaDoc;
31 import java.sql.Date JavaDoc;
32 import java.sql.SQLException JavaDoc;
33 import java.sql.Time JavaDoc;
34 import java.sql.Timestamp JavaDoc;
35 import java.text.ParseException JavaDoc;
36 import java.text.SimpleDateFormat JavaDoc;
37
38 import org.continuent.sequoia.common.protocol.ByteArrayBlob;
39 import org.continuent.sequoia.common.protocol.PreparedStatementSerializationConstants;
40 import org.continuent.sequoia.common.protocol.StringClob;
41 import org.continuent.sequoia.common.sql.filters.AbstractBlobFilter;
42 import org.continuent.sequoia.common.util.Strings;
43 import org.continuent.sequoia.controller.requests.StoredProcedure;
44
45 /**
46  * This class contains the data used to serialize PreparedStatement.
47  *
48  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
49  * @version 1.0
50  */

51 public final class PreparedStatementSerialization
52 {
53
54   /**
55    * Static method to initialize a backend PreparedStatement by calling the
56    * appropriate setXXX methods on the request skeleton. Has to extract the
57    * tagged and inlined parameters from the sql String beforehand. Used by the
58    * controller.
59    *
60    * @param parameters encoded parameters to set
61    * @param backendPS the preparedStatement to set
62    * @throws SQLException if an error occurs
63    * @see org.continuent.sequoia.driver.PreparedStatement#setParameterWithTag(int,
64    * String, String)
65    */

66   public static void setPreparedStatement(String JavaDoc parameters,
67       java.sql.PreparedStatement JavaDoc backendPS) throws SQLException JavaDoc
68   {
69     int i = 0;
70     int paramIdx = 0;
71
72     // Set all parameters
73
while ((i = parameters.indexOf(PreparedStatementSerializationConstants.START_PARAM_TAG, i)) > -1)
74     {
75       paramIdx++;
76
77       int typeStart = i + PreparedStatementSerializationConstants.START_PARAM_TAG.length();
78
79       // Here we assume that all tags have the same length as the boolean tag.
80
String JavaDoc paramType = parameters.substring(typeStart, typeStart
81           + PreparedStatementSerializationConstants.BOOLEAN_TAG.length());
82       String JavaDoc paramValue = parameters.substring(
83           typeStart + PreparedStatementSerializationConstants.BOOLEAN_TAG.length(), parameters
84               .indexOf(PreparedStatementSerializationConstants.END_PARAM_TAG, i));
85       paramValue = Strings.replace(paramValue, PreparedStatementSerializationConstants.TAG_MARKER_ESCAPE, PreparedStatementSerializationConstants.TAG_MARKER);
86
87       if (!performCallOnPreparedStatement(backendPS, paramIdx, paramType,
88           paramValue))
89       {
90         // invalid parameter, we want to be able to store strings like
91
// <?xml version="1.0" encoding="ISO-8859-1"?>
92
paramIdx--;
93       }
94       i = typeStart + paramValue.length();
95     }
96   }
97
98   /**
99    * Static method to initialize a backend PreparedStatement by calling the
100    * appropriate setXXX methods on the request skeleton. Has to extract the
101    * tagged and inlined parameters from the sql String beforehand. Used by the
102    * controller.
103    *
104    * @param parameters encoded parameters to set
105    * @param cs the CallableStatement to set
106    * @param proc the StoredProcedure that is called
107    * @throws SQLException if an error occurs
108    * @see org.continuent.sequoia.driver.PreparedStatement#setParameterWithTag(int,
109    * String, String)
110    * @see org.continuent.sequoia.driver.CallableStatement#setNamedParameterWithTag(String,
111    * String, String)
112    */

113   public static void setCallableStatement(String JavaDoc parameters,
114       CallableStatement JavaDoc cs, StoredProcedure proc) throws SQLException JavaDoc
115   {
116     int i = 0;
117     int paramIdx = 0;
118
119     // Set all parameters
120
while ((i = parameters.indexOf(PreparedStatementSerializationConstants.START_PARAM_TAG, i)) > -1)
121     {
122       paramIdx++;
123
124       int typeStart = i + PreparedStatementSerializationConstants.START_PARAM_TAG.length();
125
126       // Here we assume that all tags have the same length as the boolean tag.
127
String JavaDoc paramType = parameters.substring(typeStart, typeStart
128           + PreparedStatementSerializationConstants.BOOLEAN_TAG.length());
129       String JavaDoc paramValue = parameters.substring(
130           typeStart + PreparedStatementSerializationConstants.BOOLEAN_TAG.length(), parameters
131               .indexOf(PreparedStatementSerializationConstants.END_PARAM_TAG, i));
132       paramValue = Strings.replace(paramValue, PreparedStatementSerializationConstants.TAG_MARKER_ESCAPE, PreparedStatementSerializationConstants.TAG_MARKER);
133
134       if (!performCallOnPreparedStatement(cs, paramIdx, paramType, paramValue))
135       {
136         // Not a standard PreparedStatement call, let's check for OUT paramters
137
// and named parameters
138
int comma = paramValue.indexOf(",");
139         String JavaDoc paramName = paramValue.substring(0, comma);
140         if (setOutParameter(paramName, paramType, paramValue
141             .substring(comma + 1), cs, proc))
142         {
143           // Success, this was an out parameter
144
// else try a named parameter
145
}
146         else if (paramType.equals(PreparedStatementSerializationConstants.NAMED_PARAMETER_TAG))
147         {
148           // Value is composed of: paramName,paramTypeparamValue
149
paramType = paramValue.substring(comma + 1, comma + 1
150               + PreparedStatementSerializationConstants.BOOLEAN_TAG.length());
151           paramValue = paramValue.substring(comma + 1 + PreparedStatementSerializationConstants.BOOLEAN_TAG.length());
152           paramValue = Strings.replace(paramValue, PreparedStatementSerializationConstants.TAG_MARKER_ESCAPE,
153               PreparedStatementSerializationConstants.TAG_MARKER);
154
155           proc.setNamedParameterName(paramName);
156           setNamedParameterOnCallableStatement(cs, paramName, paramType,
157               paramValue);
158         }
159         else
160         {
161           // invalid parameter, we want to be able to store strings like
162
// <?xml version="1.0" encoding="ISO-8859-1"?>
163
paramIdx--;
164         }
165       }
166       i = typeStart;
167     }
168   }
169
170   private static boolean setOutParameter(String JavaDoc paramName, String JavaDoc paramType,
171       String JavaDoc paramValue, CallableStatement JavaDoc cs, StoredProcedure proc)
172       throws SQLException JavaDoc
173   {
174     if (paramType.equals(PreparedStatementSerializationConstants.REGISTER_OUT_PARAMETER))
175     {
176       int sqlType = Integer.valueOf(paramValue).intValue();
177       try
178       {
179         int paramIdx = Integer.parseInt(paramName);
180         proc.setOutParameterIndex(paramIdx);
181         cs.registerOutParameter(paramIdx, sqlType);
182       }
183       catch (NumberFormatException JavaDoc e)
184       { // This is a real named parameter
185
proc.setNamedParameterName(paramName);
186         cs.registerOutParameter(paramName, sqlType);
187       }
188       return true;
189     }
190     else if (paramType.equals(PreparedStatementSerializationConstants.REGISTER_OUT_PARAMETER_WITH_SCALE))
191     {
192       int comma = paramValue.indexOf(',');
193       int sqlType = Integer.valueOf(paramValue.substring(0, comma)).intValue();
194       int scale = Integer.valueOf(paramValue.substring(comma + 1)).intValue();
195       try
196       {
197         int paramIdx = Integer.parseInt(paramName);
198         proc.setOutParameterIndex(paramIdx);
199         cs.registerOutParameter(paramIdx, sqlType, scale);
200       }
201       catch (NumberFormatException JavaDoc e)
202       { // This is a real named parameter
203
proc.setNamedParameterName(paramName);
204         cs.registerOutParameter(paramName, sqlType, scale);
205       }
206       return true;
207     }
208     else if (paramType.equals(PreparedStatementSerializationConstants.REGISTER_OUT_PARAMETER_WITH_NAME))
209     {
210       int comma = paramValue.indexOf(',');
211       int sqlType = Integer.valueOf(paramValue.substring(0, comma)).intValue();
212       try
213       {
214         int paramIdx = Integer.parseInt(paramName);
215         proc.setOutParameterIndex(paramIdx);
216         cs.registerOutParameter(paramIdx, sqlType, paramValue
217             .substring(comma + 1));
218       }
219       catch (NumberFormatException JavaDoc e)
220       { // This is a real named parameter
221
proc.setNamedParameterName(paramName);
222         cs.registerOutParameter(paramName, sqlType, paramValue
223             .substring(comma + 1));
224       }
225       return true;
226     }
227     else
228       return false;
229   }
230
231   private static void setNamedParameterOnCallableStatement(
232       CallableStatement JavaDoc cs, String JavaDoc paramName, String JavaDoc paramType,
233       String JavaDoc paramValue) throws SQLException JavaDoc
234   {
235     // Test tags in alphabetical order (to make the code easier to read)
236
if (paramType.equals(PreparedStatementSerializationConstants.BIG_DECIMAL_TAG))
237     {
238       BigDecimal JavaDoc t = null;
239       if (!paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
240         t = new BigDecimal JavaDoc(paramValue);
241       cs.setBigDecimal(paramName, t);
242     }
243     else if (paramType.equals(PreparedStatementSerializationConstants.BOOLEAN_TAG))
244       cs.setBoolean(paramName, Boolean.valueOf(paramValue).booleanValue());
245     else if (paramType.equals(PreparedStatementSerializationConstants.BYTE_TAG))
246     {
247       byte t = new Integer JavaDoc(paramValue).byteValue();
248       cs.setByte(paramName, t);
249     }
250     else if (paramType.equals(PreparedStatementSerializationConstants.BYTES_TAG))
251     {
252       /**
253        * encoded by the driver at {@link #setBytes(int, byte[])}in order to
254        * inline it in the request (no database encoding here).
255        */

256       byte[] t = AbstractBlobFilter.getDefaultBlobFilter().decode(paramValue);
257       cs.setBytes(paramName, t);
258     }
259     else if (paramType.equals(PreparedStatementSerializationConstants.DATE_TAG))
260     {
261       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
262         cs.setDate(paramName, null);
263       else
264         try
265         {
266           SimpleDateFormat JavaDoc sdf = new SimpleDateFormat JavaDoc("yyyy-MM-dd");
267           Date JavaDoc t = new Date JavaDoc(sdf.parse(paramValue).getTime());
268           cs.setDate(paramName, t);
269         }
270         catch (ParseException JavaDoc p)
271         {
272           cs.setDate(paramName, null);
273           throw new SQLException JavaDoc("Couldn't format date!!!");
274         }
275     }
276     else if (paramType.equals(PreparedStatementSerializationConstants.DOUBLE_TAG))
277       cs.setDouble(paramName, Double.valueOf(paramValue).doubleValue());
278     else if (paramType.equals(PreparedStatementSerializationConstants.FLOAT_TAG))
279       cs.setFloat(paramName, Float.valueOf(paramValue).floatValue());
280     else if (paramType.equals(PreparedStatementSerializationConstants.INTEGER_TAG))
281       cs.setInt(paramName, Integer.valueOf(paramValue).intValue());
282     else if (paramType.equals(PreparedStatementSerializationConstants.LONG_TAG))
283       cs.setLong(paramName, Long.valueOf(paramValue).longValue());
284     else if (paramType.equals(PreparedStatementSerializationConstants.NULL_VALUE))
285       cs.setNull(paramName, Integer.valueOf(paramValue).intValue());
286     else if (paramType.equals(PreparedStatementSerializationConstants.OBJECT_TAG))
287     {
288       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
289         cs.setObject(paramName, null);
290       else
291       {
292         final String JavaDoc commonMsg = "Failed to deserialize object parameter of setObject()";
293         Object JavaDoc obj;
294         try
295         {
296           byte[] decoded = AbstractBlobFilter.getDefaultBlobFilter().decode(
297               paramValue);
298           obj = new ObjectInputStream JavaDoc(new ByteArrayInputStream JavaDoc(decoded))
299               .readObject();
300         }
301         catch (ClassNotFoundException JavaDoc cnfe)
302         {
303           throw (SQLException JavaDoc) new SQLException JavaDoc(commonMsg
304               + ", class not found on controller").initCause(cnfe);
305         }
306         catch (IOException JavaDoc ioe) // like for instance invalid stream header
307
{
308           throw (SQLException JavaDoc) new SQLException JavaDoc(commonMsg + ", I/O exception")
309               .initCause(ioe);
310         }
311         cs.setObject(paramName, obj);
312       }
313     }
314     else if (paramType.equals(PreparedStatementSerializationConstants.SHORT_TAG))
315     {
316       short t = new Integer JavaDoc(paramValue).shortValue();
317       cs.setShort(paramName, t);
318     }
319     else if (paramType.equals(PreparedStatementSerializationConstants.STRING_TAG))
320     {
321       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
322         cs.setString(paramName, null);
323       else
324         cs.setString(paramName, paramValue);
325     }
326     else if (paramType.equals(PreparedStatementSerializationConstants.NULL_STRING_TAG))
327     {
328       cs.setString(paramName, null);
329     }
330     else if (paramType.equals(PreparedStatementSerializationConstants.TIME_TAG))
331     {
332       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
333         cs.setTime(paramName, null);
334       else
335         try
336         {
337           SimpleDateFormat JavaDoc sdf = new SimpleDateFormat JavaDoc("HH:mm:ss");
338           Time JavaDoc t = new Time JavaDoc(sdf.parse(paramValue).getTime());
339           cs.setTime(paramName, t);
340         }
341         catch (ParseException JavaDoc p)
342         {
343           cs.setTime(paramName, null);
344           throw new SQLException JavaDoc("Couldn't format time!!!");
345         }
346     }
347     else if (paramType.equals(PreparedStatementSerializationConstants.TIMESTAMP_TAG))
348     {
349       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
350         cs.setTimestamp(paramName, null);
351       else
352         try
353         {
354           SimpleDateFormat JavaDoc sdf = new SimpleDateFormat JavaDoc("yyyy-MM-dd HH:mm:ss.S");
355           Timestamp JavaDoc t = new Timestamp JavaDoc(sdf.parse(paramValue).getTime());
356           cs.setTimestamp(paramName, t);
357         }
358         catch (ParseException JavaDoc p)
359         {
360           cs.setTimestamp(paramName, null);
361           throw new SQLException JavaDoc("Couldn't format timestamp!!!");
362         }
363     }
364     else if (paramType.equals(PreparedStatementSerializationConstants.URL_TAG))
365     {
366       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
367         cs.setURL(paramName, null);
368       else
369         try
370         {
371           cs.setURL(paramName, new URL JavaDoc(paramValue));
372         }
373         catch (MalformedURLException JavaDoc e)
374         {
375           throw new SQLException JavaDoc("Unable to create URL " + paramValue + " ("
376               + e + ")");
377         }
378     }
379     else
380     {
381       throw new SQLException JavaDoc("Unsupported named parameter type: " + paramType);
382     }
383   }
384
385   private static boolean performCallOnPreparedStatement(
386       java.sql.PreparedStatement JavaDoc backendPS, int paramIdx, String JavaDoc paramType,
387       String JavaDoc paramValue) throws SQLException JavaDoc
388   {
389     // Test tags in alphabetical order (to make the code easier to read)
390
if (paramType.equals(PreparedStatementSerializationConstants.BIG_DECIMAL_TAG))
391     {
392       BigDecimal JavaDoc t = null;
393       if (!paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
394         t = new BigDecimal JavaDoc(paramValue);
395       backendPS.setBigDecimal(paramIdx, t);
396     }
397     else if (paramType.equals(PreparedStatementSerializationConstants.BOOLEAN_TAG))
398       backendPS
399           .setBoolean(paramIdx, Boolean.valueOf(paramValue).booleanValue());
400     else if (paramType.equals(PreparedStatementSerializationConstants.BYTE_TAG))
401     {
402       byte t = new Integer JavaDoc(paramValue).byteValue();
403       backendPS.setByte(paramIdx, t);
404     }
405     else if (paramType.equals(PreparedStatementSerializationConstants.BYTES_TAG))
406     {
407       /**
408        * encoded by the driver at {@link #setBytes(int, byte[])}in order to
409        * inline it in the request (no database encoding here).
410        */

411       byte[] t = AbstractBlobFilter.getDefaultBlobFilter().decode(paramValue);
412       backendPS.setBytes(paramIdx, t);
413     }
414     else if (paramType.equals(PreparedStatementSerializationConstants.BLOB_TAG))
415     {
416       ByteArrayBlob b = null;
417       // encoded by the driver at {@link #setBlob(int, java.sql.Blob)}
418
if (!paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
419         b = new ByteArrayBlob(AbstractBlobFilter.getDefaultBlobFilter().decode(
420             paramValue));
421       backendPS.setBlob(paramIdx, b);
422     }
423     else if (paramType.equals(PreparedStatementSerializationConstants.CLOB_TAG))
424     {
425       StringClob c = null;
426       if (!paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
427         c = new StringClob(paramValue);
428       backendPS.setClob(paramIdx, c);
429     }
430     else if (paramType.equals(PreparedStatementSerializationConstants.DATE_TAG))
431     {
432       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
433         backendPS.setDate(paramIdx, null);
434       else
435         try
436         {
437           SimpleDateFormat JavaDoc sdf = new SimpleDateFormat JavaDoc("yyyy-MM-dd");
438           Date JavaDoc t = new Date JavaDoc(sdf.parse(paramValue).getTime());
439           backendPS.setDate(paramIdx, t);
440         }
441         catch (ParseException JavaDoc p)
442         {
443           backendPS.setDate(paramIdx, null);
444           throw new SQLException JavaDoc("Couldn't format date!!!");
445         }
446     }
447     else if (paramType.equals(PreparedStatementSerializationConstants.DOUBLE_TAG))
448       backendPS.setDouble(paramIdx, Double.valueOf(paramValue).doubleValue());
449     else if (paramType.equals(PreparedStatementSerializationConstants.FLOAT_TAG))
450       backendPS.setFloat(paramIdx, Float.valueOf(paramValue).floatValue());
451     else if (paramType.equals(PreparedStatementSerializationConstants.INTEGER_TAG))
452       backendPS.setInt(paramIdx, Integer.valueOf(paramValue).intValue());
453     else if (paramType.equals(PreparedStatementSerializationConstants.LONG_TAG))
454       backendPS.setLong(paramIdx, Long.valueOf(paramValue).longValue());
455     else if (paramType.equals(PreparedStatementSerializationConstants.NULL_VALUE))
456       backendPS.setNull(paramIdx, Integer.valueOf(paramValue).intValue());
457     else if (paramType.equals(PreparedStatementSerializationConstants.OBJECT_TAG))
458     {
459       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
460         backendPS.setObject(paramIdx, null);
461       else
462       {
463         final String JavaDoc commonMsg = "Failed to deserialize object parameter of setObject()";
464         Object JavaDoc obj;
465         try
466         {
467           byte[] decoded = AbstractBlobFilter.getDefaultBlobFilter().decode(
468               paramValue);
469           obj = new ObjectInputStream JavaDoc(new ByteArrayInputStream JavaDoc(decoded))
470               .readObject();
471         }
472         catch (ClassNotFoundException JavaDoc cnfe)
473         {
474           throw (SQLException JavaDoc) new SQLException JavaDoc(commonMsg
475               + ", class not found on controller").initCause(cnfe);
476         }
477         catch (IOException JavaDoc ioe) // like for instance invalid stream header
478
{
479           throw (SQLException JavaDoc) new SQLException JavaDoc(commonMsg + ", I/O exception")
480               .initCause(ioe);
481         }
482         backendPS.setObject(paramIdx, obj);
483       }
484     }
485     else if (paramType.equals(PreparedStatementSerializationConstants.REF_TAG))
486     {
487       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
488         backendPS.setRef(paramIdx, null);
489       else
490         throw new SQLException JavaDoc("Ref type not supported");
491     }
492     else if (paramType.equals(PreparedStatementSerializationConstants.SHORT_TAG))
493     {
494       short t = new Integer JavaDoc(paramValue).shortValue();
495       backendPS.setShort(paramIdx, t);
496     }
497     else if (paramType.equals(PreparedStatementSerializationConstants.STRING_TAG))
498     {
499       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
500         backendPS.setString(paramIdx, null);
501       else
502         backendPS.setString(paramIdx, paramValue);
503     }
504     else if (paramType.equals(PreparedStatementSerializationConstants.NULL_STRING_TAG))
505     {
506       backendPS.setString(paramIdx, null);
507     }
508     else if (paramType.equals(PreparedStatementSerializationConstants.TIME_TAG))
509     {
510       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
511         backendPS.setTime(paramIdx, null);
512       else
513         try
514         {
515           SimpleDateFormat JavaDoc sdf = new SimpleDateFormat JavaDoc("HH:mm:ss");
516           Time JavaDoc t = new Time JavaDoc(sdf.parse(paramValue).getTime());
517           backendPS.setTime(paramIdx, t);
518         }
519         catch (ParseException JavaDoc p)
520         {
521           backendPS.setTime(paramIdx, null);
522           throw new SQLException JavaDoc("Couldn't format time!!!");
523         }
524     }
525     else if (paramType.equals(PreparedStatementSerializationConstants.TIMESTAMP_TAG))
526     {
527       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
528         backendPS.setTimestamp(paramIdx, null);
529       else
530         try
531         {
532           SimpleDateFormat JavaDoc sdf = new SimpleDateFormat JavaDoc("yyyy-MM-dd HH:mm:ss.S");
533           Timestamp JavaDoc t = new Timestamp JavaDoc(sdf.parse(paramValue).getTime());
534           backendPS.setTimestamp(paramIdx, t);
535         }
536         catch (ParseException JavaDoc p)
537         {
538           backendPS.setTimestamp(paramIdx, null);
539           throw new SQLException JavaDoc("Couldn't format timestamp!!!");
540         }
541     }
542     else if (paramType.equals(PreparedStatementSerializationConstants.URL_TAG))
543     {
544       if (paramValue.equals(PreparedStatementSerializationConstants.NULL_VALUE))
545         backendPS.setURL(paramIdx, null);
546       else
547         try
548         {
549           backendPS.setURL(paramIdx, new URL JavaDoc(paramValue));
550         }
551         catch (MalformedURLException JavaDoc e)
552         {
553           throw new SQLException JavaDoc("Unable to create URL " + paramValue + " ("
554               + e + ")");
555         }
556     }
557     else if (paramType.equals(PreparedStatementSerializationConstants.CS_PARAM_TAG))
558       return true; // ignore, will be treated in the named parameters
559
else
560       return false;
561
562     return true;
563   }
564
565 }
566
Popular Tags