I'm having trouble returning a resultset in this method. It says that my resutset might not have been initialized. Thanks,
Justin
public static ResultSet runQuery(
String q)
{
ResultSet RS;
try
{
// The newInstance() call is a work around for some
// broken
Java implementations
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
}
catch (Exception E)
{
System.err.println("Unable to load driver.");
E.printStackTrace();
}
try
{
//
jdbc:mysql://[hostname][:port]/dbname[?param1=value1][¶m2=value2]...
Connection C = DriverManager.getConnection(
"jdbc:mysql://xx.xx.com/tparser?user=xxxl&password=xxxxi");
// Do something with the Connection
try
{
// Use some connection we've already created
Statement Stmt = C.createStatement();
RS = Stmt.executeQuery(q);
/* Clean up after ourselves*/
RS.close();
Stmt.close();
C.close();
}
catch (SQLException E)
{
System.out.println("SQLException: " + E.getMessage());
System.out.println("SQLState: " + E.getSQLState());
System.out.println("VendorError: " + E.getErrorCode());
}
}
catch(SQLException E)
{
System.out.println("SQLException: " + E.getMessage());
System.out.println("SQLState: " + E.getSQLState());
System.out.println("VendorError: " + E.getErrorCode());
}
return RS;
}
------------------