本地(netbeans)一切运作良好。
连接是这样的:
String Unicode = "useUnicode = true & CharacterEncoding = UTF-8 & charSet = UTF-8?";
con = DriverManager.getConnection (urlBaseDonnees + unicode, "root", "");
阅读我添加的SQL脚本:
s = new Scanner (new FileReader ("2sga_local.sql"));
// ...
while (s.hasNext ()) {
String req = new String (line.getBytes (), "UTF-8");
// ...
statementBDD.executeUpdate (req);
}
当我生成可执行文件时,数据库中的所有阿拉伯字母都可以,除了字母ف,而 f 是不知道阿拉伯语的字母。
答案 0 :(得分:0)
我终于使用您在此链接上找到的ScriptRunner
课程找到了解决方案: https://github.com/BenoitDuffez/ScriptRunner 。
您可以按如下方式使用它:
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/2sga_local" + unicode, "root", "");
ScriptRunner runner = new ScriptRunner(connection, false, false);
File fileDir = new File("2sga_local.sql");
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileDir), "UTF8"));
runner.runScript(in);