I have a JSP application that connects to oracle on the log in page. How can I keep this connection alive and execute queries from it on another page?
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@" + HOST + ":1521:fcprod", request.getParameter("username"), request.getParameter("password"));
I keep connections alive using c3p0 which does connection pooling. It has commands to keep the connections alive when not in use. I use this in grails apps (similar to jsp) and hibernate based applications.
The above comment is correct though, you’ll want to move the connection information out of the pages into a controller (not a great idea) or a service (probably the best idea).