Guest User

Untitled

a guest
Dec 16th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. if(table.getSelectionModel().getSelectedItems().iterator().hasNext()) {
  2. db.insertOrder(new Bestellung(customerid,table.getSelectionModel().getSelectedItems().iterator().next()));
  3.  
  4. String ct = "CREATE TABLE Order (" + "Order_Id integer generated always as identity, " + "CUSTOMER_ID BIGINT" + "ISBN, CHAR(13) " + "PRIMARY KEY(Order_Id))";
  5.  
  6. String i = "INSERT INTO ORDER(CUSTOMER_ID,ISBN), VALUES(?,?)";
  7. Connection conn = null;
  8. PreparedStatement stmt = null;
  9. try {
  10. conn = DriverManager.getConnection(connString);
  11. stmt = conn.prepareStatement(i);
  12. conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  13. stmt.setLong(1, order.getCustomerId());
  14. stmt.setString(2, order.getBuch().getISBN());
  15. stmt.executeUpdate();
  16. } catch (SQLException e) {
  17. System.out.println(e.getMessage());
  18. e.printStackTrace();
  19. }
  20. finally {
  21.  
  22. try {
  23. if (stmt != null)
  24. stmt.close();
  25. if (conn != null)
  26. conn.close();
  27. } catch (SQLException e) {
  28. System.out.println(e.getMessage());
  29. e.printStackTrace();
  30. }
  31. }
  32.  
  33. INSERT INTO ORDER(CUSTOMER_ID,ISBN), VALUES(?,?)
  34. ^
  35.  
  36. ... + "ISBN, CHAR(13) " + ...
  37. ^
Add Comment
Please, Sign In to add comment