Posted in SQLite
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package sqliteproject; /** * * @author azhar */ import java.sql.*; public class SQLiteProject { /** * @param args the command line arguments */ public static void main(String[] args) throws Exception { Class.forName("org.sqlite.JDBC"); Connection con = DriverManager.getConnection("jdbc:sqlite:belajarSQLite.db"); Statement stat = con.createStatement(); stat.executeUpdate("drop table if exists mahasiswa;"); stat.executeUpdate("create table mahasiswa (nama, jurusan);"); PreparedStatement prep = con.prepareStatement("insert into mahasiswa values (?, ?);"); prep.setString(1, "Azuharu"); prep.setString(2, "Komputasi Statistik"); prep.addBatch(); prep.setString(1, "Julia"); prep.setString(2, "Statistik Kependudukan"); prep.addBatch(); prep.setString(1, "Katia"); prep.setString(2, "Statistik Ekonomi"); prep.addBatch(); con.setAutoCommit(false); prep.executeBatch(); con.setAutoCommit(true); ResultSet rs = stat.executeQuery("select * from mahasiswa;"); while (rs.next()){ System.out.println("nama = " + rs.getString("nama")); System.out.println("jurusan = " + rs.getString("jurusan")); } rs.close(); con.close(); } }Silakan di run, dan tahap pertama belajar SQLite udah terlampaui :-) Sourcecode pemrograman Java dengan Database SQLite beserta library SQLite bisa didownload disini