I am getting the following error:
java.sql.SQLException: Before start of result set.
The problem is occurring at:
c = rs.getInt("current_connections");
Below is my code:
import java.sql.*
import java.io.*;//delete
import java.util.*;//delete
//This class reads Master.txt file, so contents may be modified by writer
class Reader1 {
public Reader1(
String command){
System.out.println("reader 1 has been called");
try {
int c;
int m;
Statement stmt;
System.out.println("reader 1 before sql");
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/jdbase?user=xxx&password=xxx");
String query = "SELECT current_connections, max_connections FROM master WHERE compid ='xxx'";
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
System.out.println("reader 1 after sql");
c = rs.getInt("current_connections");
m = rs.getInt("max_connections");
stmt.close();
conn.close();
System.out.println("got sql values");
//add c and m to an array called mast_arr
Chat6.mast_array[0]=c;
Chat6.mast_array[1]=m;
}//end try
catch (Exception ex) {
System.out.println(ex);
}
}
}