I am new in Java. I am doing this thing it creates error, please let me know why I am going in this function dispatchUncaughtException. Am I doing right ? If I am not so how can this thing possible ?
This is dataCollection Class
public class dataCollection {
private ResultSet my_rs1 = null;
public ResultSet mydata()
{
try
{
String get_data_query = "SELECT * FROM my_table ";
my_rs1 = cn.stmt.executeQuery(aggregator_data_query);
} catch(SQLException SQLex)
{
System.out.println("SQL Error: " + SQLex.getMessage());
}
return my_rs1;
}
}
This is callingClass // where we call ResultSet
public class callingClass
{
dataCollection dc = new dataCollection;
private ResultSet my_call_data = dc.mydata();
while(my_call_data.next())
{
//Code Here
}
}
EDIT
Exception in thread "Thread-2" java.lang.NullPointerException
at sms_sender.dataCollection.aggregator_data(dataCollection.java:29)
at sms_sender.threadClass.run(threadClass.java:27)