Advertisement
Guest User

Untitled

a guest
Oct 31st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package ConnectMySQL;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.ResultSet;
  11. import java.sql.Statement;
  12.  
  13. /**
  14. *
  15. * @author ACER
  16. */
  17. public class mysql {
  18. public static void main(String[] args) {
  19. Connection con;
  20. Statement st;
  21. ResultSet rs;
  22. try {
  23.  
  24. Class.forName("com.mysql.jdbc.Driver");
  25. con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "12345678");
  26. System.out.println("You are welcome !");
  27. st = con.createStatement();
  28. String sql = "Select * from DIC";
  29. rs = st.executeQuery(sql);
  30. while(rs.next()){
  31. System.out.println(rs.getString("WORD"));
  32. }
  33.  
  34. } catch (Exception ex) {
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement