// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;

public class InsertAfter5 {
    public static void main(String[] args) throws Exception {
try{
        Class.forName("org.sqlite.JDBC");
        Connection con = DriverManager.getConnection("jdbc:sqlite:asset.db");
        PreparedStatement pstmt = con.prepareStatement("INSERT INTO asset VALUES(?,?,?)");
        PreparedStatement toolpstmt = con.prepareStatement("INSERT INTO toolasset VALUES(?,?,?,?)");
        ToolAsset a = new ToolAsset(11, "Echo edger", "Edger", "Echo", 25);
        pstmt.setInt(1, a.getId());
        pstmt.setString(2, a.getDescription());
        pstmt.setInt(3, a.getAssetType());
        pstmt.executeUpdate();
        toolpstmt.setInt(1, a.getId());
        toolpstmt.setString(2, a.getToolType());
        toolpstmt.setString(3, a.getName());
        toolpstmt.setInt(4, a.getWeight());
        toolpstmt.executeUpdate();
        pstmt.close();
        toolpstmt.close();
        con.close();
} catch(Exception ex) { ex.printStackTrace(); }
    }
}
