Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- communication link failure in java
- package com.retrieve;
- import java.sql.*;
- public class retrieve{
- public static void main(String[] args) {
- System.out.println("Getting All Rows from a table!");
- Connection con = null;
- String url = "jdbc:mysql://192.168.1.249:3306/";
- String db = "login";
- String driver = "com.mysql.jdbc.Driver";
- String user = "root";
- String pass = "";
- try{
- Class.forName(driver).newInstance();
- con = DriverManager.getConnection(url+db, user, pass);
- try{
- Statement st = con.createStatement();
- ResultSet res = st.executeQuery("SELECT * FROM login");
- System.out.println("username: " + "t" + "password: ");
- while (res.next()) {
- String s = res.getString("username");
- String s1 = res.getString("password");
- System.out.println(s1 + "tt" + s);
- }
- con.close();
- }
- catch (SQLException s){
- System.out.println("SQL code does not execute.");
- }
- }
- catch (Exception e){
- e.printStackTrace();
- }
- }
- }
- GRANT ALL ON YOUR_DB.* TO 'root'@'192.168.1.249';
Add Comment
Please, Sign In to add comment