Witam.
Z niewadomych mi przyczyn poniższy kod rzuca wyjątek:
public static void RunSQLCommunication(){
java.sql.Connection connect = null;
String host = null;
String username = null;
String passwd = null;
String database = null;
String url = null;
try{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Podaj nazwe hosta: ");
host = br.readLine();
System.out.println("Podaj nazwe bazy danych: ");
database = br.readLine();
System.out.println("Podaj nazwe uzytkownika: ");
username = br.readLine();
System.out.println("Podaj haslo: ");
passwd = br.readLine();
url = "jdbc:mysql://" + host + "/" + database;
Class.forName("org.gjt.mm.mysql.Driver");
connect = DriverManager.getConnection(url, username, passwd);
System.out.println("Polaczono z baza (?): Podaj polecenie: ");
String command = br.readLine();
SQLGenerator sql1 = new SQLGenerator();
java.sql.Statement smtm = connect.createStatement();
//najprostszy sposob generowania zapytan...
java.sql.ResultSet rs = smtm.executeQuery(sql1.Console(command));
SQLJAVATableCreator TableCreator = new SQLJAVATableCreator();
DefaultTableModel ResultTable = TableCreator.CreateDataTable(rs);
for(int i = 0; i <ResultTable.getColumnCount(); i++){
for(int j = 0; j < ResultTable.getRowCount(); j++){
System.out.println(ResultTable.getValueAt(i,j));
}
}
}catch (java.sql.SQLException e) {
System.out.println(e.getMessage());
}catch(java.io.IOException e){
System.out.println(e.getMessage());
}catch(ClassNotFoundException e){
System.out.println(e.getMessage());
}
}
Użytkownik i haslo, które podaje, istnieje w systemie.
w wyniku dzialania powyższego kawałka kodu dostaje wyjątek:
"Access Denied for user: Black@ocalhost" - mySQL jest odpalony na moim komputerze.
Z MySQLFront da sie zalogować na takiego użytkownika, bo w końcu on istsnieje :)
Ma ktoś jakiś pomysł może?
Pozdrawiam.