gpt4 book ai didi

java - 带有 JDBC 的 Gluon 示例项目在 iOS 设备上不起作用

转载 作者:行者123 更新时间:2023-11-29 01:29:21 27 4
gpt4 key购买 nike

我有使用 Gluon + JDBC 的简单代码。我可以在 Android 设备上连接此代码,但不能在 Ipad 上连接。

我的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.**.*']
}
}
}

这是 Java 代码:

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;
}

正如我所说,这段代码适用于 Android,但不适用于我的 Ipad。

./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)

我尝试了不同的连接字符串,但结果是相同的。

有人可以告诉我为什么我的代码不能在 iPad 上运行吗?

谢谢埃尔坎·卡普兰

最佳答案

连接器中使用的编码似乎发生了变化。

这是适用于我的 iOS 的最新版本:

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

对于较新的版本(3.1.13+),我发现了与您看到的相同的异常:

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

最后,您的 build.gradle 文件中有一个拼写错误:

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.**.*']
}
}

确保这是您设置选项的方式:

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')
}
}

关于java - 带有 JDBC 的 Gluon 示例项目在 iOS 设备上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33610529/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com