Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void connect () {
- try{
- Class.forName("com.mysql.jdbc.Driver");
- String servername = "potsdam-moodle.de";
- String datenbank = "e209123";
- String url = "jdbc:mysql://" + servername + "/" + datenbank;
- String username = "e209123";
- String password = "Wh3c#3a3";
- Connection connection = DriverManager.getConnection(url, username, password);
- } catch (Exception e){
- e.printStackTrace();
- System.out.println("Error" + e);
- }
- }
- public void update(Float preis, String spalte) {
- try {
- connect();
- String query = "Update Produkte SET Preis= ? Where Name= ?";
- PreparedStatement st = connection.prepareStatement(query);
- st.setFloat(1, preis);
- st.setString(2, spalte);
- st.executeUpdate();
- }
- catch (Exception e){
- e.printStackTrace();
- System.out.println("Error" + e);
- }
- }
- tableView2Column2.setOnEditCommit(new EventHandler<CellEditEvent>() { //Anfang
- public void handle(CellEditEvent t){
- update(Float.parseFloat(""+t.getNewValue()), ((Produkt) t.getTableView().getItems().get(t.getTablePosition().getRow())).getName());
- }
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement