
|
Check out the MySQL syntax for UPDATE here. Here's an example that modifes a value in the customer table, created in this answer. Basically, you need to create a Statement object from a Connection and invoke executeUpdate on it, passing it the SQL UPDATE command. It returns a ResultSet containing the database rows that match your query. You can then iterate over the rows with the next method. The first call to next will position the "cursor" to the first row. You can get a particular column in that row with the getXXX methods, specifying either the column index or the column name. Make sure the database column type and the resulting variable type match, or a proper conversion is done. If types don't match, a Bad format SQLException is thrown. Main.java:
outputs:
Further Information Author of answer: Joris Van den Bogaert Comments to this answer are only viewable by members. Login or become a member! |