Bug #72713 Hitting ClassCastException trying to establish a jdbc connection with Fabric
Submitted: 21 May 2014 20:29 Modified: 3 Apr 2015 17:00
Reporter: Fernando Ipar (OCA) Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.30 OS:Mac OS X (10.9.2)
Assigned to: Jess Balint CPU Architecture:Any
Tags: fabric

[21 May 2014 20:29] Fernando Ipar
This happens with java version 1.7.0_55

When I try to establish a jdbc connection with a Fabric server, I get a ClassCastException when Fabric returns the group information. 

How to repeat:
I am running this simple test: 

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;

public class FabricSample {
    private static final String url = "jdbc:mysql:fabric://";
    private static final String user = "fabric";
    private static final String password = "f4bric";

     * @param args the command line arguments
    public static void main(String[] args) throws Exception {
        Connection c = DriverManager.getConnection(url + "&fabricServerGroup=mycluster", user, password);
        ResultSet rs = c.createStatement().executeQuery("select @@version as version");

And when I run it, I get this: 

Exception in thread "main" java.sql.SQLException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:80)
	at java.sql.DriverManager.getConnection(DriverManager.java:571)
	at java.sql.DriverManager.getConnection(DriverManager.java:215)
	at fabricsample.FabricSample.main(FabricSample.java:29)

Here is what the mysqlfabric utility prints about the group: 

[vagrant@store ~]$ mysqlfabric group lookup_servers mycluster
Command :
{ success     = True
  return      = [{'status': 'SECONDARY', 'server_uuid': '48203e5c-df8a-11e3-b486-0800274fb806', 'mode': 'READ_ONLY', 'weight': 1.0, 'address': ''}, {'status': 'FAULTY', 'server_uuid': '4d42bb56-df8a-11e3-b486-0800274fb806', 'mode': 'READ_WRITE', 'weight': 1.0, 'address': ''}, {'status': 'PRIMARY', 'server_uuid': '53d55f9d-df8a-11e3-b487-0800274fb806', 'mode': 'READ_WRITE', 'weight': 1.0, 'address': ''}]
  activities  = 
[22 May 2014 22:58] Jess Balint
Thank you for the bug report.
[24 Sep 2014 15:32] Fernando Ipar
This exception does not happen when using Connector/J 5.1.32 with Fabric from mysql-utilities 1.5.1. 
[3 Apr 2015 17:00] Jess Balint
Fixed in 5.1.32 (supports Fabric 1.5+)