Advertisement
Guest User

Untitled

a guest
Dec 15th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. public class TestDao {
  2.  
  3. private final Connection connection;
  4.  
  5. public TestDao() throws SQLException {
  6. connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb", "root", "9891");
  7. }
  8.  
  9. public void doUpdate() throws SQLException {
  10. try (Statement statement = connection.createStatement();) {
  11. statement.executeUpdate("INSERT INTO PHOTOS (photo_id, photo_name) VALUES (5, 'dsv')");
  12. }
  13. }
  14.  
  15. public void close() throws SQLException {
  16. connection.close();
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement