Description:
When Try to connenct to mysql server and do a simpler insert operations. exception populated . The version of mysql server is '6.0.11-alpha-community'. And the driver is Connector/J mysql-connector-java-5.1.26-bin.jar .
When the readOnly is not set the exception is like :
---------------------------------------------------------------------
SQLException: Could not retrieve transation read-only status server
SQLState: S1000
VendorError: 0
java.sql.SQLException: Could not retrieve transation read-only status server
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:951)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:941)
at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3939)
at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3910)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:757)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:732)
at razorcaseeditor.migration.MysqlMigrator.main(MysqlMigrator.java:42)
Caused by: java.sql.SQLException: Unknown system variable 'tx_read_only'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2812)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2761)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1612)
at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3933)
... 4 more
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:"C:\Program Files\HP\Unified Functional Testing\bin\java_shared\classes";"C:\Program Files\HP\Unified Functional Testing\\bin\java_shared\classes\jasmine.jar"
when set ReadOnly to false; the exception is changed to
-----------------------------------------------------------------------------
SQLException: Unknown system variable 'transaction'
SQLState: HY000
java.sql.SQLException: Unknown system variable 'transaction'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2812)
at com.mysql.jdbc.ConnectionImpl.setReadOnlyInternal(ConnectionImpl.java:5490)
at com.mysql.jdbc.ConnectionImpl.setReadOnly(ConnectionImpl.java:5483)
at razorcaseeditor.migration.MysqlMigrator.main(MysqlMigrator.java:41)
VendorError: 1193
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:"C:\Program Files\HP\Unified Functional Testing\bin\java_shared\classes";"C:\Program Files\HP\Unified Functional Testing\\bin\java_shared\classes\jasmine.jar"
-------------------------------------------------------------------------
don't know how to continue , please help.
thanks
Xavier
How to repeat:
Please try code
-----------------------
public static void main(String[] args) {
Connection conn = null;
try {
Statement stmt = null;
conn =
DriverManager.getConnection("jdbc:mysql://10.65.68.132/razortest?" +
"user=razortest&password=test123");
stmt = conn.createStatement();
boolean rs1 = stmt.execute(" insert into rc_test values (\"1\",2,\"3\");");
} catch (SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
}
---------------------------
DROP TABLE IF EXISTS `razortest`.`rc_test`;
CREATE TABLE `razortest`.`rc_test` (
`one` varchar(10) DEFAULT NULL,
`two` smallint(6) DEFAULT NULL,
`name` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
---------------------------
CREATE DATABASE `razortest` /*!40100 DEFAULT CHARACTER SET latin1 */;
---------------------------
Connection/J version : mysql-connector-java-5.1.26-bin.jar
Mysql serversion : '6.0.11-alpha-community'
Suggested fix:
Seems issue is in com.mysql.jdbc.ConnectionImpl using the wrong way to try to get a value from server . I am not sure this is a issue or not.