-
Blob
The Blob implementation does not allow in-place modification
(they are 'copies', as reported by the
DatabaseMetaData.locatorsUpdateCopies() method). Because of
this, you should use the corresponding
PreparedStatement.setBlob() or ResultSet.updateBlob() (in
the case of updatable result sets) methods to save changes
back to the database.
Starting with Connector/J version 3.1.0, you can emulate
Blobs with locators by adding the property
'emulateLocators=true' to your JDBC URL. You must then use a
column alias with the value of the column set to the actual
name of the Blob column in the SELECT that you write to
retrieve the Blob. The SELECT must also reference only one
table, the table must have a primary key, and the SELECT
must cover all columns that make up the primary key. The
driver will then delay loading the actual Blob data until
you retrieve the Blob and call retrieval methods
(getInputStream(), getBytes(), and so forth) on it.
-
CallableStatement
Starting with Connector/J 3.1.1, stored procedures are
supported when connecting to MySQL version 5.0 or newer via
the CallableStatement
interface.
Currently, the getParameterMetaData()
method of CallableStatement
is not
supported.
-
Clob
The Clob implementation does not allow in-place modification
(they are 'copies', as reported by the
DatabaseMetaData.locatorsUpdateCopies() method). Because of
this, you should use the PreparedStatement.setClob() method
to save changes back to the database. The JDBC API does not
have a ResultSet.updateClob() method.
-
Connection
Unlike older versions of MM.MySQL the
isClosed()
method does not
“ping” the server to determine if it is alive.
In accordance with the JDBC specification, it only returns
true if 'closed()' has been called on the connection. If you
need to determine if the connection is still valid, you
should issue a simple query, such as "SELECT 1". The driver
will throw an exception if the connection is no longer
valid.
-
DatabaseMetaData
Foreign Key information (getImported/ExportedKeys() and
getCrossReference()) is only available from 'InnoDB'-type
tables. However, the driver uses 'SHOW CREATE TABLE' to
retrieve this information, so when other storage engines
support foreign keys, the driver will transparently support
them as well.
Driver
-
PreparedStatement
PreparedStatements are implemented by the driver, as MySQL
does not have a prepared statement feature. Because of this,
the driver does not implement getParameterMetaData() or
getMetaData() as it would require the driver to have a
complete SQL parser in the client.
Starting with version 3.1.0 MySQL Connector/J, server-side
prepared statements and 'binary-encoded' result sets are
used when the server supports them.
Take care when using a server-side prepared statement with
“large” parameters that are set via
setBinaryStream(), setAsciiStream(), setUnicodeStream(),
setBlob(), or setClob(). If you want to re-execute the
statement with any “large” parameter changed to
a non-“large” parameter, it is necessary to
call clearParameters() and set all parameters again. The
reason for this is as follows:
If a parameter changes from “large” to
non-“large,” the driver must reset the
server-side state of the prepared statement to allow the
parameter that is being changed to take the place of the
prior “large” value. This removes all of
the 'large' data that has already been sent to the
server, thus requiring the data to be re-sent, via the
setBinaryStream(), setAsciiStream(), setUnicodeStream(),
setBlob() or setClob() methods.
Consequently, if you want to change the “type”
of a parameter to a non-“large” one, you must
call clearParameters() and set all parameters of the
prepared statement again before it can be re-executed.
-
ResultSet
By default, ResultSets are completely retrieved and stored
in memory. In most cases this is the most efficient way to
operate, and due to the design of the MySQL network protocol
is easier to implement. If you are working with ResultSets
that have a large number of rows or large values, and can
not allocate heap space in your JVM for the memory required,
you can tell the driver to 'stream' the results back one row
at a time.
To enable this functionality, you need to create a Statement
instance in the following manner:
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,
java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);
The combination of a forward-only, read-only result set,
with a fetch size of Integer.MIN_VALUE serves as a signal to
the driver to “stream” result sets row-by-row.
After this any result sets created with the statement will
be retrieved row-by-row.
There are some caveats with this approach. You will have to
read all of the rows in the result set (or close it) before
you can issue any other queries on the connection, or an
exception will be thrown.
The earliest the locks these statements hold can be released
(whether they be MyISAM
table-level locks
or row-level locks in some other storage engine such as
InnoDB
) is when the statement completes.
If the statement is within scope of a transaction, then
locks are released when the transaction completes (which
implies that the statement needs to complete first). As with
most other databases, statements are not complete until all
the results pending on the statement are read or the active
result set for the statement is closed.
Therefore, if using “streaming” results, you
should process them as quickly as possible if you want to
maintain concurrent access to the tables referenced by the
statement producing the result set.
-
ResultSetMetaData
The "isAutoIncrement()" method only works when using MySQL
servers 4.0 and newer.
-
Statement
When using versions of the JDBC driver earlier than 3.2.1,
and connected to server versions earlier than 5.0.3, the
"setFetchSize()" method has no effect, other than to toggle
result set streaming as described above.
MySQL does not support SQL cursors, and the JDBC driver
doesn't emulate them, so "setCursorName()" has no effect.