SQLite and JAVA
I may edit this post again after publish. A sample Java code with SQLite.
package package;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
public class MyClass {
private Connection con;
private Statement stat;
private ResultSet rs;
private PreparedStatement pre;
public static void main(String[] args) {
try{
Class.forName("org.sqlite.JDBC");
Connection con= DriverManager.getConnection("jdbc:sqlite:mydata.db");
Statement stat= con.createStatement();
// stat.execute("CREATE TABLE mydata( Name VARCHAR(13) PRIMARY KEY, Address VARCHAR(50) NOT NULL);");
PreparedStatement pre=con.prepareStatement("insert into mydata values(?,?);");
pre.setString(1, "Aruz");
pre.setString(2, "Center of the World");
pre.addBatch();
con.setAutoCommit(false);
pre.executeBatch();
ResultSet rs= stat.executeQuery("select * from stok;");
while(rs.next()){
System.out.println("Name : "+ rs.getString("Name"));
System.out.println("Address : "+ rs.getString("Address"));
}
rs.close();
con.close();
}
catch(Exception e){
System.out.println("Error : "+ e);
}
}
}
And this is the output:
Name : Aruz
Address : Center of the World
