jak zapisać wynik do JTextArea
Mam pytanie - jak napisać wynik / wybór DB do JTextArea. Moja metoda JButton to:
public void actionPerformed(ActionEvent evt){
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Connection OK");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/filisng", "root", "passw");
statement = connection.createStatement();
result = statement.executeQuery("select * from `filisng`.`names`");
while(result.next()){
String nam = result.getString("Name");
String surnam = result.getString("Surname");
System.out.printf("Name: %s\tSurname: %s\t\n", Name, Surname);
}
}catch(ClassNotFoundException ex){System.out.println("Class Not Found! " +ex);
}catch(SQLException exception){
System.out.println("SQL Error " + exception);
}
}
Jeśli używamSystem.out.printf("Name: %s\tSurname: %s\t\n", Name, Surname);
- Widzę dane wyjściowe w konsoli, ale jak ustawić tekst w JTextArea?