Koneksi sqlite3 di java









/****[SOURCE CODE]*****/
import java.sql.Connection;
import java.sql.DriverManager;

public class SQLiteJDBC {
  public static void main( String args[] ) {
      Connection c = null;
      
      try {
         Class.forName("org.sqlite.JDBC");
         c = DriverManager.getConnection("jdbc:sqlite:$lokasidb");// $lokasidb = lokasi database ex : /home/qnoy/sqlite_folder/testqq.db
      } catch ( Exception e ) {
         System.err.println( e.getClass().getName() + ": " + e.getMessage() );
         System.exit(0);
      }
      System.out.println("Opened database successfully");
   }
}
tested with :
sqlite3 :  3.21.0
java : openjdk version 1.8.0_151

IDE :
BlueJ : v4.1.2



Sumber : 
http://www.sqlitetutorial.net/sqlite-java/sqlite-jdbc-driver/
https://www.tutorialspoint.com/sqlite/sqlite_java.htm
https://bitbucket.org/xerial/sqlite-jdbc/downloads/

Comments