Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Sedrick Jefferson
Added: Apr 25, 2018 3:11 PM
Views: 18
SQLite PreparedStatement Insert
  1. String sql = "INSERT INTO Notes(local_date_time, note) VALUES(?, ?)";
  2. try (Connection conn = DriverManager.getConnection("jdbc:sqlite:calendarFx.db");
  3.                 PreparedStatement pstmt = conn.prepareStatement(sql))
  4. {
  5.         pstmt.setString(1, ld.toLocalDate().toString());
  6.         pstmt.setString(2, note);
  7.        
  8.         pstmt.executeUpdate();
  9. }
  10. catch (SQLException ex)
  11. {
  12.         System.out.println(ex.getMessage());
  13. }