My Oracle Support Banner

Connector/J 5.1.16 Errors when URL Contains Session Variables and UTF8 Character Encoding (Doc ID 1330795.1)

Last updated on MARCH 08, 2017

Applies to:

MySQL Connectors - Version: 5.1 and later   [Release: 5.1 and later ]
Information in this document applies to any platform.

Symptoms

On : 5.1 version, Connector/J version 5.1.16

When attempting to connect via JDBC with both UTF8 character encoding and SESSION variables set in the connection string such as:

DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=root&password=password&sessionVariables=FOREIGN_KEY_CHECKS=0&characterEncoding=utf8")

the follow error occurs:

ERROR
-----------------------
...
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.getServerCharacterEncoding(ConnectionImpl.java:3100)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2095)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619)
... 18 more
SQLException: Unexpected exception encountered during query.
SQLState: S1000
...


STEPS
-----------------------
This issue can be reproduced with the following steps:
  1. Create a connection string for Connector/J defining both session variables and UTF8 character encoding.
  2. Attempt to open the connection to MySQL.

BUSINESS IMPACT
-----------------------
The issue has the following business impact:
Users cannot connect to the MySQL server using all the capabilities they employed in the previous versions. Involves waiting for patch or changing application code to get a working connection.

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
  Symptoms
  Cause
  Solution
  References

This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review.

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.