0

i have simple code with Gluon + JDBC. I can connect this code on Android Device but not on Ipad.

my build.gradle;

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.0.6'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
}
dependencies {
    compile 'mysql:mysql-connector-java:5.0.2'
    iosRuntime 'mysql:mysql-connector-java:5.0.2'
}

mainClassName = 'com.mtt8.version15'

jfxmobile {
    android {
        manifest = 'src/android/AndroidManifest.xml'
        packagingOptions {
            exclude 'META-INF/INDEX.LIST'
        }

        ios {
            infoPList = file('src/ios/Default-Info.plist')
            forceLinkClasses = ['com.mtt8.**.*', 'com.mysql.**.*']
        }
    }
}

and here is JavaCode:

private static final String serverIP="192.168.3.188";
    private static final String DB_DRIVER = "com.mysql.jdbc.Driver";
    private static final String DB_CONNECTION = "jdbc:mysql://192.168.3.188:3306/kasse_sql?useUnicode=true&characterEncoding=UTF-8";
    private static final String DB_USER = "root";
    private static final String DB_PASSWORD = "MYPASSWORD";

    public static Connection connection = null;
    public static Statement statement = null;
    public static String SQL = null;

    public static PreparedStatement pst = null;


    public static Connection getDBConnection(){

        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        try {
            //connection = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD);
            connection = DriverManager.getConnection("jdbc:mysql://192.168.3.188:3306/kasse_sql?user=root&password=MYPASSWORD&useUnicode=true&characterEncoding=UTF-8");
            msg.setText("Connection is OK");
            return  connection;
        } catch (SQLException e) {
            e.printStackTrace();
            msg.setText("Dont Connection");
        }

        return connection;
    }

As i say, this code working with Android but not on my Ipad.

I get following errors after ./gradlew launchIOSDevice

java.sql.SQLException: Unsupported character encoding 'Cp1252'
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
    at com.mysql.jdbc.Buffer.readString(Buffer.java:430)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2823)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:812)
    at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3269)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1182)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2644)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
    at java.sql.DriverManager.getConnection(DriverManager.java:179)
    at java.sql.DriverManager.getConnection(DriverManager.java:144)
    at com.mtt8.version15.getDBConnection(version15.java:58)
    at com.mtt8.version15.start(version15.java:32)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.LauncherImpl$$Lambda$9.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl$$Lambda$7.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at com.sun.javafx.application.PlatformImpl$$Lambda$19.run(Unknown Source)
    at java.security.AccessController.doPrivileged(AccessController.java:52)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.javafx.application.PlatformImpl$$Lambda$6.run(Unknown Source)
    at org.robovm.apple.uikit.UIApplication.main(Native Method)
    at org.robovm.apple.uikit.UIApplication.main(UIApplication.java:384)
    at org.javafxports.jfxmobile.ios.BasicLauncher.main(BasicLauncher.java:115)
IOSWindowSystemInterface : setSwapInterval unimp
setSwapInterval(1)
ES2ResourceFactory: Prism - createStockShader: FillPgram_Color.frag
ES2ResourceFactory: Prism - createStockShader: Texture_Color.frag
ES2ResourceFactory: Prism - createStockShader: Solid_TextureRGB.frag
IOSWindowSystemInterface : setSwapInterval unimp
setSwapInterval(0)

i have tried with diffently connection strings but result is same.

Can anybody please say me why my code dont working on Ipad?

thanks erkan kaplan

José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • Check your `build.gradle` file, it seems you have included `iOS` within `android` settings. Or is it a typo posting the code? – José Pereda Nov 09 '15 at 13:59
  • my build.gradle is like above...i have add only the line with "iosRuntime" – erkan kaplan Nov 09 '15 at 14:02
  • That line is not necessary, it will be added from the first dependency. And check this: `jfxmobile { android { manifest = 'src/android/AndroidManifest.xml' packagingOptions { exclude 'META-INF/INDEX.LIST' } } ios { infoPList = file('src/ios/Default-Info.plist') forceLinkClasses = ['com.mtt8.**.*', 'com.mysql.**.*'] } }` – José Pereda Nov 09 '15 at 14:04
  • Sorr jose, i dont understand you, what you mean. here is my code: – erkan kaplan Nov 09 '15 at 14:15
  • dependencies { compile 'mysql:mysql-connector-java:3.1.14' } mainClassName = 'com.mtt8.version15' jfxmobile { android { manifest = 'src/android/AndroidManifest.xml' packagingOptions { exclude 'META-INF/INDEX.LIST' } } ios { infoPList = file('src/ios/Default-Info.plist') forceLinkClasses = ['com.mtt8.**.*', 'com.mysql.**.*'] } } is same result.... – erkan kaplan Nov 09 '15 at 14:47

1 Answers1

1

It seems there's a change in the encoding used in the connector.

This is the latest version that works for me on iOS:

dependencies {
    compile 'mysql:mysql-connector-java:3.1.12'
}

For newer versions (3.1.13+), I find the same exception you see:

java.sql.SQLException: Unsupported character encoding 'Cp1252'.
at com.mysql.jdbc.StringUtils.getBytes(StringUtils.java)

Finally, there is a typo on your build.gradle file:

jfxmobile {
    android {
        manifest = 'src/android/AndroidManifest.xml'
        packagingOptions {
            exclude 'META-INF/INDEX.LIST'
        }
        // typo!! iOS should be outside android!
        ios {
            infoPList = file('src/ios/Default-Info.plist')
            forceLinkClasses = ['com.mtt8.**.*', 'com.mysql.**.*']
        }
    }

}

Make sure this is how you set your options:

jfxmobile {
    android {
        manifest = 'src/android/AndroidManifest.xml'
        packagingOptions {
            exclude 'META-INF/INDEX.LIST'
        }
    }

    ios {
        forceLinkClasses = [ 'com.gluonhq.**.*', 'com.mysql.**.*']
        infoPList = file('src/ios/Default-Info.plist')
    }
}
José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • Thanks you Jose, ;.) I correct my typo and set my IOS Lines in build.gradle....Now i have a connection on Ipad AIR...But only with version 3.1.12.....What you things, its a bug from robovm side or jdbc side? – erkan kaplan Nov 09 '15 at 14:57
  • I can't tell. Those mysql versions are really old, and they were not intended for mobile devices. As an aside, if you think the answers are valid, please mark them as accepted, so others can find them and benefit from them as well. – José Pereda Nov 09 '15 at 15:03
  • Jose, but the Version 5.0.2 working with Android but not on Ipad..... On Ipad working only Version 3.1.12.....It seems it s bug in robovm... – erkan kaplan Nov 09 '15 at 15:05
  • Feel free to report it to them, if you think it's that the case. – José Pereda Nov 09 '15 at 15:06
  • ok, i do it and try to open a bug on robovm ....How can accept your answer as valid? (sorry i m new on stackoverflow) – erkan kaplan Nov 09 '15 at 15:09
  • Just on the top left of my answer, there's a check you can click. You can vote as well when you have enough reputation. – José Pereda Nov 09 '15 at 15:10