【发布时间】:2016-04-07 03:44:27
【问题描述】:
我在 Eclipse 和 Firebird 数据库中有一个 Maven JavaFX 项目,它带有 UTF-8 表编码(俄语表中的数据)。当我尝试使用命令 jfx:run 从 Eclipse 运行它时 - 它成功并且在 TableView 中我看到所有数据都是正确的。
但是,当我尝试使用命令jfx:native 创建本机安装程序并设置结果包时,TableViews 中的所有数据都是不正确的编码(通过互联网搜索得到提示,需要从 UTF-8 转换数据到 WINDOWS-1251)。
从数据库中填充数据的代码:
private class GetClientListTask extends Task<ObservableList<Client>> {
@Override
protected ObservableList<Client> call() throws Exception {
try (Connection connection = DriverManager.getConnection(App.DB_CONNECTION_STRING, App.DB_USERNAME, App.DB_PASSWORD)) {
com.zvpblog.KomstarService.model.jooq.tables.Client t = com.zvpblog.KomstarService.model.jooq.tables.Client.CLIENT;
DSL.using(connection).
selectFrom(t).
orderBy(t.CLIENTID.desc()).
fetch().
map(rs -> new Client(rs.getClientid(), DateTimeUtils.convertToLocalDate(rs.getRegdate()), rs.getLname(), rs.getFname(), rs.getMname(), rs.getGender(), DateTimeUtils.convertToLocalDate(rs.getBirthdate()), rs.getAddress(), rs.getPhone())).
forEach(c -> clients.add(c));
clientTableViewData = FXCollections.observableArrayList(clients);
return clientTableViewData;
} catch (SQLException e) {
LOGGER.error(e);
return null;
}
}
}
为什么在运行模式下编码正确,而在原生包中不正确?
【问题讨论】:
-
我看到标题很好。您从哪里填充数据?
-
@Eng.Fouad 是的,所有 UI 元素标签都很好,只有数据库中的数据编码不正确。添加代码发布(我在
init方法中调用Platform.runLater中的服务)。
标签: java maven javafx javafx-8