The following features are new, compared to the 5.0 series of Connector/J
JDBC-4.0 support for setting per-connection client information
(which can be viewed in the comments section of a query via
SHOW PROCESSLIST
on a MySQL
server, or can be extended to support custom persistence of the
information via a public interface).
Support for JDBC-4.0 XML processing via JAXP interfaces to DOM, SAX and StAX.
JDBC-4.0 standardized unwrapping to interfaces that include vendor extensions.
Functionality added or changed:
Connector/J now connects using an initial character set of
utf-8
solely for the purpose of
authentication to allow user names or database names in any
character set to be used in the JDBC connection URL.
(Bug#29853)
Added two configuration parameters:
blobsAreStrings
— Should the driver
always treat BLOBs as Strings. Added specifically to work
around dubious metadata returned by the server for
GROUP BY
clauses. Defaults to false.
functionsNeverReturnBlobs
— Should
the driver always treat data from functions returning
BLOBs
as Strings. Added specifically to
work around dubious metadata returned by the server for
GROUP BY
clauses. Defaults to false.
Setting rewriteBatchedStatements
to
true
now causes CallableStatements with
batched arguments to be re-written in the form "CALL (...); CALL
(...); ..." to send the batch in as few client-server round
trips as possible.
The driver now picks appropriate internal row representation
(whole row in one buffer, or individual byte[]s for each column
value) depending on heuristics, including whether or not the row
has BLOB
or
TEXT
types and the overall
row-size. The threshold for row size that will cause the driver
to use a buffer rather than individual byte[]s is configured by
the configuration property
largeRowSizeThreshold
, which has a default
value of 2KB.
The data (and how it is stored) for ResultSet
rows are now behind an interface which allows us (in some cases)
to allocate less memory per row, in that for "streaming" result
sets, we re-use the packet used to read rows, since only one row
at a time is ever active.
Added experimental support for statement "interceptors" via the
com.mysql.jdbc.StatementInterceptor
interface, examples are in
com/mysql/jdbc/interceptors
. Implement this
interface to be placed "in between" query execution, so that it
can be influenced (currently experimental).
The driver will automatically adjust the server session variable
net_write_timeout
when it
determines its been asked for a "streaming" result, and resets
it to the previous value when the result set has been consumed.
(The configuration property is named
netTimeoutForStreamingResults
, with a unit of
seconds, the value '0' means the driver will not try and adjust
this value).
JDBC-4.0 ease-of-development features including
auto-registration with the DriverManager
via
the service provider mechanism, standardized Connection validity
checks and categorized SQLExceptions
based on
recoverability/retry-ability and class of the underlying error.
Statement.setQueryTimeout()
s now affect the
entire batch for batched statements, rather than the individual
statements that make up the batch.
Errors encountered during
Statement
/PreparedStatement
/CallableStatement.executeBatch()
when rewriteBatchStatements
has been set to
true
now return
BatchUpdateExceptions
according to the
setting of continueBatchOnError
.
If continueBatchOnError
is set to
true
, the update counts for the "chunk" that
were sent as one unit will all be set to
EXECUTE_FAILED
, but the driver will attempt
to process the remainder of the batch. You can determine which
"chunk" failed by looking at the update counts returned in the
BatchUpdateException
.
If continueBatchOnError
is set to "false",
the update counts returned will contain all updates up-to and
including the failed "chunk", with all counts for the failed
"chunk" set to EXECUTE_FAILED
.
Since MySQL doesn't return multiple error codes for
multiple-statements, or for multi-value
INSERT
/REPLACE
,
it is the application's responsibility to handle determining
which item(s) in the "chunk" actually failed.
New methods on com.mysql.jdbc.Statement:
setLocalInfileInputStream()
and
getLocalInfileInputStream()
:
setLocalInfileInputStream()
sets an
InputStream
instance that will be used to
send data to the MySQL server for a
LOAD DATA LOCAL
INFILE
statement rather than a
FileInputStream
or
URLInputStream
that represents the path
given as an argument to the statement.
This stream will be read to completion upon execution of a
LOAD DATA LOCAL
INFILE
statement, and will automatically be closed
by the driver, so it needs to be reset before each call to
execute*()
that would cause the MySQL
server to request data to fulfill the request for
LOAD DATA LOCAL
INFILE
.
If this value is set to NULL
, the driver
will revert to using a FileInputStream
or
URLInputStream
as required.
getLocalInfileInputStream()
returns the
InputStream
instance that will be used to
send data in response to a
LOAD DATA LOCAL
INFILE
statement.
This method returns NULL
if no such
stream has been set via
setLocalInfileInputStream()
.
Setting useBlobToStoreUTF8OutsideBMP
to
true
tells the driver to treat
[MEDIUM/LONG]BLOB
columns as
[LONG]VARCHAR
columns holding text encoded in
UTF-8 that has characters outside the BMP (4-byte encodings),
which MySQL server can't handle natively.
Set utf8OutsideBmpExcludedColumnNamePattern
to
a regex so that column names matching the given regex will still
be treated as BLOBs
The regex must follow the
patterns used for the java.util.regex
package.
The default is to exclude no columns, and include all columns.
Set utf8OutsideBmpIncludedColumnNamePattern
to
specify exclusion rules to
utf8OutsideBmpExcludedColumnNamePattern". The regex must follow
the patterns used for the java.util.regex
package.
Bugs fixed:
setObject(int, Object, int, int)
delegate in
PreparedStatmentWrapper delegates to wrong method.
(Bug#30892)
NPE with null column values when
padCharsWithSpace
is set to true.
(Bug#30851)
Collation on VARBINARY
column
types would be misidentified. A fix has been added, but this fix
only works for MySQL server versions 5.0.25 and newer, since
earlier versions didn't consistently return correct metadata for
functions, and thus results from subqueries and functions were
indistinguishable from each other, leading to type-related bugs.
(Bug#30664)
An ArithmeticException
or
NullPointerException
would be raised when the
batch had zero members and
rewriteBatchedStatements=true
when
addBatch()
was never called, or
executeBatch()
was called immediately after
clearBatch()
.
(Bug#30550)
Closing a load-balanced connection would cause a
ClassCastException
.
(Bug#29852)
Connection checker for JBoss didn't use same method parameters via reflection, causing connections to always seem "bad". (Bug#29106)
DatabaseMetaData.getTypeInfo()
for the types
DECIMAL
and
NUMERIC
will return a precision
of 254 for server versions older than 5.0.3, 64 for versions
5.0.3–5.0.5 and 65 for versions newer than 5.0.5.
(Bug#28972)
CallableStatement.executeBatch()
doesn't work
when connection property
noAccessToProcedureBodies
has been set to
true
.
The fix involves changing the behavior of
noAccessToProcedureBodies
,in that the driver
will now report all paramters as "IN" paramters but allow
callers to call registerOutParameter() on them without throwing
an exception.
(Bug#28689)
DatabaseMetaData.getColumns()
doesn't contain
SCOPE_*
or
IS_AUTOINCREMENT
columns.
(Bug#27915)
Schema objects with identifiers other than the connection
character aren't retrieved correctly in
ResultSetMetadata
.
(Bug#27867)
Connection.getServerCharacterEncoding()
doesn't work for servers with version >= 4.1.
(Bug#27182)
The automated SVN revisions in
DBMD.getDriverVersion()
. The SVN revision of
the directory is now inserted into the version information
during the build.
(Bug#21116)
Specifying a "validation query" in your connection pool that starts with "/* ping */" _exactly_ will cause the driver to instead send a ping to the server and return a fake result set (much lighter weight), and when using a ReplicationConnection or a LoadBalancedConnection, will send the ping across all active connections.
User Comments
Add your own comment.