wachteldonk
Erfahrenes Mitglied
Ich habe folgende Datenbankklasse erzeugt
Aber
erzeugt imme reinen Fehelr. Warum?
Code:
public class JDb {
public static String STRusername = "root";
public static String STRpassword = "";
public static String STRport = "3306";
public static String STRdatabase = "test";
public static String STRhost = "localhost";
public static Connection con = null;
public static Statement stmt = null;
public static ResultSet rs = null;
public void ConnectDb() {
try {
Class.forName("com.mysql.jdbc.Driver");
String connectionUrl = "jdbc:mysql://" + STRhost+ ":" + STRport +"/" + STRdatabase+ "?" + "user=" + STRusername + "&password=" + STRpassword + "";
con = DriverManager.getConnection(connectionUrl);
} catch (SQLException e) {
System.out.println("SQL Exception: "+ e.toString());
} catch (ClassNotFoundException cE) {
System.out.println("Class Not Found Exception: "+ cE.toString());
}
}
public void makeQuery(String strSQL) {
//SQL query command
this.stmt = this.con.createStatement();
this.rs = this.stmt.executeQuery(strSQL);
while(this.rs.next()) {
System.out.println("A");
}
}
}
Aber
Code:
while(this.rs.next()) {
erzeugt imme reinen Fehelr. Warum?