I have a method, which simply return a string value. It is first required to connect to a mysql database @ db4free.net (I have check and made sure that there are no problems whilst connecting). Then there is a PreparedStatement In which the query SELECT * FROM ip is executed. ResultSet stores the query result but when I do result.getString(1) it returns nothing. Here's my code below (The class Client extends Connector btw)
public String ObtainServerIP(){
if(MYSQLConnection!=null){
try{
PreparedStatement state = MYSQLConnection.prepareStatement("SELECT * FROM "+TableName);
result = state.executeQuery();
result.next();
return result.getString(1);
}catch(Exception e){
return ""+e;
}
}
return "wot m8";
}
The code above is in the Connector class.
The code below is what needs to print the stuff out. (I've even tried index 0 on result set, still nothing).
public void run(){
while(AppRunning){
if(DatabaseConnection){
System.out.println(ObtainServerIP());
AppRunning=false;
}
}
}
Yes the loop is working fine, DatabaseConnection is true and the loop makes it ways into the if statement. However nothing print's out. Even an exception isn't being printed out. Here's a snapshot from my MYSQL Database:
