tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon T <tom...@sydneybluegum.com>
Subject Re: JDBCRealm & connection pool
Date Fri, 23 Aug 2002 11:01:52 GMT
I am using 4.1.9 and it is working ok, but just at home not in a 
production env.

Looking at 
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html

The doc say the following is required.

    * Tomcat 4.0.3
    * mySQL 4.0.1alpha
    * mm.mysql 2.0.14 (JDBC Driver)
    * DBCP - Jakarta-commons connection pool  (included in tomcat 4.1.9)

I have mysql working ok with mm.mysql-2.0.14-bin.jar file in the common/lib
I am using the jdk1.3.1 with the full tomcat 4.1.19 installation.

The context (DBTest) web.xml needs to be updated for the context in the 
server.xml     e.g in the tomcat example they created DBTest  <Context 
path="/DBTest" docBase="DBTest"

A jsp example that i used for testing . It will display a max of 100 
rows from table abc.

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#e0a0e0">
<%@page language="java" import="javax.sql.*"%>
<%@page import="javax.naming.*" %>
<%@page import="java.sql.*" %>
<%
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/mysql");
Connection conn = ds.getConnection();
Statement StatementRecordset1 = conn.createStatement();
ResultSet Recordset1 = StatementRecordset1.executeQuery("select * from 
abc");
boolean Recordset1_isEmpty = !Recordset1.next();
boolean Recordset1_hasData = !Recordset1_isEmpty;
int Recordset1_numRows = 0;
int Repeat1__numRows = 100 ;
int Repeat1__index = 0 ;
Recordset1_numRows += Repeat1__numRows;
%>
<table BORDER=2>
<% while ((Recordset1_hasData)&&(Repeat1__numRows-- != 0))
{
%>
       <tr>
         <td><%= (String) Recordset1.getObject("name") %></td>
       </tr>
       <%Repeat1__index++;
Recordset1_hasData = Recordset1.next();}
Recordset1.close();
conn.close();
%>
</table>
</body></html


Regards,
Simon



Rolando Duma wrote:

>It's possible to configure a JDBCRealm + dbcp without coding any class (only
>editing server.xml)?
>I didn't find
>I'm using Tomcat 4.0.4 + MySQL.
>tia
>
>
>--
>To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>
>
>
>  
>



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message