/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testprintblogs;
import java.sql.*;
public class TestPrintBlogs
{
public static void main(String[] args) throws Exception
{
Class.forName("org.sqlite.JDBC");
try (Connection conn = DriverManager.getConnection("jdbc:sqlite:myMarker.db")) {
Statement stat = conn.createStatement();
stat.executeUpdate("drop table if exists marker;");
stat.executeUpdate("create table marker (marker_id, marker_type, marker_gen, marker_exp, marker_prio, marker_mm, marker_event, marker_lr);");
PreparedStatement prep = conn.prepareStatement("insert into marker values (?, ?, ?, ?, ?, ?, ?, ?);");
prep.setString(1, "1234");
prep.setString(2, "M1");
prep.setString(3, "24.12.2011");
prep.setString(4, "25.12.2012");
prep.setString(5, "0");
prep.addBatch();
prep.setString(1, "2345");
prep.setString(2, "M1");
prep.setString(3, "24.10.2011");
prep.setString(4, "25.11.2012");
prep.setString(5, "1");
prep.addBatch();
prep.setString(1, "3456");
prep.setString(2, "M2");
prep.setString(3, "24.08.2010");
prep.setString(4, "25.09.2011");
prep.setString(5, "0");
prep.addBatch();
conn.setAutoCommit(false);
prep.executeBatch();
conn.setAutoCommit(true);
String sql = "SELECT * FROM marker WHERE marker_id = ?;";
prep = conn.prepareStatement(sql);
prep.setString(1,"3456");
ResultSet rs1 = prep.executeQuery();
while (rs1.next())
{
System.out.println("marker_ID = " + rs1.getString("marker_id"));
System.out.println("marker_TYPE = " + rs1.getString("marker_type"));
}
rs1.close();
}
}
}