Advertisement
Guest User

TRY LANG

a guest
Apr 8th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. try{
  2. Class.forName("com.mysql.jdbc.Driver");
  3. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb?autoReconnect=true&useSSL=false", "root", "admin");
  4.  
  5. PreparedStatement ps;
  6.  
  7. String query = "INSERT INTO test_table values(?)";
  8. ps = con.prepareStatement(query);
  9.  
  10. ps.setString(1, string);
  11.  
  12. ps.executeUpdate();
  13.  
  14. ps.close();
  15. con.close();
  16. }
  17. catch (Exception e)
  18. {
  19. System.out.println(e);
  20. }
  21. return "Success";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement