Prueba el siguiente código
public int num() throws Exception {
try {
// This will load the MySQL driver, each DB has its own driver
Class.forName("com.mysql.jdbc.Driver");
// Setup the connection with the DB
connect = DriverManager.getConnection("jdbc:mysql://localhost/testdb?"
+ "user=root&password=");
// Statements allow to issue SQL queries to the database
statement = connect.createStatement();
resultSet = statement.executeQuery("select count(*) from testdb.emg");
while (resultSet.next()) {
return resultSet.getInt(1);
}
} catch (Exception e) {
}
Debajo había error
-
public void num() throws Exception {
debería ser
public int num() throws Exception {
-
Para contar el total de filas, debe usar la consulta
select count(*) from testdb.emg
Avísame en caso de cualquier problema.