0
我想獲得連接到SQLite數據庫(在Windows 8上使用Eclipse)。只要路徑名不包含任何特殊字符(如「é」),一切都可以正常工作。我試圖將其轉換爲UTF-8(因爲我在http://www.sqlite.org/c3ref/open.html上閱讀它應該是),但它不起作用。我得到「內存不足」異常(SQLException),意味着沒有找到數據庫文件。在打開SQLite數據庫連接的路徑中的特殊字符
這就是我所做的代碼摘要:
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
// ...
}
感謝您的幫助!
太棒了!謝謝你的幫助! :) – casaout 2012-08-10 14:37:19