386 //---------------------------------------------------------------------- |
386 //---------------------------------------------------------------------- |
387 // Advanced features: |
387 // Advanced features: |
388 |
388 |
389 /** |
389 /** |
390 * Sets the value of the designated parameter with the given object. |
390 * Sets the value of the designated parameter with the given object. |
391 * This method is like the method <code>setObject</code> |
391 * |
392 * above, except that it assumes a scale of zero. |
392 * This method is similar to {@link #setObject(int parameterIndex, |
|
393 * Object x, int targetSqlType, int scaleOrLength)}, |
|
394 * except that it assumes a scale of zero. |
393 * |
395 * |
394 * @param parameterIndex the first parameter is 1, the second is 2, ... |
396 * @param parameterIndex the first parameter is 1, the second is 2, ... |
395 * @param x the object containing the input parameter value |
397 * @param x the object containing the input parameter value |
396 * @param targetSqlType the SQL type (as defined in java.sql.Types) to be |
398 * @param targetSqlType the SQL type (as defined in java.sql.Types) to be |
397 * sent to the database |
399 * sent to the database |
398 * @exception SQLException if parameterIndex does not correspond to a parameter |
400 * @exception SQLException if parameterIndex does not correspond to a parameter |
399 * marker in the SQL statement; if a database access error occurs or |
401 * marker in the SQL statement; if a database access error occurs or this |
400 * this method is called on a closed <code>PreparedStatement</code> |
402 * method is called on a closed PreparedStatement |
401 * @exception SQLFeatureNotSupportedException if <code>targetSqlType</code> is |
403 * @exception SQLFeatureNotSupportedException if |
402 * a <code>ARRAY</code>, <code>BLOB</code>, <code>CLOB</code>, |
404 * the JDBC driver does not support this data type |
403 * <code>DATALINK</code>, <code>JAVA_OBJECT</code>, <code>NCHAR</code>, |
|
404 * <code>NCLOB</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code>, |
|
405 * <code>REF</code>, <code>ROWID</code>, <code>SQLXML</code> |
|
406 * or <code>STRUCT</code> data type and the JDBC driver does not support |
|
407 * this data type |
|
408 * @see Types |
405 * @see Types |
409 */ |
406 */ |
410 void setObject(int parameterIndex, Object x, int targetSqlType) |
407 void setObject(int parameterIndex, Object x, int targetSqlType) |
411 throws SQLException; |
408 throws SQLException; |
412 |
409 |
413 /** |
410 /** |
414 * <p>Sets the value of the designated parameter using the given object. |
411 * <p>Sets the value of the designated parameter using the given object. |
415 * The second parameter must be of type <code>Object</code>; therefore, the |
|
416 * <code>java.lang</code> equivalent objects should be used for built-in types. |
|
417 * |
412 * |
418 * <p>The JDBC specification specifies a standard mapping from |
413 * <p>The JDBC specification specifies a standard mapping from |
419 * Java <code>Object</code> types to SQL types. The given argument |
414 * Java <code>Object</code> types to SQL types. The given argument |
420 * will be converted to the corresponding SQL type before being |
415 * will be converted to the corresponding SQL type before being |
421 * sent to the database. |
416 * sent to the database. |
955 * marker in the SQL statement; if a database access error occurs; |
948 * marker in the SQL statement; if a database access error occurs; |
956 * this method is called on a closed <code>PreparedStatement</code> or |
949 * this method is called on a closed <code>PreparedStatement</code> or |
957 * if the Java Object specified by x is an InputStream |
950 * if the Java Object specified by x is an InputStream |
958 * or Reader object and the value of the scale parameter is less |
951 * or Reader object and the value of the scale parameter is less |
959 * than zero |
952 * than zero |
960 * @exception SQLFeatureNotSupportedException if <code>targetSqlType</code> is |
953 * @exception SQLFeatureNotSupportedException if |
961 * a <code>ARRAY</code>, <code>BLOB</code>, <code>CLOB</code>, |
954 * the JDBC driver does not support this data type |
962 * <code>DATALINK</code>, <code>JAVA_OBJECT</code>, <code>NCHAR</code>, |
|
963 * <code>NCLOB</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code>, |
|
964 * <code>REF</code>, <code>ROWID</code>, <code>SQLXML</code> |
|
965 * or <code>STRUCT</code> data type and the JDBC driver does not support |
|
966 * this data type |
|
967 * @see Types |
955 * @see Types |
968 * |
956 * |
969 * @since 1.6 |
957 * @since 1.6 |
970 */ |
958 */ |
971 void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) |
959 void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) |
1218 * @since 1.6 |
1206 * @since 1.6 |
1219 */ |
1207 */ |
1220 void setNClob(int parameterIndex, Reader reader) |
1208 void setNClob(int parameterIndex, Reader reader) |
1221 throws SQLException; |
1209 throws SQLException; |
1222 |
1210 |
1223 |
1211 //------------------------- JDBC 4.2 ----------------------------------- |
|
1212 |
|
1213 /** |
|
1214 * <p>Sets the value of the designated parameter with the given object. |
|
1215 * |
|
1216 * If the second argument is an {@code InputStream} then the stream |
|
1217 * must contain the number of bytes specified by scaleOrLength. |
|
1218 * If the second argument is a {@code Reader} then the reader must |
|
1219 * contain the number of characters specified by scaleOrLength. If these |
|
1220 * conditions are not true the driver will generate a |
|
1221 * {@code SQLException} when the prepared statement is executed. |
|
1222 * |
|
1223 * <p>The given Java object will be converted to the given targetSqlType |
|
1224 * before being sent to the database. |
|
1225 * |
|
1226 * If the object has a custom mapping (is of a class implementing the |
|
1227 * interface {@code SQLData}), |
|
1228 * the JDBC driver should call the method {@code SQLData.writeSQL} to |
|
1229 * write it to the SQL data stream. |
|
1230 * If, on the other hand, the object is of a class implementing |
|
1231 * {@code Ref}, {@code Blob}, {@code Clob}, {@code NClob}, |
|
1232 * {@code Struct}, {@code java.net.URL}, |
|
1233 * or {@code Array}, the driver should pass it to the database as a |
|
1234 * value of the corresponding SQL type. |
|
1235 * |
|
1236 * <p>Note that this method may be used to pass database-specific |
|
1237 * abstract data types. |
|
1238 *<P> |
|
1239 * The default implementation will throw {@code SQLFeatureNotSupportedException} |
|
1240 * |
|
1241 * @param parameterIndex the first parameter is 1, the second is 2, ... |
|
1242 * @param x the object containing the input parameter value |
|
1243 * @param targetSqlType the SQL type to be sent to the database. The |
|
1244 * scale argument may further qualify this type. |
|
1245 * @param scaleOrLength for {@code java.sql.JDBCType.DECIMAL} |
|
1246 * or {@code java.sql.JDBCType.NUMERIC types}, |
|
1247 * this is the number of digits after the decimal point. For |
|
1248 * Java Object types {@code InputStream} and {@code Reader}, |
|
1249 * this is the length |
|
1250 * of the data in the stream or reader. For all other types, |
|
1251 * this value will be ignored. |
|
1252 * @exception SQLException if parameterIndex does not correspond to a |
|
1253 * parameter marker in the SQL statement; if a database access error occurs |
|
1254 * or this method is called on a closed {@code PreparedStatement} or |
|
1255 * if the Java Object specified by x is an InputStream |
|
1256 * or Reader object and the value of the scale parameter is less |
|
1257 * than zero |
|
1258 * @exception SQLFeatureNotSupportedException if |
|
1259 * the JDBC driver does not support this data type |
|
1260 * @see JDBCType |
|
1261 * @see SQLType |
|
1262 * @since 1.8 |
|
1263 */ |
|
1264 default void setObject(int parameterIndex, Object x, SQLType targetSqlType, |
|
1265 int scaleOrLength) throws SQLException { |
|
1266 throw new SQLFeatureNotSupportedException("setObject not implemented"); |
|
1267 } |
|
1268 |
|
1269 /** |
|
1270 * Sets the value of the designated parameter with the given object. |
|
1271 * |
|
1272 * This method is similar to {@link #setObject(int parameterIndex, |
|
1273 * Object x, SQLType targetSqlType, int scaleOrLength)}, |
|
1274 * except that it assumes a scale of zero. |
|
1275 *<P> |
|
1276 * The default implementation will throw {@code SQLFeatureNotSupportedException} |
|
1277 * |
|
1278 * @param parameterIndex the first parameter is 1, the second is 2, ... |
|
1279 * @param x the object containing the input parameter value |
|
1280 * @param targetSqlType the SQL type to be sent to the database |
|
1281 * @exception SQLException if parameterIndex does not correspond to a |
|
1282 * parameter marker in the SQL statement; if a database access error occurs |
|
1283 * or this method is called on a closed {@code PreparedStatement} |
|
1284 * @exception SQLFeatureNotSupportedException if |
|
1285 * the JDBC driver does not support this data type |
|
1286 * @see JDBCType |
|
1287 * @see SQLType |
|
1288 * @since 1.8 |
|
1289 */ |
|
1290 default void setObject(int parameterIndex, Object x, SQLType targetSqlType) |
|
1291 throws SQLException { |
|
1292 throw new SQLFeatureNotSupportedException("setObject not implemented"); |
|
1293 } |
|
1294 |
|
1295 /** |
|
1296 * Executes the SQL statement in this <code>PreparedStatement</code> object, |
|
1297 * which must be an SQL Data Manipulation Language (DML) statement, |
|
1298 * such as <code>INSERT</code>, <code>UPDATE</code> or |
|
1299 * <code>DELETE</code>; or an SQL statement that returns nothing, |
|
1300 * such as a DDL statement. |
|
1301 * <p> |
|
1302 * This method should be used when the returned row count may exceed |
|
1303 * {@link Integer.MAX_VALUE}. |
|
1304 * <p> |
|
1305 * The default implementation will throw {@code UnsupportedOperationException} |
|
1306 * |
|
1307 * @return either (1) the row count for SQL Data Manipulation Language |
|
1308 * (DML) statements or (2) 0 for SQL statements that return nothing |
|
1309 * @exception SQLException if a database access error occurs; |
|
1310 * this method is called on a closed <code>PreparedStatement</code> |
|
1311 * or the SQL statement returns a <code>ResultSet</code> object |
|
1312 * @throws SQLTimeoutException when the driver has determined that the |
|
1313 * timeout value that was specified by the {@code setQueryTimeout} |
|
1314 * method has been exceeded and has at least attempted to cancel |
|
1315 * the currently running {@code Statement} |
|
1316 * @since 1.8 |
|
1317 */ |
|
1318 default long executeLargeUpdate() throws SQLException { |
|
1319 throw new UnsupportedOperationException("executeLargeUpdate not implemented"); |
|
1320 } |
1224 } |
1321 } |