Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @FXML
- private void InsertButtonAction(ActionEvent event) throws IOException {
- //alterar conection!
- String myDriver = "org.gjt.mm.mysql.Driver";
- String myUrl = "jdbc:mysql://localhost/test";
- Class.forName(myDriver);
- Connection conn = DriverManager.getConnection(myUrl, "root", "");
- //alterar table name
- String query = " insert into tableName (dept_no, dept_name)"
- + " values (?, ?)";
- PreparedStatement preparedStmt = conn.prepareStatement(query);
- //aletrar String
- preparedStmt.setString (1, "Numero+1 de departamentos");
- preparedStmt.setString (2, textfield.getText());
- preparedStmt.execute();
- conn.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement