Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(table.getSelectionModel().getSelectedItems().iterator().hasNext()) {
- db.insertOrder(new Bestellung(customerid,table.getSelectionModel().getSelectedItems().iterator().next()));
- String ct = "CREATE TABLE Order (" + "Order_Id integer generated always as identity, " + "CUSTOMER_ID BIGINT" + "ISBN, CHAR(13) " + "PRIMARY KEY(Order_Id))";
- String i = "INSERT INTO ORDER(CUSTOMER_ID,ISBN), VALUES(?,?)";
- Connection conn = null;
- PreparedStatement stmt = null;
- try {
- conn = DriverManager.getConnection(connString);
- stmt = conn.prepareStatement(i);
- conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
- stmt.setLong(1, order.getCustomerId());
- stmt.setString(2, order.getBuch().getISBN());
- stmt.executeUpdate();
- } catch (SQLException e) {
- System.out.println(e.getMessage());
- e.printStackTrace();
- }
- finally {
- try {
- if (stmt != null)
- stmt.close();
- if (conn != null)
- conn.close();
- } catch (SQLException e) {
- System.out.println(e.getMessage());
- e.printStackTrace();
- }
- }
- INSERT INTO ORDER(CUSTOMER_ID,ISBN), VALUES(?,?)
- ^
- ... + "ISBN, CHAR(13) " + ...
- ^
Add Comment
Please, Sign In to add comment