Best practices JDBC JSP

From: mBird (no_at_spam.com)
Date: 03/31/04


Date: Wed, 31 Mar 2004 02:29:17 GMT

I query an Oracle 9i database and present on the web using TomCat and JSP. I
am wondering if the way I do it (see code snip below) is the
best/recommended way to do it or are there other/better recommended ways. I
am using TomCat 5 with JDK 1.4 and latest JDBC drivers from Oracle.
Thank you for any advice.

...
<%@ page import="java.sql.*" %>
<%
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
java.sql.Connection conn;
conn = DriverManager.getConnection(
  "jdbc:oracle:thin:@mBird:1521:ORCL",
  "webaccount",
  "webpassword"
);

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select title from books");

while(rs.next())
{
  out.println( "<br>" + rs.getString("title") );
}

rs.close();
conn.close();
%>
...



Relevant Pages

  • Re: Tomcat Shutdown Causes High Oracle DB CPU Load
    ... Whenever we shut down tomcat, our Oracle server suddenly spawns up to ... closing all result sets, statements, and connections in "finally" ... gets executed after the JVM shuts down. ...
    (comp.lang.java.databases)
  • Tomcat Shutdown Causes High Oracle DB CPU Load
    ... We're running tomcat 6.0 on one Centos ... The hardware is a Dell 1950 for the app server and 2950 for the ... our Oracle server suddenly spawns up to ... closing all result sets, statements, and connections in "finally" ...
    (comp.lang.java.databases)
  • ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    ... I try play a little bit with a oracle, tomcat, apache. ... I setup apache, ... When I am login on that server I can use sqlplus. ...
    (comp.lang.java.databases)
  • Re: localhost connection refused (Oracle & Tomcat)
    ... such as: StandardHost: Error deploying application at context ... The problem I have with oracle is also one of the problems that I am ... having with tomcat. ... we are to stand by the president, right or wrong, is not only ...
    (alt.os.linux.suse)
  • Re: Help with Tomcat & Oracle on localhost
    ... My shop recently relocated our Oracle 10g instance to a new box. ... Since, this action, I can no longer run JSP's from my local host ... run it with Tomcat prior to the migration. ... If I run an app on my local tomcat to connect to remote databases I normally get an error stack including the ORA error number at the top of it. ...
    (comp.databases.oracle.misc)