F
francan00
I have the same SQL resultset in my Database class file several times
and was wondering if I can make it into a method?
public somemethod()
{
ResultSet results = null;
Statement statement = null;
....
//next two lines are repeated several times in different methods in
this class file:
results = statement.executeQuery("select sport from typetable");
results.next();
.....
My attempt outputs no data. Please advise.
public boolean mymeth()
{
try {
ResultSet results = null;
Statement statement = null;
results = statement.executeQuery("select sport from typetable");
boolean mydata = results.next();
}
catch(Exception e)
{
}
return mydata;
}
public somemethod()
{
ResultSet results = null;
Statement statement = null;
....
mymeth();
.....
and was wondering if I can make it into a method?
public somemethod()
{
ResultSet results = null;
Statement statement = null;
....
//next two lines are repeated several times in different methods in
this class file:
results = statement.executeQuery("select sport from typetable");
results.next();
.....
My attempt outputs no data. Please advise.
public boolean mymeth()
{
try {
ResultSet results = null;
Statement statement = null;
results = statement.executeQuery("select sport from typetable");
boolean mydata = results.next();
}
catch(Exception e)
{
}
return mydata;
}
public somemethod()
{
ResultSet results = null;
Statement statement = null;
....
mymeth();
.....