Advertisement
Guest User

Untitled

a guest
May 7th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. package Classes;
  2. import java.sql.*;
  3.  
  4.  
  5.  
  6.  
  7. public class SQLConnector{
  8. public void CreateConnection() throws SQLException{
  9. Connection myConn = null;
  10. Statement myStmt = null;
  11. ResultSet myRs = null;
  12.  
  13. String user = "root";
  14. String pass = "";
  15. try {
  16.  
  17. myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/AMYSQLsémaneve", user, pass);
  18.  
  19. myStmt = myConn.createStatement();
  20. /*
  21. myRs = myStmt.executeQuery("SELECT * FROM TÁMLANEVE");
  22.  
  23. while(myRs.next()){
  24. System.out.println(myRs.getString("OSZLOPNEVE"));
  25. }*/
  26. }
  27. catch (SQLException ex) {
  28. ex.printStackTrace();
  29. }
  30. finally{
  31. if(myRs != null)
  32. myRs.close();
  33. if(myStmt != null)
  34. myStmt.close();
  35. if(myConn != null)
  36. myConn.close();
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement