I am using Tomcat as a server to work on a servlet that need to access a database and I need to use CachedRowSet, but I cannot seem to connect to the database correctly.
Currently I have
public class FaqListingServlet extends HttpServlet
{
private CachedRowSetImpl cachedRowSet;
// set up database connection and create SQL statement
public void init( ServletConfig config ) throws ServletException
{
// attempt database connection and create Statement
try
{
Class.forName("databaseDriver");
//CachedRowSetImpl cachedRowSet = new CachedRowSetImpl();
cachedRowSet.setUrl("databaseName");
cachedRowSet.setUsername("username");
cachedRowSet.setPassword("password");
cachedRowSet.setCommand("SELECT * FROM topics");
cachedRowSet.execute();
} // end try
// for any exception throw an UnavailableException to
// indicate that the servlet is not currently available
catch ( Exception exception )
{
exception.printStackTrace();
throw new UnavailableException( exception.getMessage() );
}// end catch
} // end method init
where the "databaseDriver", "databaseName", "password" etc. are all declared in an xml file. Currently though it always dumps an exception because it never successfully makes the connection. I am assuming it is my implementation of the CachedRowSet that is incorrect so any suggestions would be appreciated.
Also does anyone know why tomcat would suddenly not display the tomcat homepage? I get a 404 error, but if I add the folders (e.g. localhost:8080/examples)everything displays as it should. It has been a long week already...