Best practices JDBC JSP
From: mBird (no_at_spam.com)
Date: 03/31/04
- Next message: Eugene Staten: "Re: bind variables with jdbc"
- Previous message: Jim Kennedy: "Re: bind variables with jdbc"
- Next in thread: Andree Große: "Re: Best practices JDBC JSP"
- Reply: Andree Große: "Re: Best practices JDBC JSP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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();
%>
...
- Next message: Eugene Staten: "Re: bind variables with jdbc"
- Previous message: Jim Kennedy: "Re: bind variables with jdbc"
- Next in thread: Andree Große: "Re: Best practices JDBC JSP"
- Reply: Andree Große: "Re: Best practices JDBC JSP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|