2012-02-14 15 views
0

システムのデスクトップにlocalEntry.sqliteという名前のSQLiteデータベースファイルがあります。私はこのデータベースのテーブルの1つのデータを読みたいと思います。 localEntry.sqliteファイルは私のJavaProjectであるときは、このために私はすべてのデータ形式テーブルの1:SQLite接続文字列設定

public class SqliteDbRead { 

private static String col1; 
private static String col2; 


public static void main(String[] args) throws 
    SQLException, ClassNotFoundException { 

    //Get Connection 
    Class.forName("org.sqlite.JDBC"); 
    Connection con = DriverManager.getConnection("jdbc:sqlite:localEntry.sqlite"); 

    //obtain a statement 
    Statement st = con.createStatement(); 
    String query = "select * from submitted_table"; 

    //Execute Query 
    ResultSet rs = st.executeQuery(query); 

    while (rs.next()) { 

     col1 = rs.getString("col1"); 
     col2 = rs.getString("col2"); 


    } //while 
    con.close(); 
} //main 
} 

このコードは正常に動作アクセスするには、Eclipseでコードを記述します。ここでは、このデータベースファイルがデスクトップ上または他の場所のコンピュータにある場合、接続文字列(または他の方法)が何であるかわかりません。

答えて