【问题标题】:Special character in path to open SQLite database connection打开 SQLite 数据库连接的路径中的特殊字符
【发布时间】:2012-07-30 10:56:13
【问题描述】:

我正在尝试连接到 SQLite 数据库(在 Windows 8 上使用 Eclipse)。只要路径名不包含任何特殊字符(如“é”),一切正常。我试图将其转换为 UTF-8(因为我在 http://www.sqlite.org/c3ref/open.html 上读到它应该是),但它没有用。我收到“内存不足”异常 (SQLException),这意味着找不到数据库文件。

这是我所做的代码摘要:

public static String DB_PATH = "jdbc:sqlite:" + System.getProperty("user.home") + "<Rest of the path><databasename>.sqlite";

public static void main(String[] args) throws ClassNotFoundException
{
  // load the sqlite-JDBC driver using the current class loader
  Class.forName("org.sqlite.JDBC");

 Connection connection = null;
 try
 {
   // create a database connection
   connection = DriverManager.getConnection(DB_PATH);
   Statement statement = connection.createStatement();
   statement.setQueryTimeout(30);  // set timeout to 30 sec.

   // work with the database ...
   }
 }
 catch(SQLException e)
 {
   // if the error message is "out of memory", 
   // it probably means no database file is found
   System.err.println(e.getMessage());
 }
 finally
 {
   // try to disconnect
   // ...
}

感谢您的帮助!

【问题讨论】:

    标签: java database sqlite classnotfoundexception sqlitejdbc


    【解决方案1】:
    猜你喜欢
    • 2016-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-17
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    • 2020-05-18
    相关资源
    最近更新 更多