2012-08-01 5 views
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 
    // ... 
} 

감사합니다!

답변