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

  • 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)
  • Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    ... > I try play a little bit with a oracle, tomcat, apache. ... I setup apache, ... * FirstSQL/J Object/Relational DBMS ...
    (comp.lang.java.databases)
  • Re: Servlets, JDBC Oracle Connection Mode
    ... >I need to write a servlet, that interacts with Oracle database, using ... >JDBC. ... running Tomcat is not the same as Database Server ... Oracle database use over the network. ...
    (comp.lang.java.databases)