Created
June 18, 2019 10:10
-
-
Save dewanshrawat15/1fd22ab2ac5996c99d63a702d1bd52cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String url = "jdbc:mysql://localhost:3306/testdb?useSSL=false"; | |
String user = ""; | |
String password = ""; | |
String author = "me"; | |
String sql = "UPDATE table_name SET name = name1, email = email1, ...WHERE condition;"; | |
try (Connection con = DriverManager.getConnection(url, user, password); | |
PreparedStatement pst = con.prepareStatement(sql)) { | |
pst.setString(1, author); | |
pst.executeUpdate(); | |
System.out.println("A new column inserted"); | |
} catch (SQLException ex) { | |
Logger lgr = Logger.getLogger(JdbcPrepared.class.getName()); | |
lgr.log(Level.SEVERE, ex.getMessage(), ex); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment