Public Member Functions | |
PreparedStatement (Connection connection, String sqlStatement) throws SQLException | |
void | close () throws SQLException |
java.sql.ResultSet | executeQuery () throws SQLException |
int | executeUpdate () throws SQLException |
void | setNull (int parameterIndex, int sqlType) throws SQLException |
void | setBoolean (int parameterIndex, boolean x) throws SQLException |
void | setByte (int parameterIndex, byte x) throws SQLException |
void | setShort (int parameterIndex, short x) throws SQLException |
void | setInt (int parameterIndex, int x) throws SQLException |
void | setLong (int parameterIndex, long x) throws SQLException |
void | setFloat (int parameterIndex, float x) throws SQLException |
void | setDouble (int parameterIndex, double x) throws SQLException |
void | setBigDecimal (int parameterIndex, BigDecimal x) throws SQLException |
void | setString (int parameterIndex, String x) throws SQLException |
void | setBytes (int parameterIndex, byte x[]) throws SQLException |
void | setDate (int parameterIndex, java.sql.Date x) throws SQLException |
void | setTime (int parameterIndex, Time x) throws SQLException |
void | setTimestamp (int parameterIndex, Timestamp x) throws SQLException |
void | setAsciiStream (int parameterIndex, InputStream x, int length) throws SQLException |
void | setUnicodeStream (int parameterIndex, InputStream x, int length) throws SQLException |
void | setBinaryStream (int parameterIndex, InputStream x, int length) throws SQLException |
void | clearParameters () throws SQLException |
void | setObject (int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException |
void | setObject (int parameterIndex, Object x, int targetSqlType) throws SQLException |
void | setObject (int parameterIndex, Object x) throws SQLException |
boolean | execute () throws SQLException |
String | toString () |
void | addBatch () throws SQLException |
java.sql.ResultSetMetaData | getMetaData () throws SQLException |
void | setArray (int i, Array x) throws SQLException |
void | setBlob (int i, java.sql.Blob x) throws SQLException |
void | setCharacterStream (int i, java.io.Reader x, int length) throws SQLException |
void | setClob (int i, java.sql.Clob x) throws SQLException |
void | setNull (int i, int t, String s) throws SQLException |
void | setRef (int i, Ref x) throws SQLException |
void | setDate (int i, java.sql.Date d, java.util.Calendar cal) throws SQLException |
void | setTime (int i, Time t, java.util.Calendar cal) throws SQLException |
void | setTimestamp (int i, Timestamp t, java.util.Calendar cal) throws SQLException |
void | setURL (int parameterIndex, java.net.URL x) throws SQLException |
ParameterMetaData | getParameterMetaData () throws SQLException |
Static Public Member Functions | |
void | setPreparedStatement (String sql, java.sql.PreparedStatement ps) throws SQLException |
Static Public Attributes | |
final String | BYTE_TAG = "b|" |
final String | BYTES_TAG = "B|" |
final String | BLOB_TAG = "c|" |
final String | CLOB_TAG = "C|" |
final String | BOOLEAN_TAG = "0|" |
final String | BIG_DECIMAL_TAG = "1|" |
final String | DATE_TAG = "d|" |
final String | DOUBLE_TAG = "D|" |
final String | FLOAT_TAG = "F|" |
final String | INTEGER_TAG = "I|" |
final String | LONG_TAG = "L|" |
final String | NULL_TAG = "N|" |
final String | OBJECT_TAG = "O|" |
final String | SHORT_TAG = "s|" |
final String | STRING_TAG = "S|" |
final String | TIME_TAG = "t|" |
final String | TIMESTAMP_TAG = "T|" |
Protected Member Functions | |
synchronized String | compileQuery () throws SQLException |
String | doEscapeProcessing (String x) |
void | setGeneratedKeysFlag (int autoGeneratedKeys) |
Protected Attributes | |
String | sql |
PreparedStatement
object. This object can then be used to efficiently execute this statement multiple times. Note: The setXXX methods for setting IN parameter values must specify types that are compatible with the defined SQL type of the input parameter. For instance, if the IN parameter has SQL type Integer, then setInt should be used.
If arbitrary parameter type conversions are required, then the setObject method should be used with a target SQL type.
For instance, this is just a dirty copy/paste from the PostgreSQL driver ! Implementation has to be completly checked and revised.
java.sql.PreparedStatement
Definition at line 75 of file PreparedStatement.java.
|
Constructor. Splits the SQL statement into segments - separated by the arguments. When we rebuild the thing with the arguments, we can substitute the args and join the whole thing together.
Definition at line 130 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.clearParameters(). 00132 { 00133 super(connection); 00134 00135 ArrayList v = new ArrayList(); 00136 int lastParmEnd = 0; 00137 00138 // The following two boolean switches are used to make sure we're not 00139 // counting "?" in either strings or metadata strings. For instance the 00140 // following query: 00141 // select '?' "A ? value" from dual 00142 // doesn't have any parameters. 00143 00144 boolean inString = false; 00145 boolean inMetaString = false; 00146 00147 this.sql = sqlStatement.trim(); 00148 this.connection = connection; 00149 for (int i = 0; i < sql.length(); ++i) 00150 { 00151 if (sql.charAt(i) == '\'') 00152 inString = !inString; 00153 if (sql.charAt(i) == '"') 00154 inMetaString = !inMetaString; 00155 if ((sql.charAt(i) == '?') && (!(inString || inMetaString))) 00156 { 00157 v.add(sql.substring(lastParmEnd, i)); 00158 lastParmEnd = i + 1; 00159 } 00160 } 00161 v.add(sql.substring(lastParmEnd, sql.length())); 00162 00163 int size = v.size(); 00164 templateStrings = new String[size]; 00165 inStrings = new String[size - 1]; 00166 clearParameters(); 00167 00168 for (int i = 0; i < size; ++i) 00169 templateStrings[i] = (String) v.get(i); 00170 }
|
|
This parses the query and adds it to the current batch
Definition at line 969 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.compileQuery(). 00970 { 00971 super.addBatch(compileQuery()); 00972 }
|
|
|
Release objects for garbage collection and call Statement.close().
Reimplemented from org.objectweb.cjdbc.driver.Statement. Definition at line 177 of file PreparedStatement.java. 00178 { 00179 sql = null; 00180 templateStrings = null; 00181 inStrings = null; 00182 00183 super.close(); 00184 }
|
|
Helper - this compiles the SQL query from the various parameters This is identical to toString() except it throws an exception if a parameter is unused.
Definition at line 222 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.addBatch(), org.objectweb.cjdbc.driver.PreparedStatement.execute(), org.objectweb.cjdbc.driver.PreparedStatement.executeQuery(), and org.objectweb.cjdbc.driver.PreparedStatement.executeUpdate(). 00223 { 00224 sbuf.setLength(0); 00225 int i; 00226 00227 for (i = 0; i < inStrings.length; ++i) 00228 { 00229 if (inStrings[i] == null) 00230 throw new SQLException("Parameter " + (i + 1) + " is incorrect"); 00231 sbuf.append(templateStrings[i]).append(inStrings[i]); 00232 } 00233 sbuf.append(templateStrings[inStrings.length]); 00234 return sbuf.toString(); 00235 }
|
|
Escape the input string.
Definition at line 247 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Connection.getEscapeChar(), org.objectweb.cjdbc.driver.Connection.isEscapeBackslash(), and org.objectweb.cjdbc.driver.Connection.isEscapeSingleQuote(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setString(). 00248 { 00249 // use the shared buffer object. Should never clash but this 00250 // makes us thread safe! 00251 synchronized (sbuf) 00252 { 00253 sbuf.setLength(0); 00254 int i; 00255 sbuf.append(connection.getEscapeChar()); 00256 for (i = 0; i < x.length(); ++i) 00257 { 00258 char c = x.charAt(i); 00259 if ((c == '\'' && connection.isEscapeSingleQuote()) 00260 || (c == '\\' && connection.isEscapeBackslash())) 00261 sbuf.append(c); 00262 sbuf.append(c); 00263 } 00264 sbuf.append(connection.getEscapeChar()); 00265 } 00266 return sbuf.toString(); 00267 }
|
|
Some prepared statements return multiple results; the execute method handles these complex statements as well as the simpler form of statements handled by
Definition at line 904 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.compileQuery(), org.objectweb.cjdbc.driver.PreparedStatement.executeQuery(), and org.objectweb.cjdbc.driver.Statement.executeUpdateWithSkeleton(). 00905 { 00906 int start = 0; 00907 try 00908 { 00909 // Ignore any leading parenthesis 00910 while (sql.charAt(start) == '(') 00911 start++; 00912 } 00913 catch (IndexOutOfBoundsException e) 00914 { 00915 // Probably a buggy request, let it go through and let thefollowing code 00916 // to report an accurate error if any. 00917 start = 0; 00918 } 00919 00920 if (sql.regionMatches(true, start, "select", 0, 6) 00921 || (sql.regionMatches(true, start, "{call", 0, 5))) 00922 { 00923 result = executeQuery(sql, compileQuery()); 00924 return true; 00925 } 00926 else 00927 { 00928 updateCount = executeUpdateWithSkeleton(sql, compileQuery()); 00929 return false; 00930 } 00931 }
|
|
A Prepared SQL query is executed and its
Definition at line 194 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.compileQuery(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.execute(), and org.objectweb.cjdbc.driver.DriverResultSet.refreshRow(). 00195 { 00196 return super.executeQuery(sql, compileQuery()); // in Statement class 00197 }
|
|
Execute a SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing such as SQL DDL statements can be executed.
Definition at line 208 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.compileQuery(). Referenced by org.objectweb.cjdbc.driver.DriverResultSet.deleteRow(), org.objectweb.cjdbc.driver.DriverResultSet.insertRow(), and org.objectweb.cjdbc.driver.DriverResultSet.updateRow(). 00209 { 00210 return super.executeUpdateWithSkeleton(sql, compileQuery()); 00211 // in Statement class 00212 }
|
|
Returns the
Definition at line 981 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Statement.getResultSet(). 00982 { 00983 java.sql.ResultSet rs = getResultSet(); 00984 if (rs != null) 00985 return rs.getMetaData(); 00986 00987 // Does anyone really know what this method does? 00988 return null; 00989 }
|
|
Retrieves the number, types and properties of this
Definition at line 1209 of file PreparedStatement.java. 01210 { 01211 throw new NotImplementedException("getParameterMetaData"); 01212 }
|
|
Definition at line 994 of file PreparedStatement.java. 00995 { 00996 throw new NotImplementedException("setArray()"); 00997 }
|
|
When a very large ASCII value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.InputStream. JDBC will read the data from the stream as needed, until it reaches end-of-file. The JDBC driver will do any necessary conversion from ASCII to the database char format. Note: this stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
Definition at line 644 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.setBinaryStream(). 00646 { 00647 setBinaryStream(parameterIndex, x, length); 00648 }
|
|
Sets a parameter to a java.lang.BigDecimal value. The driver converts this to a SQL NUMERIC value when it sends it to the database.
Definition at line 435 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.BIG_DECIMAL_TAG, org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, and org.objectweb.cjdbc.driver.PreparedStatement.setNull(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateBigDecimal(). 00437 { 00438 if (connection.isDriverProcessed()) 00439 { 00440 if (x == null) 00441 setNull(parameterIndex, Types.DECIMAL); 00442 else 00443 set(parameterIndex, x.toString()); 00444 } 00445 else 00446 { 00447 if (x == null) 00448 setWithTag(parameterIndex, BIG_DECIMAL_TAG, NULL_TAG); 00449 else 00450 setWithTag(parameterIndex, BIG_DECIMAL_TAG, x.toString()); 00451 } 00452 }
|
|
When a very large binary value is input to a LONGVARBINARY parameter, it may be more practical to send it via a java.io.InputStream. JDBC will read the data from the stream as needed, until it reaches end-of-file. Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
Definition at line 686 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.setBytes(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setAsciiStream(), org.objectweb.cjdbc.driver.PreparedStatement.setBlob(), and org.objectweb.cjdbc.driver.PreparedStatement.setUnicodeStream(). 00688 { 00689 byte[] data = new byte[length]; 00690 try 00691 { 00692 x.read(data, 0, length); 00693 } 00694 catch (Exception ioe) 00695 { 00696 throw new SQLException("Problem with streaming of data"); 00697 } 00698 setBytes(parameterIndex, data); 00699 }
|
|
Definition at line 1002 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.BLOB_TAG, org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.setBinaryStream(), and org.objectweb.cjdbc.driver.PreparedStatement.setNull(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(). 01003 { 01004 if (x == null) 01005 { 01006 if (connection.isDriverProcessed()) 01007 setNull(i, Types.BLOB); 01008 else 01009 setWithTag(i, BLOB_TAG, NULL_TAG); 01010 return; 01011 } 01012 01013 if (connection.isDriverProcessed()) 01014 setBinaryStream(i, x.getBinaryStream(), (int) x.length()); 01015 else 01016 { 01017 byte[] data = new byte[(int) x.length()]; 01018 InputStream binStream = x.getBinaryStream(); 01019 try 01020 { 01021 binStream.read(data, 0, (int) x.length()); 01022 } 01023 catch (Exception ioe) 01024 { 01025 throw new SQLException("Problem with data streaming"); 01026 } 01027 try 01028 { 01029 synchronized (sbuf) 01030 { 01031 sbuf.setLength(0); 01032 sbuf.append(new HexaBlobFilter().encode(data)); 01033 setWithTag(i, BLOB_TAG, sbuf.toString()); 01034 } 01035 } 01036 catch (OutOfMemoryError oome) 01037 { 01038 sbuf = null; 01039 System.gc(); 01040 throw new SQLException("Out of memory"); 01041 } 01042 01043 } 01044 }
|
|
Sets a parameter to a Java boolean value. The driver converts this to a SQL BIT value when it sends it to the database.
Definition at line 294 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.BOOLEAN_TAG, org.objectweb.cjdbc.driver.Connection.getPreparedStatementBooleanFalse(), org.objectweb.cjdbc.driver.Connection.getPreparedStatementBooleanTrue(), and org.objectweb.cjdbc.driver.Connection.isDriverProcessed(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateBoolean(). 00295 { 00296 if (connection.isDriverProcessed()) 00297 { 00298 set(parameterIndex, x 00299 ? connection.getPreparedStatementBooleanTrue() 00300 : connection.getPreparedStatementBooleanFalse()); 00301 } 00302 else 00303 { 00304 setWithTag(parameterIndex, BOOLEAN_TAG, String.valueOf(x)); 00305 } 00306 }
|
|
Sets a parameter to a Java byte value.
Definition at line 315 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.BYTE_TAG, and org.objectweb.cjdbc.driver.Connection.isDriverProcessed(). Referenced by org.objectweb.cjdbc.driver.DriverResultSet.updateByte(). 00316 { 00317 if (connection.isDriverProcessed()) 00318 { 00319 set(parameterIndex, Integer.toString(x)); 00320 } 00321 else 00322 { 00323 setWithTag(parameterIndex, BYTE_TAG, Integer.toString(x)); 00324 } 00325 }
|
|
Sets a parameter to a Java array of bytes. The driver converts this to a SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARYs) when it sends it to the database. Implementation note: with org.postgresql, this creates a large object, and stores the objects oid in this column.
Definition at line 504 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.BYTES_TAG, org.objectweb.cjdbc.common.sql.filters.AbstractBlobFilter.encode(), org.objectweb.cjdbc.driver.Connection.escapeChar, org.objectweb.cjdbc.driver.Connection.getBlobFilter(), and org.objectweb.cjdbc.driver.Connection.isDriverProcessed(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setBinaryStream(), org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateBytes(). 00505 { 00506 String blob; 00507 try 00508 { 00509 synchronized (sbuf) 00510 { 00511 if (connection.isDriverProcessed()) 00512 { 00513 blob = connection.getBlobFilter().encode(x); 00514 sbuf.setLength(0); 00515 sbuf.append(connection.escapeChar); 00516 sbuf.append(blob); 00517 sbuf.append(connection.escapeChar); 00518 set(parameterIndex, sbuf.toString()); 00519 } 00520 else 00521 { 00522 blob = new HexaBlobFilter().encode(x); 00523 setWithTag(parameterIndex, BYTES_TAG, blob); 00524 } 00525 } 00526 } 00527 catch (OutOfMemoryError oome) 00528 { 00529 blob = null; 00530 sbuf = null; 00531 System.gc(); 00532 throw new SQLException("Out of memory"); 00533 } 00534 }
|
|
Definition at line 1050 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.setString(). 01052 { 01053 char[] data = new char[length]; 01054 try 01055 { 01056 x.read(data, 0, length); 01057 } 01058 catch (Exception ioe) 01059 { 01060 throw new SQLException("Problem with streaming of data"); 01061 } 01062 setString(i, new String(data)); 01063 }
|
|
Definition at line 1068 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.CLOB_TAG, org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.setNull(), and org.objectweb.cjdbc.driver.PreparedStatement.setString(). 01069 { 01070 if (x == null) 01071 { 01072 if (connection.isDriverProcessed()) 01073 setNull(i, Types.CLOB); 01074 else 01075 setWithTag(i, CLOB_TAG, NULL_TAG); 01076 return; 01077 } 01078 if (connection.isDriverProcessed()) 01079 setString(i, x.getSubString(0, (int) x.length())); 01080 else 01081 setWithTag(i, CLOB_TAG, x.getSubString(0, (int) x.length())); 01082 }
|
|
Definition at line 1104 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.DATE_TAG, org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.setDate(), and org.objectweb.cjdbc.driver.PreparedStatement.setNull(). 01106 { 01107 if (d == null) 01108 { 01109 if (connection.isDriverProcessed()) 01110 setNull(i, Types.DATE); 01111 else 01112 setWithTag(i, DATE_TAG, NULL_TAG); 01113 return; 01114 } 01115 else 01116 { 01117 if (cal == null) 01118 setDate(i, d); 01119 else 01120 { 01121 cal.setTime(d); 01122 setDate(i, new java.sql.Date(cal.getTime().getTime())); 01123 } 01124 } 01125 }
|
|
Sets a parameter to a java.sql.Date value. The driver converts this to a SQL DATE value when it sends it to the database.
Definition at line 544 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.DATE_TAG, org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, and org.objectweb.cjdbc.driver.PreparedStatement.setNull(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setDate(), org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateDate(). 00545 { 00546 if (connection.isDriverProcessed()) 00547 { 00548 if (x == null) 00549 setNull(parameterIndex, Types.DATE); 00550 else 00551 set(parameterIndex, "'" + new java.sql.Date(x.getTime()).toString() 00552 + "'"); 00553 } 00554 else 00555 { 00556 if (x == null) 00557 setWithTag(parameterIndex, DATE_TAG, NULL_TAG); 00558 else 00559 setWithTag(parameterIndex, DATE_TAG, new java.sql.Date(x.getTime()) 00560 .toString()); 00561 } 00562 }
|
|
Sets a parameter to a Java double value. The driver converts this to a SQL DOUBLE value when it sends it to the database.
Definition at line 415 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.DOUBLE_TAG, and org.objectweb.cjdbc.driver.Connection.isDriverProcessed(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateDouble(). 00416 { 00417 if (connection.isDriverProcessed()) 00418 { 00419 set(parameterIndex, Double.toString(x)); 00420 } 00421 else 00422 { 00423 setWithTag(parameterIndex, DOUBLE_TAG, Double.toString(x)); 00424 } 00425 }
|
|
Sets a parameter to a Java float value. The driver converts this to a SQL FLOAT value when it sends it to the database.
Definition at line 395 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.FLOAT_TAG, and org.objectweb.cjdbc.driver.Connection.isDriverProcessed(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateFloat(). 00396 { 00397 if (connection.isDriverProcessed()) 00398 { 00399 set(parameterIndex, Float.toString(x)); 00400 } 00401 else 00402 { 00403 setWithTag(parameterIndex, FLOAT_TAG, Float.toString(x)); 00404 } 00405 }
|
|
Set the auto generated key flag defined in Statement
Definition at line 1267 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.Connection.prepareStatement(). 01268 { 01269 generatedKeysFlag = autoGeneratedKeys; 01270 }
|
|
Sets a parameter to a Java int value. The driver converts this to a SQL INTEGER value when it sends it to the database.
Definition at line 355 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.INTEGER_TAG, and org.objectweb.cjdbc.driver.Connection.isDriverProcessed(). Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateInt(). 00356 { 00357 if (connection.isDriverProcessed()) 00358 { 00359 set(parameterIndex, Integer.toString(x)); 00360 } 00361 else 00362 { 00363 setWithTag(parameterIndex, INTEGER_TAG, Integer.toString(x)); 00364 } 00365 }
|
|
Sets a parameter to a Java long value. The driver converts this to a SQL BIGINT value when it sends it to the database.
Definition at line 375 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), and org.objectweb.cjdbc.driver.PreparedStatement.LONG_TAG. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateLong(). 00376 { 00377 if (connection.isDriverProcessed()) 00378 { 00379 set(parameterIndex, Long.toString(x)); 00380 } 00381 else 00382 { 00383 setWithTag(parameterIndex, LONG_TAG, Long.toString(x)); 00384 } 00385 }
|
|
Definition at line 1087 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.setNull(). 01088 { 01089 setNull(i, t); 01090 }
|
|
Sets a parameter to SQL NULL. Note: you must specify the parameters SQL type but we ignore it.
Definition at line 278 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), and org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setBigDecimal(), org.objectweb.cjdbc.driver.PreparedStatement.setBlob(), org.objectweb.cjdbc.driver.PreparedStatement.setClob(), org.objectweb.cjdbc.driver.PreparedStatement.setDate(), org.objectweb.cjdbc.driver.PreparedStatement.setNull(), org.objectweb.cjdbc.driver.PreparedStatement.setObject(), org.objectweb.cjdbc.driver.PreparedStatement.setString(), org.objectweb.cjdbc.driver.PreparedStatement.setTime(), org.objectweb.cjdbc.driver.PreparedStatement.setTimestamp(), and org.objectweb.cjdbc.driver.DriverResultSet.updateNull(). 00279 { 00280 if (connection.isDriverProcessed()) 00281 set(parameterIndex, "null"); 00282 else 00283 setWithTag(parameterIndex, NULL_TAG, String.valueOf(sqlType)); 00284 }
|
|
This stores an Object into a parameter.
Definition at line 823 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.OBJECT_TAG, org.objectweb.cjdbc.driver.PreparedStatement.setBigDecimal(), org.objectweb.cjdbc.driver.PreparedStatement.setBlob(), org.objectweb.cjdbc.driver.PreparedStatement.setBoolean(), org.objectweb.cjdbc.driver.PreparedStatement.setBytes(), org.objectweb.cjdbc.driver.PreparedStatement.setDate(), org.objectweb.cjdbc.driver.PreparedStatement.setDouble(), org.objectweb.cjdbc.driver.PreparedStatement.setFloat(), org.objectweb.cjdbc.driver.PreparedStatement.setInt(), org.objectweb.cjdbc.driver.PreparedStatement.setLong(), org.objectweb.cjdbc.driver.PreparedStatement.setNull(), org.objectweb.cjdbc.driver.PreparedStatement.setShort(), org.objectweb.cjdbc.driver.PreparedStatement.setString(), org.objectweb.cjdbc.driver.PreparedStatement.setTime(), org.objectweb.cjdbc.driver.PreparedStatement.setTimestamp(), and org.objectweb.cjdbc.driver.PreparedStatement.setURL(). 00824 { 00825 if (x == null) 00826 { 00827 if (connection.isDriverProcessed()) 00828 setNull(parameterIndex, Types.JAVA_OBJECT); 00829 else 00830 setWithTag(parameterIndex, OBJECT_TAG, NULL_TAG); 00831 } 00832 else 00833 { 00834 if (x instanceof String) 00835 setString(parameterIndex, (String) x); 00836 else if (x instanceof BigDecimal) 00837 setBigDecimal(parameterIndex, (BigDecimal) x); 00838 else if (x instanceof Short) 00839 setShort(parameterIndex, ((Short) x).shortValue()); 00840 else if (x instanceof Integer) 00841 setInt(parameterIndex, ((Integer) x).intValue()); 00842 else if (x instanceof Long) 00843 setLong(parameterIndex, ((Long) x).longValue()); 00844 else if (x instanceof Float) 00845 setFloat(parameterIndex, ((Float) x).floatValue()); 00846 else if (x instanceof Double) 00847 setDouble(parameterIndex, ((Double) x).doubleValue()); 00848 else if (x instanceof byte[]) 00849 setBytes(parameterIndex, (byte[]) x); 00850 else if (x instanceof java.sql.Date) 00851 setDate(parameterIndex, (java.sql.Date) x); 00852 else if (x instanceof Time) 00853 setTime(parameterIndex, (Time) x); 00854 else if (x instanceof Timestamp) 00855 setTimestamp(parameterIndex, (Timestamp) x); 00856 else if (x instanceof Boolean) 00857 setBoolean(parameterIndex, ((Boolean) x).booleanValue()); 00858 else if (x instanceof Blob) 00859 setBlob(parameterIndex, (Blob) x); 00860 else if (x instanceof java.net.URL) 00861 setURL(parameterIndex, (java.net.URL) x); 00862 else if (x instanceof Serializable) 00863 { 00864 ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); 00865 try 00866 { 00867 // Serialize object to byte array 00868 ObjectOutputStream objectOutputStream = new ObjectOutputStream( 00869 byteOutputStream); 00870 objectOutputStream.writeObject(x); 00871 objectOutputStream.flush(); 00872 objectOutputStream.close(); 00873 if (connection.isDriverProcessed()) 00874 setBytes(parameterIndex, byteOutputStream.toByteArray()); 00875 else 00876 synchronized (sbuf) 00877 { 00878 sbuf.setLength(0); 00879 sbuf.append(byteOutputStream); 00880 setWithTag(parameterIndex, OBJECT_TAG, sbuf.toString()); 00881 } 00882 } 00883 catch (IOException e) 00884 { 00885 throw new SQLException("Failed to serialize object: " + e); 00886 } 00887 } 00888 else 00889 throw new SQLException("Objects of type " + x.getClass() 00890 + " are not supported."); 00891 } 00892 }
|
|
Definition at line 810 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.setObject(). 00812 { 00813 setObject(parameterIndex, x, targetSqlType, 0); 00814 }
|
|
Sets the value of a parameter using an object; use the The given Java object will be converted to the targetSqlType before being sent to the database.
Note that this method may be used to pass database-specific abstract data types. This is done by using a Driver-specific Java type and using a
Definition at line 738 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.setBlob(), org.objectweb.cjdbc.driver.PreparedStatement.setBoolean(), org.objectweb.cjdbc.driver.PreparedStatement.setBytes(), org.objectweb.cjdbc.driver.PreparedStatement.setDate(), org.objectweb.cjdbc.driver.PreparedStatement.setInt(), org.objectweb.cjdbc.driver.PreparedStatement.setLong(), org.objectweb.cjdbc.driver.PreparedStatement.setNull(), org.objectweb.cjdbc.driver.PreparedStatement.setString(), org.objectweb.cjdbc.driver.PreparedStatement.setTime(), org.objectweb.cjdbc.driver.PreparedStatement.setTimestamp(), org.objectweb.cjdbc.driver.PreparedStatement.setURL(), and org.objectweb.cjdbc.driver.PreparedStatement.STRING_TAG. Referenced by org.objectweb.cjdbc.driver.DriverResultSet.deleteRow(), org.objectweb.cjdbc.driver.DriverResultSet.refreshRow(), org.objectweb.cjdbc.driver.PreparedStatement.setObject(), org.objectweb.cjdbc.driver.DriverResultSet.updateObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateRow(). 00740 { 00741 if (x == null) 00742 { 00743 setNull(parameterIndex, targetSqlType); 00744 } 00745 else 00746 { 00747 switch (targetSqlType) 00748 { 00749 case Types.TINYINT : 00750 case Types.SMALLINT : 00751 case Types.INTEGER : 00752 setInt(parameterIndex, ((Number) x).intValue()); 00753 break; 00754 case Types.BIGINT : 00755 setLong(parameterIndex, ((Number) x).longValue()); 00756 break; 00757 case Types.REAL : 00758 case Types.FLOAT : 00759 case Types.DOUBLE : 00760 case Types.DECIMAL : 00761 case Types.NUMERIC : 00762 // Cast to Number is not necessary 00763 if (connection.isDriverProcessed()) 00764 set(parameterIndex, x.toString()); 00765 else 00766 setWithTag(parameterIndex, STRING_TAG, x.toString()); 00767 break; 00768 case Types.BIT : 00769 case Types.BOOLEAN : 00770 setBoolean(parameterIndex, ((Boolean) x).booleanValue()); 00771 break; 00772 case Types.CHAR : 00773 case Types.VARCHAR : 00774 case Types.LONGVARCHAR : 00775 setString(parameterIndex, (String) x); 00776 break; 00777 case Types.BINARY : 00778 case Types.VARBINARY : 00779 case Types.LONGVARBINARY : 00780 setBytes(parameterIndex, (byte[]) x); 00781 break; 00782 case Types.DATE : 00783 setDate(parameterIndex, (java.sql.Date) x); 00784 break; 00785 case Types.TIME : 00786 setTime(parameterIndex, (Time) x); 00787 break; 00788 case Types.TIMESTAMP : 00789 setTimestamp(parameterIndex, (Timestamp) x); 00790 break; 00791 case Types.BLOB : 00792 setBlob(parameterIndex, (Blob) x); 00793 break; 00794 case Types.DATALINK : 00795 setURL(parameterIndex, (java.net.URL) x); 00796 break; 00797 case Types.JAVA_OBJECT : 00798 case Types.OTHER : 00799 setObject(parameterIndex, x); 00800 break; 00801 default : 00802 throw new SQLException("Unsupported type value"); 00803 } 00804 } 00805 }
|
|
Set a PreparedStatement by calling the appropriate setXXX methods on the request skeleton.
Definition at line 1280 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.BIG_DECIMAL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.BLOB_TAG, org.objectweb.cjdbc.driver.PreparedStatement.BOOLEAN_TAG, org.objectweb.cjdbc.driver.PreparedStatement.BYTE_TAG, org.objectweb.cjdbc.driver.PreparedStatement.BYTES_TAG, org.objectweb.cjdbc.driver.PreparedStatement.CLOB_TAG, org.objectweb.cjdbc.driver.PreparedStatement.DATE_TAG, org.objectweb.cjdbc.driver.PreparedStatement.DOUBLE_TAG, org.objectweb.cjdbc.driver.PreparedStatement.FLOAT_TAG, org.objectweb.cjdbc.driver.PreparedStatement.INTEGER_TAG, org.objectweb.cjdbc.driver.PreparedStatement.LONG_TAG, org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.OBJECT_TAG, org.objectweb.cjdbc.driver.PreparedStatement.SHORT_TAG, org.objectweb.cjdbc.driver.PreparedStatement.STRING_TAG, org.objectweb.cjdbc.driver.PreparedStatement.TIME_TAG, and org.objectweb.cjdbc.driver.PreparedStatement.TIMESTAMP_TAG. 01282 { 01283 int i = 0; 01284 int currentParameter = 0; 01285 01286 // Set all parameters 01287 while ((i = sql.indexOf(Connection.START_PARAM_TAG, i)) > -1) 01288 { 01289 currentParameter++; 01290 01291 int typeStart = i + Connection.START_PARAM_TAG.length(); 01292 01293 // Here we assume that all tags have the same length as the boolean tag. 01294 String tag = sql.substring(typeStart, typeStart + BOOLEAN_TAG.length()); 01295 String value = sql.substring(typeStart + BOOLEAN_TAG.length(), sql 01296 .indexOf(Connection.END_PARAM_TAG, i)); 01297 value = Strings.replace(value, Connection.TAG_MARKER_ESCAPE, 01298 Connection.TAG_MARKER); 01299 01300 // Test tags in alphabetical order (to make the code easier to read) 01301 if (tag.equals(BIG_DECIMAL_TAG)) 01302 { 01303 if (value.equals(NULL_TAG)) 01304 ps.setBigDecimal(currentParameter, null); 01305 else 01306 { 01307 BigDecimal t = new BigDecimal(value); 01308 ps.setBigDecimal(currentParameter, t); 01309 } 01310 } 01311 else if (tag.equals(BOOLEAN_TAG)) 01312 ps.setBoolean(currentParameter, Boolean.valueOf(value).booleanValue()); 01313 else if (tag.equals(BYTE_TAG)) 01314 { 01315 byte t = new Integer(value).byteValue(); 01316 ps.setByte(currentParameter, t); 01317 } 01318 else if (tag.equals(BYTES_TAG)) 01319 { 01320 byte[] t = new HexaBlobFilter().decode(value); 01321 ps.setBytes(currentParameter, t); 01322 } 01323 else if (tag.equals(BLOB_TAG)) 01324 { 01325 if (value.equals(NULL_TAG)) 01326 ps.setBlob(currentParameter, null); 01327 else 01328 { 01329 Blob b = new Blob(new HexaBlobFilter().decode(value)); 01330 ps.setBlob(currentParameter, b); 01331 } 01332 } 01333 else if (tag.equals(CLOB_TAG)) 01334 { 01335 if (value.equals(NULL_TAG)) 01336 ps.setClob(currentParameter, null); 01337 else 01338 { 01339 Clob c = new Clob(value); 01340 ps.setClob(currentParameter, c); 01341 } 01342 } 01343 else if (tag.equals(DATE_TAG)) 01344 { 01345 if (value.equals(NULL_TAG)) 01346 ps.setDate(currentParameter, null); 01347 else 01348 try 01349 { 01350 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 01351 Date t = new Date(sdf.parse(value).getTime()); 01352 ps.setDate(currentParameter, t); 01353 } 01354 catch (ParseException p) 01355 { 01356 ps.setDate(currentParameter, null); 01357 throw new SQLException("Couldn't format date!!!"); 01358 } 01359 } 01360 else if (tag.equals(DOUBLE_TAG)) 01361 ps.setDouble(currentParameter, Double.valueOf(value).doubleValue()); 01362 else if (tag.equals(FLOAT_TAG)) 01363 ps.setFloat(currentParameter, Float.valueOf(value).floatValue()); 01364 else if (tag.equals(INTEGER_TAG)) 01365 ps.setInt(currentParameter, Integer.valueOf(value).intValue()); 01366 else if (tag.equals(LONG_TAG)) 01367 ps.setLong(currentParameter, Long.valueOf(value).longValue()); 01368 else if (tag.equals(NULL_TAG)) 01369 ps.setNull(currentParameter, Integer.valueOf(value).intValue()); 01370 else if (tag.equals(OBJECT_TAG)) 01371 { 01372 if (value.equals(NULL_TAG)) 01373 ps.setObject(currentParameter, null); 01374 else 01375 { 01376 try 01377 { 01378 ObjectInputStream in = new ObjectInputStream( 01379 new ByteArrayInputStream(value.getBytes())); 01380 ps.setObject(currentParameter, in.readObject()); 01381 in.close(); 01382 } 01383 catch (Exception e) 01384 { 01385 throw new SQLException("Failed to rebuild object from stream " + e); 01386 } 01387 } 01388 } 01389 else if (tag.equals(SHORT_TAG)) 01390 { 01391 short t = new Integer(value).shortValue(); 01392 ps.setShort(currentParameter, t); 01393 } 01394 else if (tag.equals(STRING_TAG)) 01395 { 01396 if (value.equals(NULL_TAG)) 01397 ps.setString(currentParameter, null); 01398 else 01399 ps.setString(currentParameter, value); 01400 } 01401 else if (tag.equals(TIME_TAG)) 01402 { 01403 if (value.equals(NULL_TAG)) 01404 ps.setTime(currentParameter, null); 01405 else 01406 try 01407 { 01408 SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); 01409 Time t = new Time(sdf.parse(value).getTime()); 01410 ps.setTime(currentParameter, t); 01411 } 01412 catch (ParseException p) 01413 { 01414 ps.setTime(currentParameter, null); 01415 throw new SQLException("Couldn't format time!!!"); 01416 } 01417 } 01418 else if (tag.equals(TIMESTAMP_TAG)) 01419 { 01420 if (value.equals(NULL_TAG)) 01421 ps.setTimestamp(currentParameter, null); 01422 else 01423 try 01424 { 01425 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); 01426 Timestamp t = new Timestamp(sdf.parse(value).getTime()); 01427 ps.setTimestamp(currentParameter, t); 01428 } 01429 catch (ParseException p) 01430 { 01431 ps.setTimestamp(currentParameter, null); 01432 throw new SQLException("Couldn't format timestamp!!!"); 01433 } 01434 } 01435 else 01436 { 01437 // invalid parameter, we want to be able to store strings like 01438 // <?xml version="1.0" encoding="ISO-8859-1"?> 01439 currentParameter--; 01440 } 01441 i = typeStart; 01442 } 01443 }
|
|
Definition at line 1095 of file PreparedStatement.java. 01096 { 01097 throw new NotImplementedException("setRef()"); 01098 }
|
|
Sets a parameter to a Java short value. The driver converts this to a SQL SMALLINT value when it sends it to the database.
Definition at line 335 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), and org.objectweb.cjdbc.driver.PreparedStatement.SHORT_TAG. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateShort(). 00336 { 00337 if (connection.isDriverProcessed()) 00338 { 00339 set(parameterIndex, Integer.toString(x)); 00340 } 00341 else 00342 { 00343 setWithTag(parameterIndex, SHORT_TAG, Integer.toString(x)); 00344 } 00345 }
|
|
Sets a parameter to a Java String value. The driver converts this to a SQL VARCHAR or LONGVARCHAR value (depending on the arguments size relative to the driver's limits on VARCHARs) when it sends it to the database.
Definition at line 463 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.doEscapeProcessing(), org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.Connection.isEscapeBackslash(), org.objectweb.cjdbc.driver.Connection.isEscapeSingleQuote(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.setNull(), and org.objectweb.cjdbc.driver.PreparedStatement.STRING_TAG. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setCharacterStream(), org.objectweb.cjdbc.driver.PreparedStatement.setClob(), org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.DriverResultSet.updateString(). 00464 { 00465 if (connection.isDriverProcessed()) 00466 { 00467 if (x == null) 00468 // if the passed string is null, then set this column to null 00469 setNull(parameterIndex, Types.VARCHAR); 00470 else 00471 { 00472 if (escapeProcessing 00473 && (connection.isEscapeBackslash() || connection 00474 .isEscapeSingleQuote())) 00475 set(parameterIndex, doEscapeProcessing(x)); 00476 else 00477 // No escape processing 00478 set(parameterIndex, x); 00479 } 00480 } 00481 else 00482 { 00483 if (x == null) 00484 setWithTag(parameterIndex, STRING_TAG, NULL_TAG); 00485 else 00486 // No escape processing is needed for queries not being parsed into 00487 // statements. 00488 setWithTag(parameterIndex, STRING_TAG, x); 00489 } 00490 }
|
|
Definition at line 1131 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.setNull(), org.objectweb.cjdbc.driver.PreparedStatement.setTime(), and org.objectweb.cjdbc.driver.PreparedStatement.TIME_TAG. 01133 { 01134 if (t == null) 01135 { 01136 if (connection.isDriverProcessed()) 01137 setNull(i, Types.TIME); 01138 else 01139 setWithTag(i, TIME_TAG, NULL_TAG); 01140 return; 01141 } 01142 else 01143 { 01144 if (cal == null) 01145 setTime(i, t); 01146 else 01147 { 01148 cal.setTime(t); 01149 setTime(i, new java.sql.Time(cal.getTime().getTime())); 01150 } 01151 } 01152 }
|
|
Sets a parameter to a
Definition at line 572 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.setNull(), and org.objectweb.cjdbc.driver.PreparedStatement.TIME_TAG. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), org.objectweb.cjdbc.driver.PreparedStatement.setTime(), and org.objectweb.cjdbc.driver.DriverResultSet.updateTime(). 00573 { 00574 if (connection.isDriverProcessed()) 00575 { 00576 if (x == null) 00577 setNull(parameterIndex, Types.TIME); 00578 else 00579 set(parameterIndex, "{t '" + x.toString() + "'}"); 00580 } 00581 else 00582 { 00583 if (x == null) 00584 setWithTag(parameterIndex, TIME_TAG, NULL_TAG); 00585 else 00586 setWithTag(parameterIndex, TIME_TAG, x.toString()); 00587 } 00588 }
|
|
Definition at line 1158 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.setNull(), org.objectweb.cjdbc.driver.PreparedStatement.setTimestamp(), and org.objectweb.cjdbc.driver.PreparedStatement.TIMESTAMP_TAG. 01160 { 01161 if (t == null) 01162 { 01163 if (connection.isDriverProcessed()) 01164 setNull(i, Types.TIMESTAMP); 01165 else 01166 setWithTag(i, TIMESTAMP_TAG, NULL_TAG); 01167 return; 01168 } 01169 else 01170 { 01171 if (cal == null) 01172 setTimestamp(i, t); 01173 else 01174 { 01175 cal.setTime(t); 01176 setTimestamp(i, new java.sql.Timestamp(cal.getTime().getTime())); 01177 } 01178 } 01179 }
|
|
Sets a parameter to a
Definition at line 598 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.Connection.isDriverProcessed(), org.objectweb.cjdbc.driver.PreparedStatement.NULL_TAG, org.objectweb.cjdbc.driver.PreparedStatement.setNull(), and org.objectweb.cjdbc.driver.PreparedStatement.TIMESTAMP_TAG. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), org.objectweb.cjdbc.driver.PreparedStatement.setTimestamp(), and org.objectweb.cjdbc.driver.DriverResultSet.updateTimestamp(). 00599 { 00600 if (connection.isDriverProcessed()) 00601 { 00602 if (x == null) 00603 setNull(parameterIndex, Types.TIMESTAMP); 00604 else 00605 { 00606 // Be careful don't use instanceof here since it would match derived 00607 // classes. 00608 if (x.getClass().equals(Timestamp.class)) 00609 set(parameterIndex, "'" + x.toString() + "'"); 00610 else 00611 set(parameterIndex, "'" + new Timestamp(x.getTime()).toString() + "'"); 00612 } 00613 } 00614 else 00615 { 00616 if (x == null) 00617 setWithTag(parameterIndex, TIMESTAMP_TAG, NULL_TAG); 00618 else 00619 { 00620 if (x.getClass().equals(Timestamp.class)) 00621 setWithTag(parameterIndex, TIMESTAMP_TAG, x.toString()); 00622 else 00623 setWithTag(parameterIndex, TIMESTAMP_TAG, new Timestamp(x.getTime()) 00624 .toString()); 00625 } 00626 } 00627 }
|
|
When a very large Unicode value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.InputStream. JDBC will read the data from the stream as needed, until it reaches end-of-file. The JDBC driver will do any necessary conversion from UNICODE to the database char format. ** DEPRECIATED IN JDBC 2 ** Note: this stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
Definition at line 667 of file PreparedStatement.java. References org.objectweb.cjdbc.driver.PreparedStatement.setBinaryStream(). 00669 { 00670 setBinaryStream(parameterIndex, x, length); 00671 }
|
|
Sets the designated parameter to the given
Definition at line 1193 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(). 01194 { 01195 throw new NotImplementedException("setURL"); 01196 }
|
|
Returns the SQL statement with the current template values substituted.
Note: : This is identical to
Definition at line 942 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.DriverResultSet.getBoolean(), org.objectweb.cjdbc.driver.DriverResultSet.getDouble(), org.objectweb.cjdbc.driver.DriverResultSet.getFloat(), org.objectweb.cjdbc.driver.DriverResultSet.getInt(), org.objectweb.cjdbc.driver.DriverResultSet.getLong(), org.objectweb.cjdbc.driver.DriverResultSet.getShort(), and org.objectweb.cjdbc.driver.DriverResultSet.getString(). 00943 { 00944 synchronized (sbuf) 00945 { 00946 sbuf.setLength(0); 00947 int i; 00948 00949 for (i = 0; i < inStrings.length; ++i) 00950 { 00951 if (inStrings[i] == null) 00952 sbuf.append('?'); 00953 else 00954 sbuf.append(templateStrings[i]); 00955 sbuf.append(inStrings[i]); 00956 } 00957 sbuf.append(templateStrings[inStrings.length]); 00958 return sbuf.toString(); 00959 } 00960 }
|
|
Tag for a big decimal parameter Definition at line 90 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setBigDecimal(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a BLOB (used for null Blob) parameter Definition at line 84 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setBlob(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a boolean parameter Definition at line 88 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setBoolean(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a byte parameter Definition at line 80 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setByte(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a bytes (used for Blob) parameter Definition at line 82 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setBytes(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a CLOB (used for null Clob) parameter Definition at line 86 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setClob(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a date parameter Definition at line 92 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setDate(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a double parameter Definition at line 94 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setDouble(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a float parameter Definition at line 96 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setFloat(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a integer parameter Definition at line 98 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setInt(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a long parameter Definition at line 100 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setLong(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a setNull call Definition at line 102 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setBigDecimal(), org.objectweb.cjdbc.driver.PreparedStatement.setBlob(), org.objectweb.cjdbc.driver.PreparedStatement.setClob(), org.objectweb.cjdbc.driver.PreparedStatement.setDate(), org.objectweb.cjdbc.driver.PreparedStatement.setNull(), org.objectweb.cjdbc.driver.PreparedStatement.setObject(), org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(), org.objectweb.cjdbc.driver.PreparedStatement.setString(), org.objectweb.cjdbc.driver.PreparedStatement.setTime(), and org.objectweb.cjdbc.driver.PreparedStatement.setTimestamp(). |
|
Tag for an object parameter Definition at line 104 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), and org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(). |
|
Tag for a short parameter Definition at line 106 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(), and org.objectweb.cjdbc.driver.PreparedStatement.setShort(). |
|
Tag for a string parameter Definition at line 108 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setObject(), org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(), and org.objectweb.cjdbc.driver.PreparedStatement.setString(). |
|
Tag for a time parameter Definition at line 110 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(), and org.objectweb.cjdbc.driver.PreparedStatement.setTime(). |
|
Tag for a timestamp parameter Definition at line 112 of file PreparedStatement.java. Referenced by org.objectweb.cjdbc.driver.PreparedStatement.setPreparedStatement(), and org.objectweb.cjdbc.driver.PreparedStatement.setTimestamp(). |