Advertisement
Guest User

Untitled

a guest
May 10th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1.  
  2. public static void connectMYSQL() {
  3.  
  4. try {
  5. System.out.println("[PixelMV] Verbindung zur Datenbank wird hergestellt!");
  6. conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb?" + "user=testuser");
  7. System.out.println("[PixelMV] Verbindung zur Datenbank hergestellt!");
  8. } catch (SQLException e) {
  9. System.out.println("[PixelMV] Es gab einen Fehler!");
  10. e.printStackTrace();
  11. }
  12.  
  13. }
  14.  
  15.  
  16. public static void update(String up) {
  17. try {
  18. Statement s = conn.createStatement();
  19. s.executeUpdate(up);
  20. s.close();
  21. } catch (SQLException e) {
  22. e.printStackTrace();
  23. }
  24. }
  25.  
  26. public static ResultSet query(String up) {
  27. ResultSet r = null;
  28.  
  29. try{
  30. Statement s = conn.createStatement();
  31. r = s.executeQuery(up);
  32. }catch(SQLException e) {
  33. e.printStackTrace();
  34. }
  35. return r;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement