close

undefined

下面紀錄使用 Java 存取 SQLite 資料庫的方式:

資料庫名稱為 test.db

資料表名稱為 testTable

存取的欄位分別為 name 與 phone

SQLite 取值的時候可以指定欄位名稱與資料型別。

		Class.forName("org.sqlite.JDBC");
	    // create a database connection
	    connection = DriverManager.getConnection("jdbc:sqlite:test.db");
	    Statement statement = connection.createStatement();
	    ResultSet rs = statement.executeQuery("select * from testTable");
		while(rs.next()){
			System.out.println(rs.getString("name") + " " + rs.getString("phone"));
		}

 

arrow
arrow
    全站熱搜

    葛瑞斯肯 發表在 痞客邦 留言(0) 人氣()