字母ف仅对可执行jar有误

时间:2016-02-19 15:36:29

标签: java utf-8

本地(netbeans)一切运作良好。

  1. 在netbeans编码中是UTF-8
  2. 在Mysql中是utf8_general_ci
  3. 连接是这样的:

    String Unicode  = "useUnicode = true & CharacterEncoding = UTF-8 & charSet = UTF-8?";
    con = DriverManager.getConnection (urlBaseDonnees + unicode, "root", "");
    
  4. 阅读我添加的SQL脚本:

    s = new Scanner (new FileReader ("2sga_local.sql"));  
    // ... 
    while (s.hasNext ()) {  
      String req = new String (line.getBytes (), "UTF-8");  
      // ...
      statementBDD.executeUpdate (req);  
    }
    
  5. 当我生成可执行文件时,数据库中的所有阿拉伯字母都可以,除了字母ف,而 f 是不知道阿拉伯语的字母。

1 个答案:

答案 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);