1

i m trying to write a simple mysql connection code with JDBC to my mysql server on my LAN on OSX.

i have, – IntelliJ 15 CE – Gluon Plugins 1.0.1 installed. – member of apple developper center – Setting mysql-connector-java.5.1.37.bin.jar in Modules and Libraries (IntelliJ) from Maven Server and saved under /Library/Java/Extensions

I can create simple IPA and APK and send/start on device with launchIOSDevice / creataIP/android (but as i say only simple Hello world)

My Problem is, if i start my code with TASKS -> RUN everythings is ok.. I have a succes message on Desktop (OSX), that the connection is OK.

But, if i try same code below to send to my Ipad, i get following errors below.

can anybody help me please, why i cant start this simple code on my ipad?

thanks erkan kaplan

my build.gradle:

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

    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
}

mainClassName = 'com.gluonapplication.GluonApplication'

jfxmobile {

    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
    ios {
        forceLinkClasses = [ 'com.gluonapplication.**.*']
        infoPList = file('src/ios/Default-Info.plist')
    }
}

How must i define my "forceLinkClassess" Line for mysql-connector-java?

my simple javafx code:

private static final String DB_CONNECTION = "jdbc:mysql://192.168.3.188:3306/test_sql";
    private static final String DB_USER = "root";
    private static final String DB_PASSWORD = "myPASSWORT";

    public static Connection connection = 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);
            alertMessage("Connection is OK");
            System.out.println("BAglanti ok");
            return  connection;
        } catch (SQLException e) {
            e.printStackTrace();
            System.out.println("CONNECTION ERROR...");
            alertMessage(e.toString());
        }

    return connection;
    }


    public static void alertMessage(String msg){
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Information");
        alert.setHeaderText("Information");
        alert.setContentText("Ergebnis : " + msg );
        alert.showAndWait();
    }

Error Logs:

[WARN] java.lang.Class: Class.forName() failed to load ‘com.mysql.jdbc.Driver’. Use the -forcelinkclasses command line option or add <forceLinkClasses><pattern>com.mysql.jdbc.Driver</pattern></forceLinkClasses> to your robovm.xml file to link it in.
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.lang.VMClassLoader.findClassInClasspathForLoader(Native Method)
..........
..........
..........
José Pereda
  • 44,311
  • 7
  • 104
  • 132

1 Answers1

0

If you want to run on iOS devices, your classes have to be added with the forceLinkClasses option, if you want RoboVM to link them.

That includes the classes on your package, and those on any third dependency you may use.

So this will work:

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

Note also that you may need an older version of the mysql connector.

Finally, Alert won't work with JavaFXPorts. JavaFX 8 Dialogs are not yet supported.

Community
  • 1
  • 1
José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • Thanks Jose, i think now is the jdbc included in my project but i have another problem. please look here [link] http://stackoverflow.com/questions/33610529/gluon-sample-proect-with-jdbc-dont-work-on-ios-device [/link] – erkan kaplan Nov 09 '15 at 13:54