Guest User

Untitled

a guest
Sep 13th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. communication link failure in java
  2. package com.retrieve;
  3. import java.sql.*;
  4.  
  5. public class retrieve{
  6. public static void main(String[] args) {
  7. System.out.println("Getting All Rows from a table!");
  8. Connection con = null;
  9. String url = "jdbc:mysql://192.168.1.249:3306/";
  10. String db = "login";
  11. String driver = "com.mysql.jdbc.Driver";
  12. String user = "root";
  13. String pass = "";
  14. try{
  15. Class.forName(driver).newInstance();
  16. con = DriverManager.getConnection(url+db, user, pass);
  17. try{
  18. Statement st = con.createStatement();
  19. ResultSet res = st.executeQuery("SELECT * FROM login");
  20. System.out.println("username: " + "t" + "password: ");
  21. while (res.next()) {
  22. String s = res.getString("username");
  23. String s1 = res.getString("password");
  24. System.out.println(s1 + "tt" + s);
  25. }
  26. con.close();
  27. }
  28. catch (SQLException s){
  29. System.out.println("SQL code does not execute.");
  30. }
  31. }
  32. catch (Exception e){
  33. e.printStackTrace();
  34. }
  35. }
  36. }
  37.  
  38. GRANT ALL ON YOUR_DB.* TO 'root'@'192.168.1.249';
Add Comment
Please, Sign In to add comment