Compare commits
No commits in common. "0.4.0" and "master" have entirely different histories.
32 changed files with 1792 additions and 2697 deletions
8
.cvsignore
Normal file
8
.cvsignore
Normal file
|
@ -0,0 +1,8 @@
|
|||
*.ipr
|
||||
*.iml
|
||||
*.iws
|
||||
bin
|
||||
dist
|
||||
build
|
||||
classes
|
||||
javadoc
|
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
*.ipr
|
||||
*.iml
|
||||
*.iws
|
||||
bin
|
||||
dist
|
||||
build
|
||||
classes
|
||||
javadoc
|
||||
/CVS/
|
||||
CVS
|
|
@ -1,26 +1,26 @@
|
|||
# Project
|
||||
proj.name=simplepool
|
||||
proj.version=1.0
|
||||
|
||||
# Locations
|
||||
path.build=build
|
||||
path.src=src
|
||||
path.dist=dist
|
||||
path.lib=lib
|
||||
path.javadoc=javadoc
|
||||
|
||||
# Jar
|
||||
jar.name=${proj.name}
|
||||
|
||||
# Examples
|
||||
ex.name=${proj.name}-examples-${proj.version}
|
||||
path.ex=${proj.name}-examples
|
||||
|
||||
# Release
|
||||
release.name=${proj.name}-${proj.version}
|
||||
|
||||
# Javadoc
|
||||
javadoc.title=SimplePool API
|
||||
javadoc.api.link=http://java.sun.com/j2se/1.4.2/docs/api
|
||||
javadoc.servlet.link=http://java.sun.com/products/servlet/2.3/javadoc/
|
||||
# Project
|
||||
proj.name=simplepool
|
||||
proj.version=1.0
|
||||
|
||||
# Locations
|
||||
path.build=build
|
||||
path.src=src
|
||||
path.dist=dist
|
||||
path.lib=lib
|
||||
path.javadoc=javadoc
|
||||
|
||||
# Jar
|
||||
jar.name=${proj.name}
|
||||
|
||||
# Examples
|
||||
ex.name=${proj.name}-examples-${proj.version}
|
||||
path.ex=${proj.name}-examples
|
||||
|
||||
# Release
|
||||
release.name=${proj.name}-${proj.version}
|
||||
|
||||
# Javadoc
|
||||
javadoc.title=SimplePool API
|
||||
javadoc.api.link=http://java.sun.com/j2se/1.4.2/docs/api
|
||||
javadoc.servlet.link=http://java.sun.com/products/servlet/2.3/javadoc/
|
||||
javadoc.packages=net.java.dev.simplepool.*
|
174
build.xml
174
build.xml
|
@ -1,88 +1,88 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="simplepool" default="build" basedir=".">
|
||||
<property file="${basedir}/build.properties" />
|
||||
<property name="path.jar.build" value="${path.build}/${jar.name}"/>
|
||||
<property name="path.ex.build" value="${path.build}/${ex.name}"/>
|
||||
<property name="path.rel.build" value="${path.build}/${release.name}"/>
|
||||
<path id="path.source">
|
||||
<pathelement location="${path.src}" />
|
||||
</path>
|
||||
<path id="path.class">
|
||||
<fileset dir="${path.lib}">
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<target name="init">
|
||||
<tstamp />
|
||||
<mkdir dir="${path.build}"/>
|
||||
<mkdir dir="${path.dist}"/>
|
||||
<mkdir dir="${path.javadoc}"/>
|
||||
</target>
|
||||
<target name="compile" depends="init" description="Compiles sources">
|
||||
<mkdir dir="${path.jar.build}" />
|
||||
<javac sourcepathref="path.source" classpathref="path.class" destdir="${path.jar.build}" debug="off" deprecation="on">
|
||||
<src refid="path.source" />
|
||||
</javac>
|
||||
</target>
|
||||
<target name="build" depends="clean,compile,jar" description="Rebuilds project" />
|
||||
<target name="jar" depends="compile" description="Builds the JAR">
|
||||
<copy todir="${path.jar.build}">
|
||||
<fileset dir="${path.src}" includes="*.properties" />
|
||||
</copy>
|
||||
<jar destfile="${basedir}/${path.dist}/${jar.name}.jar" basedir="${path.jar.build}" excludes="**/.dependency-info/**" />
|
||||
</target>
|
||||
<target name="examples" depends="build" description="Builds the Examples WAR">
|
||||
<copy todir="${path.ex.build}">
|
||||
<fileset dir="${path.ex}"/>
|
||||
<filterset>
|
||||
<filter token="EX.NAME" value="${ex.name}"/>
|
||||
</filterset>
|
||||
</copy>
|
||||
<copy file="${path.dist}/${jar.name}.jar" todir="${path.ex.build}/WEB-INF/lib/"/>
|
||||
<touch>
|
||||
<fileset dir="${path.ex.build}"/>
|
||||
</touch>
|
||||
<jar jarfile="${path.dist}/${ex.name}.war" basedir="${path.ex.build}"/>
|
||||
</target>
|
||||
<target name="release" depends="build,javadoc" description="Builds the release archives">
|
||||
<mkdir dir="${path.rel.build}"/>
|
||||
<copy todir="${path.rel.build}">
|
||||
<fileset file="${path.dist}/${jar.name}.jar"/>
|
||||
<fileset dir="${basedir}" includes="${path.javadoc}/**"/>
|
||||
</copy>
|
||||
<touch>
|
||||
<fileset dir="${path.rel.build}"/>
|
||||
</touch>
|
||||
<zip destfile="${path.dist}/${release.name}.zip" basedir="${path.build}" includes="${release.name}/**"/>
|
||||
<tar tarfile="${path.dist}/${release.name}.tar.gz" compression="gzip">
|
||||
<tarfileset dir="${path.rel.build}" prefix="${release.name}" mode="644"/>
|
||||
</tar>
|
||||
</target>
|
||||
<target name="src" description="Builds the source archive">
|
||||
<tar tarfile="${path.dist}/${release.name}-src.tar.gz" compression="gzip">
|
||||
<tarfileset dir="${basedir}" prefix="${release.name}">
|
||||
<include name="${path.src}/**"/>
|
||||
<include name="${path.ex}/**"/>
|
||||
<include name="${path.lib}/**"/>
|
||||
<include name="build.*"/>
|
||||
</tarfileset>
|
||||
</tar>
|
||||
</target>
|
||||
<target name="javadoc" depends="init" description="Builds the Javadoc">
|
||||
<delete quiet="true" includeEmptyDirs="true">
|
||||
<fileset dir="${path.javadoc}" includes="*,*/**"/>
|
||||
</delete>
|
||||
<javadoc sourcepath="${path.src}" destdir="${path.javadoc}" packagenames="${javadoc.packages}" windowtitle="${javadoc.title}" verbose="false" failonerror="true" additionalparam="">
|
||||
<link href="${javadoc.api.link}"/>
|
||||
<link href="${javadoc.servlet.link}"/>
|
||||
<classpath refid="path.class"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="clean" depends="init" description="Removes classses and javadoc">
|
||||
<delete quiet="true" includeEmptyDirs="true">
|
||||
<fileset dir="${path.build}" includes="*,*/**"/>
|
||||
<fileset dir="${path.dist}" includes="*,*/**"/>
|
||||
<fileset dir="${path.javadoc}" includes="*,*/**"/>
|
||||
</delete>
|
||||
</target>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="simplepool" default="build" basedir=".">
|
||||
<property file="${basedir}/build.properties" />
|
||||
<property name="path.jar.build" value="${path.build}/${jar.name}"/>
|
||||
<property name="path.ex.build" value="${path.build}/${ex.name}"/>
|
||||
<property name="path.rel.build" value="${path.build}/${release.name}"/>
|
||||
<path id="path.source">
|
||||
<pathelement location="${path.src}" />
|
||||
</path>
|
||||
<path id="path.class">
|
||||
<fileset dir="${path.lib}">
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<target name="init">
|
||||
<tstamp />
|
||||
<mkdir dir="${path.build}"/>
|
||||
<mkdir dir="${path.dist}"/>
|
||||
<mkdir dir="${path.javadoc}"/>
|
||||
</target>
|
||||
<target name="compile" depends="init" description="Compiles sources">
|
||||
<mkdir dir="${path.jar.build}" />
|
||||
<javac sourcepathref="path.source" classpathref="path.class" destdir="${path.jar.build}" debug="off" deprecation="on">
|
||||
<src refid="path.source" />
|
||||
</javac>
|
||||
</target>
|
||||
<target name="build" depends="clean,compile,jar" description="Rebuilds project" />
|
||||
<target name="jar" depends="compile" description="Builds the JAR">
|
||||
<copy todir="${path.jar.build}">
|
||||
<fileset dir="${path.src}" includes="*.properties" />
|
||||
</copy>
|
||||
<jar destfile="${basedir}/${path.dist}/${jar.name}.jar" basedir="${path.jar.build}" excludes="**/.dependency-info/**" />
|
||||
</target>
|
||||
<target name="examples" depends="build" description="Builds the Examples WAR">
|
||||
<copy todir="${path.ex.build}">
|
||||
<fileset dir="${path.ex}"/>
|
||||
<filterset>
|
||||
<filter token="EX.NAME" value="${ex.name}"/>
|
||||
</filterset>
|
||||
</copy>
|
||||
<copy file="${path.dist}/${jar.name}.jar" todir="${path.ex.build}/WEB-INF/lib/"/>
|
||||
<touch>
|
||||
<fileset dir="${path.ex.build}"/>
|
||||
</touch>
|
||||
<jar jarfile="${path.dist}/${ex.name}.war" basedir="${path.ex.build}"/>
|
||||
</target>
|
||||
<target name="release" depends="build,javadoc" description="Builds the release archives">
|
||||
<mkdir dir="${path.rel.build}"/>
|
||||
<copy todir="${path.rel.build}">
|
||||
<fileset file="${path.dist}/${jar.name}.jar"/>
|
||||
<fileset dir="${basedir}" includes="${path.javadoc}/**"/>
|
||||
</copy>
|
||||
<touch>
|
||||
<fileset dir="${path.rel.build}"/>
|
||||
</touch>
|
||||
<zip destfile="${path.dist}/${release.name}.zip" basedir="${path.build}" includes="${release.name}/**"/>
|
||||
<tar tarfile="${path.dist}/${release.name}.tar.gz" compression="gzip">
|
||||
<tarfileset dir="${path.rel.build}" prefix="${release.name}" mode="644"/>
|
||||
</tar>
|
||||
</target>
|
||||
<target name="src" description="Builds the source archive">
|
||||
<tar tarfile="${path.dist}/${release.name}-src.tar.gz" compression="gzip">
|
||||
<tarfileset dir="${basedir}" prefix="${release.name}">
|
||||
<include name="${path.src}/**"/>
|
||||
<include name="${path.ex}/**"/>
|
||||
<include name="${path.lib}/**"/>
|
||||
<include name="build.*"/>
|
||||
</tarfileset>
|
||||
</tar>
|
||||
</target>
|
||||
<target name="javadoc" depends="init" description="Builds the Javadoc">
|
||||
<delete quiet="true" includeEmptyDirs="true">
|
||||
<fileset dir="${path.javadoc}" includes="*,*/**"/>
|
||||
</delete>
|
||||
<javadoc sourcepath="${path.src}" destdir="${path.javadoc}" packagenames="${javadoc.packages}" windowtitle="${javadoc.title}" verbose="false" failonerror="true" additionalparam="">
|
||||
<link href="${javadoc.api.link}"/>
|
||||
<link href="${javadoc.servlet.link}"/>
|
||||
<classpath refid="path.class"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="clean" depends="init" description="Removes classses and javadoc">
|
||||
<delete quiet="true" includeEmptyDirs="true">
|
||||
<fileset dir="${path.build}" includes="*,*/**"/>
|
||||
<fileset dir="${path.dist}" includes="*,*/**"/>
|
||||
<fileset dir="${path.javadoc}" includes="*,*/**"/>
|
||||
</delete>
|
||||
</target>
|
||||
</project>
|
214
conf/server.xml
214
conf/server.xml
|
@ -1,107 +1,107 @@
|
|||
|
||||
|
||||
<Server port="8005" shutdown="SHUTDOWN" debug="0">
|
||||
|
||||
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" debug="0"/>
|
||||
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" debug="0"/>
|
||||
|
||||
<GlobalNamingResources>
|
||||
|
||||
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase"/>
|
||||
|
||||
<ResourceParams name="UserDatabase">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>pathname</name>
|
||||
<value>conf/tomcat-users.xml</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
|
||||
<Resource name="jdbc/PooledDS" type="javax.sql.DataSource" auth="Container"/>
|
||||
|
||||
<ResourceParams name="jdbc/PooledDS">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>net.java.dev.simplepool.SimplePoolDataSourceFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>driver</name>
|
||||
<value>com.mysql.jdbc.Driver</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>user</name>
|
||||
<value>dbuser</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>password</name>
|
||||
<value>test</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jdbcUrl</name>
|
||||
<value>jdbc:mysql://localhost:3306/dbname</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>minConns</name>
|
||||
<value>8</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConns</name>
|
||||
<value>30</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConnTime</name>
|
||||
<value>1</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxCheckoutSeconds</name>
|
||||
<value>60</value>
|
||||
</parameter>
|
||||
|
||||
</ResourceParams>
|
||||
|
||||
</GlobalNamingResources>
|
||||
|
||||
<Service name="Catalina">
|
||||
|
||||
<Connector port="80"
|
||||
maxThreads="150"
|
||||
minSpareThreads="25"
|
||||
maxSpareThreads="75"
|
||||
enableLookups="false"
|
||||
redirectPort="8443"
|
||||
acceptCount="100"
|
||||
debug="0"
|
||||
connectionTimeout="20000"
|
||||
proxyPort="80"
|
||||
/>
|
||||
|
||||
|
||||
<Engine name="Catalina" defaultHost="www.waveblog.com" debug="0">
|
||||
|
||||
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
|
||||
debug="1" resourceName="UserDatabase"/>
|
||||
|
||||
<Host name="localhost"
|
||||
debug="1" appBase="webapps" unpackWARs="true" autoDeploy="true"
|
||||
xmlValidation="false" xmlNamespaceAware="false">
|
||||
|
||||
<Context path="" docBase="ROOT" debug="0" reloadable="true">
|
||||
<ResourceLink name="jdbc/PooledDS" global="jdbc/PooledDS" type="javax.sql.DataSource" />
|
||||
</Context>
|
||||
|
||||
<Valve className="org.apache.catalina.valves.AccessLogValve"
|
||||
directory="logs" prefix="waveblog" suffix=".log"
|
||||
pattern="combined" resolveHosts="false"/>
|
||||
|
||||
</Host>
|
||||
|
||||
|
||||
</Engine>
|
||||
|
||||
</Service>
|
||||
|
||||
</Server>
|
||||
|
||||
|
||||
<Server port="8005" shutdown="SHUTDOWN" debug="0">
|
||||
|
||||
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" debug="0"/>
|
||||
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" debug="0"/>
|
||||
|
||||
<GlobalNamingResources>
|
||||
|
||||
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase"/>
|
||||
|
||||
<ResourceParams name="UserDatabase">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>pathname</name>
|
||||
<value>conf/tomcat-users.xml</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
|
||||
<Resource name="jdbc/PooledDS" type="javax.sql.DataSource" auth="Container"/>
|
||||
|
||||
<ResourceParams name="jdbc/PooledDS">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>net.java.dev.simplepool.SimplePoolDataSourceFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>driver</name>
|
||||
<value>com.mysql.jdbc.Driver</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>user</name>
|
||||
<value>dbuser</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>password</name>
|
||||
<value>test</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jdbcUrl</name>
|
||||
<value>jdbc:mysql://localhost:3306/dbname</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>minConns</name>
|
||||
<value>8</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConns</name>
|
||||
<value>30</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConnTime</name>
|
||||
<value>1</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxCheckoutSeconds</name>
|
||||
<value>60</value>
|
||||
</parameter>
|
||||
|
||||
</ResourceParams>
|
||||
|
||||
</GlobalNamingResources>
|
||||
|
||||
<Service name="Catalina">
|
||||
|
||||
<Connector port="80"
|
||||
maxThreads="150"
|
||||
minSpareThreads="25"
|
||||
maxSpareThreads="75"
|
||||
enableLookups="false"
|
||||
redirectPort="8443"
|
||||
acceptCount="100"
|
||||
debug="0"
|
||||
connectionTimeout="20000"
|
||||
proxyPort="80"
|
||||
/>
|
||||
|
||||
|
||||
<Engine name="Catalina" defaultHost="www.waveblog.com" debug="0">
|
||||
|
||||
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
|
||||
debug="1" resourceName="UserDatabase"/>
|
||||
|
||||
<Host name="localhost"
|
||||
debug="1" appBase="webapps" unpackWARs="true" autoDeploy="true"
|
||||
xmlValidation="false" xmlNamespaceAware="false">
|
||||
|
||||
<Context path="" docBase="ROOT" debug="0" reloadable="true">
|
||||
<ResourceLink name="jdbc/PooledDS" global="jdbc/PooledDS" type="javax.sql.DataSource" />
|
||||
</Context>
|
||||
|
||||
<Valve className="org.apache.catalina.valves.AccessLogValve"
|
||||
directory="logs" prefix="waveblog" suffix=".log"
|
||||
pattern="combined" resolveHosts="false"/>
|
||||
|
||||
</Host>
|
||||
|
||||
|
||||
</Engine>
|
||||
|
||||
</Service>
|
||||
|
||||
</Server>
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<% out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); %>
|
||||
<%@ page contentType="text/xml;charset=UTF-8"%>
|
||||
<%@ page session="false"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
|
||||
|
||||
<sql:setDataSource dataSource="jdbc/PooledDS" />
|
||||
|
||||
<sql:query var="page" maxRows="30">
|
||||
select * from entry
|
||||
</sql:query>
|
||||
|
||||
<document>
|
||||
<c:forEach var="row" items="${page.rows}" varStatus="counter">
|
||||
<entry>
|
||||
<count><c:out value="${counter.count}"/></count>
|
||||
<id><c:out value="${row.id}"/></id>
|
||||
<title><c:out value="${row.name}"/></title>
|
||||
</entry>
|
||||
</c:forEach>
|
||||
</document>
|
||||
<% out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); %>
|
||||
<%@ page contentType="text/xml;charset=UTF-8"%>
|
||||
<%@ page session="false"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
|
||||
|
||||
<sql:setDataSource dataSource="jdbc/PooledDS" />
|
||||
|
||||
<sql:query var="page" maxRows="30">
|
||||
select * from entry
|
||||
</sql:query>
|
||||
|
||||
<document>
|
||||
<c:forEach var="row" items="${page.rows}" varStatus="counter">
|
||||
<entry>
|
||||
<count><c:out value="${counter.count}"/></count>
|
||||
<id><c:out value="${row.id}"/></id>
|
||||
<title><c:out value="${row.name}"/></title>
|
||||
</entry>
|
||||
</c:forEach>
|
||||
</document>
|
||||
|
|
Binary file not shown.
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
* Copyright (c) 1999-2004 The Apache Software Foundation. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution, if
|
||||
* any, must include the following acknowlegement:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowlegement may appear in the software itself,
|
||||
* if and wherever such third-party acknowlegements normally appear.
|
||||
*
|
||||
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
|
||||
* Foundation" must not be used to endorse or promote products derived
|
||||
* from this software without prior written permission. For written
|
||||
* permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache"
|
||||
* nor may "Apache" appear in their names without prior written
|
||||
* permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
|
@ -1,407 +0,0 @@
|
|||
<CENTER>
|
||||
GNU GENERAL PUBLIC LICENSE<BR>
|
||||
Version 2, June 1991
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.<BR>
|
||||
675 Mass Ave, Cambridge, MA 02139, USA<BR>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
<P>
|
||||
<CENTER>
|
||||
Preamble
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
<P>
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
<P>
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
<P>
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
<P>
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
<P>
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
<P>
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
<P>
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
<CENTER>
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
<P>
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
<P>
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
<P>
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
<P>
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
<BLOCKQUOTE>
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
<P>
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
<P>
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
<P>
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
<P>
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
<BLOCKQUOTE>
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
<P>
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
<P>
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
<P>
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
<P>
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
<P>
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
<P>
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
<P>
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
<P>
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
<P>
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
<P>
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
<P>
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
<P>
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
<P>
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
<P>
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
<CENTER>
|
||||
NO WARRANTY
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
<P>
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
<CENTER>
|
||||
END OF TERMS AND CONDITIONS
|
||||
<P>
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
<P>
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<BLOCKQUOTE>
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
<P>
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
<P>
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
<P>
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
<P>
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
<BLOCKQUOTE>
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
<P>
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
<BLOCKQUOTE>
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<P>
|
||||
<signature of Ty Coon>, 1 April 1989<BR>
|
||||
Ty Coon, President of Vice
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/licenses/SimplePool License.txt,v $
|
||||
* $Revision: 1.1 $
|
||||
* $Date: 2004-03-28 02:04:48 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
|
@ -1,52 +1,52 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE web-app PUBLIC
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
||||
<web-app>
|
||||
<description>SimplePool Examples</description>
|
||||
|
||||
<!--
|
||||
<servlet>
|
||||
<servlet-name>SimplePoolServlet</servlet-name>
|
||||
<servlet-class>net.java.dev.simplepool.SimplePoolServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>varName</param-name>
|
||||
<param-value>ServletPoolDS</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>driver</param-name>
|
||||
<param-value>com.mysql.jdbc.Driver</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>user</param-name>
|
||||
<param-value>dbuser</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>password</param-name>
|
||||
<param-value>dbpassword</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>jdbcUrl</param-name>
|
||||
<param-value>jdbc:mysql://localhost:3306/dbname</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>minConns</param-name>
|
||||
<param-value>8</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxConns</param-name>
|
||||
<param-value>30</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxConnTime</param-name>
|
||||
<param-value>1</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxCheckoutSeconds</param-name>
|
||||
<param-value>60</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
-->
|
||||
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE web-app PUBLIC
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
||||
<web-app>
|
||||
<description>SimplePool Examples</description>
|
||||
|
||||
<!--
|
||||
<servlet>
|
||||
<servlet-name>SimplePoolServlet</servlet-name>
|
||||
<servlet-class>net.java.dev.simplepool.SimplePoolServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>varName</param-name>
|
||||
<param-value>ServletPoolDS</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>driver</param-name>
|
||||
<param-value>com.mysql.jdbc.Driver</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>user</param-name>
|
||||
<param-value>dbuser</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>password</param-name>
|
||||
<param-value>dbpassword</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>jdbcUrl</param-name>
|
||||
<param-value>jdbc:mysql://localhost:3306/dbname</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>minConns</param-name>
|
||||
<param-value>8</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxConns</param-name>
|
||||
<param-value>30</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxConnTime</param-name>
|
||||
<param-value>1</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxCheckoutSeconds</param-name>
|
||||
<param-value>60</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
-->
|
||||
|
||||
</web-app>
|
|
@ -1,62 +1,62 @@
|
|||
<Server port="8005" shutdown="SHUTDOWN">
|
||||
<Service name="Catalina">
|
||||
<Connector port="80" />
|
||||
|
||||
<Engine name="Catalina" defaultHost="localhost">
|
||||
<Logger className="org.apache.catalina.logger.FileLogger" />
|
||||
|
||||
<Host name="localhost" appBase="webapps">
|
||||
|
||||
<!-- Define our application context -->
|
||||
<Context path="/@EX.NAME@" docBase="@EX.NAME@"
|
||||
debug="5" reloadable="true" crossContext="true">
|
||||
|
||||
<!-- Define our JDNI DataSource -->
|
||||
<Resource name="jdbc/JNDIPoolDS" type="javax.sql.DataSource" auth="Container"/>
|
||||
|
||||
<!-- Configure our JNDI DataSource -->
|
||||
<ResourceParams name="jdbc/JNDIPoolDS">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>net.java.dev.simplepool.SimplePoolDataSourceFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>driver</name>
|
||||
<value>com.mysql.jdbc.Driver</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>user</name>
|
||||
<value>dbuser</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>password</name>
|
||||
<value>dbpassword</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jdbcUrl</name>
|
||||
<value>jdbc:mysql://localhost:3306/dbname</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>minConns</name>
|
||||
<value>8</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConns</name>
|
||||
<value>30</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConnTime</name>
|
||||
<value>1</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxCheckoutSeconds</name>
|
||||
<value>60</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
</Context>
|
||||
|
||||
</Host>
|
||||
</Engine>
|
||||
</Service>
|
||||
<Server port="8005" shutdown="SHUTDOWN">
|
||||
<Service name="Catalina">
|
||||
<Connector port="80" />
|
||||
|
||||
<Engine name="Catalina" defaultHost="localhost">
|
||||
<Logger className="org.apache.catalina.logger.FileLogger" />
|
||||
|
||||
<Host name="localhost" appBase="webapps">
|
||||
|
||||
<!-- Define our application context -->
|
||||
<Context path="/@EX.NAME@" docBase="@EX.NAME@"
|
||||
debug="5" reloadable="true" crossContext="true">
|
||||
|
||||
<!-- Define our JDNI DataSource -->
|
||||
<Resource name="jdbc/JNDIPoolDS" type="javax.sql.DataSource" auth="Container"/>
|
||||
|
||||
<!-- Configure our JNDI DataSource -->
|
||||
<ResourceParams name="jdbc/JNDIPoolDS">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>net.java.dev.simplepool.SimplePoolDataSourceFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>driver</name>
|
||||
<value>com.mysql.jdbc.Driver</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>user</name>
|
||||
<value>dbuser</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>password</name>
|
||||
<value>dbpassword</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jdbcUrl</name>
|
||||
<value>jdbc:mysql://localhost:3306/dbname</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>minConns</name>
|
||||
<value>8</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConns</name>
|
||||
<value>30</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConnTime</name>
|
||||
<value>1</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxCheckoutSeconds</name>
|
||||
<value>60</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
</Context>
|
||||
|
||||
</Host>
|
||||
</Engine>
|
||||
</Service>
|
||||
</Server>
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: inst.css,v 1.1 2004-03-28 02:04:51 ethauvin Exp $
|
||||
/* $Id: inst.css,v 1.1 2004/03/20 13:36:08 erik Exp $
|
||||
|
||||
This file contains rules that extend or override the more basic formatting defined in tigris.css. Edit it to customize the look of applications using tigris.css (instances). You are responsible for maintaining your own set of (optional) deltas from tigris.css defaults; this file is intended as an example.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: tigris.css,v 1.1 2004-03-28 02:04:52 ethauvin Exp $
|
||||
/* $Id: tigris.css,v 1.1 2004/03/20 13:36:08 erik Exp $
|
||||
|
||||
This file defines basic default formatting for HTML conforming to Tigris application style. To extend or override these rules for your instance, edit inst.css instead of this file. */
|
||||
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
<!DOCTYPE html PUBLIC "-//Tigris//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://style.tigris.org/tigris_transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
/* <![CDATA[ */
|
||||
@import "includes/tigris.css";
|
||||
@import "includes/inst.css";
|
||||
/* ]]> */
|
||||
</style>
|
||||
<title>simplepool: Examples</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0" class="composite">
|
||||
<table border="0" cellspacing="0" cellpadding="4" width="100%" id="main">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div id="bodycol">
|
||||
<div id="apphead">
|
||||
<h2><small>simplepool</small><br />
|
||||
Examples</h2>
|
||||
</div>
|
||||
<p class="tasknav"><a href="https://simplepool.dev.java.net/">Project Home</a></p>
|
||||
<div id="examples" class="app">
|
||||
<div class="axial">
|
||||
<table border="0" cellspacing="2" cellpadding="3">
|
||||
<tr>
|
||||
<th>Summary</th>
|
||||
<td>A simple database connection pool for webapps using JSTL.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 1</th>
|
||||
<td><a href="jndi/index.jsp">JNDI DataSource Examples</a> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 2</th>
|
||||
<td><a href="servlet/index.jsp">Servlet DataSource Examples</a> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="h3" id="longdescription">
|
||||
<h3>Description</h3>
|
||||
<p>SimplePool is a simple database connection pool implementation for web applications, specifically those using <a href="http://java.sun.com/products/jsp/jstl/">JSTL</a>.</p>
|
||||
<p>The connection pool can be created, accessed and managed via <a href="jndi">JNDI</a> or a provided <a href="servlet/">Servlet</a>.</p>
|
||||
<p>The examples above have been tailored for use with <a href="http://jakarta.apache.org/tomcat/">Tomcat</a> and <a href="http://www.mysql.com/">MySQL</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html PUBLIC "-//Tigris//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://style.tigris.org/tigris_transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
/* <![CDATA[ */
|
||||
@import "includes/tigris.css";
|
||||
@import "includes/inst.css";
|
||||
/* ]]> */
|
||||
</style>
|
||||
<title>simplepool: Examples</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0" class="composite">
|
||||
<table border="0" cellspacing="0" cellpadding="4" width="100%" id="main">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div id="bodycol">
|
||||
<div id="apphead">
|
||||
<h2><small>simplepool</small><br />
|
||||
Examples</h2>
|
||||
</div>
|
||||
<p class="tasknav"><a href="https://simplepool.dev.java.net/">Project Home</a></p>
|
||||
<div id="examples" class="app">
|
||||
<div class="axial">
|
||||
<table border="0" cellspacing="2" cellpadding="3">
|
||||
<tr>
|
||||
<th>Summary</th>
|
||||
<td>A simple database connection pool for webapps using JSTL.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 1</th>
|
||||
<td><a href="jndi/index.jsp">JNDI DataSource Examples</a> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 2</th>
|
||||
<td><a href="servlet/index.jsp">Servlet DataSource Examples</a> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="h3" id="longdescription">
|
||||
<h3>Description</h3>
|
||||
<p>SimplePool is a simple database connection pool implementation for web applications, specifically those using <a href="http://java.sun.com/products/jsp/jstl/">JSTL</a>.</p>
|
||||
<p>The connection pool can be created, accessed and managed via <a href="jndi">JNDI</a> or a provided <a href="servlet/">Servlet</a>.</p>
|
||||
<p>The examples above have been tailored for use with <a href="http://jakarta.apache.org/tomcat/">Tomcat</a> and <a href="http://www.mysql.com/">MySQL</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,84 +1,84 @@
|
|||
<!DOCTYPE html PUBLIC "-//Tigris//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://style.tigris.org/tigris_transitional.dtd">
|
||||
<%@page import="javax.naming.*" %>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
/* <![CDATA[ */
|
||||
@import "../includes/tigris.css";
|
||||
@import "../includes/inst.css";
|
||||
/* ]]> */
|
||||
</style>
|
||||
<title>simplepool: JNDI DataSource Examples</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
<script language="javascript" type="text/javascript">
|
||||
<%
|
||||
boolean enabled = false;
|
||||
|
||||
try {
|
||||
enabled = (new InitialContext().lookup("java:comp/env/jdbc/JNDIPoolDS") != null);
|
||||
} catch (Exception ignore) { }
|
||||
%>
|
||||
function RTFM()
|
||||
{
|
||||
alert("Please read the instructions to enable this example.");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0" class="composite">
|
||||
<table border="0" cellspacing="0" cellpadding="4" width="100%" id="main">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div id="bodycol">
|
||||
<div id="apphead">
|
||||
<h2><small>simplepool</small><br />
|
||||
JNDI DataSource Examples</h2>
|
||||
</div>
|
||||
<p class="tasknav"><a href="../index.html">Examples Home</a></p>
|
||||
<p><strong>Please read the instructions before trying to run the examples.</strong></p>
|
||||
<div id="examples" class="app">
|
||||
<div class="axial">
|
||||
<table border="0" cellspacing="2" cellpadding="3">
|
||||
<tr>
|
||||
<th>Summary</th>
|
||||
<td>A simple database connection pool example using JDNI.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 1</th>
|
||||
<td><a href="<% if (enabled) { %>scriptlet.jsp<% } else { %>javascript:RTFM()<% } %>">Scriptlet Example</a> [<a href="../source.jsp?file=jndi/scriptlet.jsp">source</a>]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 2</th>
|
||||
<td><a href="<% if (enabled) { %>jstl.jsp<% } else { %>javascript:RTFM()<% } %>">JSTL Example</a> [<a href="../source.jsp?file=jndi/jstl.jsp">source</a>]</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="h3" id="instructions">
|
||||
<h3>Instructions</h3>
|
||||
<p>JNDI is used to create, access and manage the connection pool.</p>
|
||||
<p class="alert">First, make sure that your JDBC driver is available, by placing its components in this webapp's WEB-INF/lib/ directory.</p>
|
||||
<p class="alert">The JNDI DataSource is defined as naming resource in the current webapp context, as shown in this minimal <a href="../source.jsp?file=conf/server.xml">server configuration file</a>. </p>
|
||||
<p>The JNDI DataSource is configured using the following parameters:</p>
|
||||
<ul>
|
||||
<li>The <span class="info">varName</span> parameter is used to specify the name of the variable which will hold a reference to the DataSource object created by the Servlet.</li>
|
||||
<li>The <span class="info">driver</span> parameter is used to specify the name of the JDBC driver class to be registered. For <code>example: com.mysql.jdbc.Driver</code>.</li>
|
||||
<li>The <span class="info">user</span> parameter is used to specify the database username, if any.</li>
|
||||
<li>The <span class="info">password</span> parameter is used to specify the database password, if any.</li>
|
||||
<li>The <span class="info">jdbcUrl</span> parameter is used to specify the JDBC URL associated with the database. For example: <code>jdbc:mysql://localhost:3306/dbname</code>.</li>
|
||||
<li>The <span class="info">minConns</span> parameter is used to specify the minimum number of connections to start the pool with.</li>
|
||||
<li>The <span class="info">maxConns</span> parameter is used to specify the maximum number of connections to be dynamically created in the pool.</li>
|
||||
<li>The <span class="info">maxConnTime</span> parameter is used to specify the time (in days) between connection resets. The pool manager will perform a basic cleanup at the specified interval.</li>
|
||||
<li>The <span class="info">maxCheckoutSeconds</span> parameter is used to specify the maximum time a connection can be checked out before being recycled. A zero value turns this option off.</li>
|
||||
</ul>
|
||||
<p>Please note that <em>all parameters are required</em>.</p>
|
||||
<p class="alert">Please take a minute to incorporate the <a href="../source.jsp?file=conf/server.xml">JDNI DataSource example</a> in your <code>$CATALINE_HOME/conf/server.xml</code>. Once done, please restart Tomcat. The examples will be functional upon restart.</p>
|
||||
<p>Please look at the [source] of the provided examples to understand how to access the connection pool from a scriptlet or using the JSTL SQL tags. The examples demonstrates how to list all of the tables contained in the specified database.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html PUBLIC "-//Tigris//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://style.tigris.org/tigris_transitional.dtd">
|
||||
<%@page import="javax.naming.*" %>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
/* <![CDATA[ */
|
||||
@import "../includes/tigris.css";
|
||||
@import "../includes/inst.css";
|
||||
/* ]]> */
|
||||
</style>
|
||||
<title>simplepool: JNDI DataSource Examples</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
<script language="javascript" type="text/javascript">
|
||||
<%
|
||||
boolean enabled = false;
|
||||
|
||||
try {
|
||||
enabled = (new InitialContext().lookup("java:comp/env/jdbc/JNDIPoolDS") != null);
|
||||
} catch (Exception ignore) { }
|
||||
%>
|
||||
function RTFM()
|
||||
{
|
||||
alert("Please read the instructions to enable this example.");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0" class="composite">
|
||||
<table border="0" cellspacing="0" cellpadding="4" width="100%" id="main">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div id="bodycol">
|
||||
<div id="apphead">
|
||||
<h2><small>simplepool</small><br />
|
||||
JNDI DataSource Examples</h2>
|
||||
</div>
|
||||
<p class="tasknav"><a href="../index.html">Examples Home</a></p>
|
||||
<p><strong>Please read the instructions before trying to run the examples.</strong></p>
|
||||
<div id="examples" class="app">
|
||||
<div class="axial">
|
||||
<table border="0" cellspacing="2" cellpadding="3">
|
||||
<tr>
|
||||
<th>Summary</th>
|
||||
<td>A simple database connection pool example using JDNI.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 1</th>
|
||||
<td><a href="<% if (enabled) { %>scriptlet.jsp<% } else { %>javascript:RTFM()<% } %>">Scriptlet Example</a> [<a href="../source.jsp?file=jndi/scriptlet.jsp">source</a>]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 2</th>
|
||||
<td><a href="<% if (enabled) { %>jstl.jsp<% } else { %>javascript:RTFM()<% } %>">JSTL Example</a> [<a href="../source.jsp?file=jndi/jstl.jsp">source</a>]</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="h3" id="instructions">
|
||||
<h3>Instructions</h3>
|
||||
<p>JNDI is used to create, access and manage the connection pool.</p>
|
||||
<p class="alert">First, make sure that your JDBC driver is available, by placing its components in this webapp's WEB-INF/lib/ directory.</p>
|
||||
<p class="alert">The JNDI DataSource is defined as naming resource in the current webapp context, as shown in this minimal <a href="../source.jsp?file=conf/server.xml">server configuration file</a>. </p>
|
||||
<p>The JNDI DataSource is configured using the following parameters:</p>
|
||||
<ul>
|
||||
<li>The <span class="info">varName</span> parameter is used to specify the name of the variable which will hold a reference to the DataSource object created by the Servlet.</li>
|
||||
<li>The <span class="info">driver</span> parameter is used to specify the name of the JDBC driver class to be registered. For <code>example: com.mysql.jdbc.Driver</code>.</li>
|
||||
<li>The <span class="info">user</span> parameter is used to specify the database username, if any.</li>
|
||||
<li>The <span class="info">password</span> parameter is used to specify the database password, if any.</li>
|
||||
<li>The <span class="info">jdbcUrl</span> parameter is used to specify the JDBC URL associated with the database. For example: <code>jdbc:mysql://localhost:3306/dbname</code>.</li>
|
||||
<li>The <span class="info">minConns</span> parameter is used to specify the minimum number of connections to start the pool with.</li>
|
||||
<li>The <span class="info">maxConns</span> parameter is used to specify the maximum number of connections to be dynamically created in the pool.</li>
|
||||
<li>The <span class="info">maxConnTime</span> parameter is used to specify the time (in days) between connection resets. The pool manager will perform a basic cleanup at the specified interval.</li>
|
||||
<li>The <span class="info">maxCheckoutSeconds</span> parameter is used to specify the maximum time a connection can be checked out before being recycled. A zero value turns this option off.</li>
|
||||
</ul>
|
||||
<p>Please note that <em>all parameters are required</em>.</p>
|
||||
<p class="alert">Please take a minute to incorporate the <a href="../source.jsp?file=conf/server.xml">JDNI DataSource example</a> in your <code>$CATALINE_HOME/conf/server.xml</code>. Once done, please restart Tomcat. The examples will be functional upon restart.</p>
|
||||
<p>Please look at the [source] of the provided examples to understand how to access the connection pool from a scriptlet or using the JSTL SQL tags. The examples demonstrates how to list all of the tables contained in the specified database.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
||||
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
|
||||
<html>
|
||||
<head>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
||||
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool JNDI/JSTL Example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%-- Execute the query using our JNDI DataSource --%>
|
||||
<sql:query var="rs" dataSource="jdbc/JNDIPoolDS">
|
||||
<body>
|
||||
|
||||
<%-- Execute the query using our JNDI DataSource --%>
|
||||
<sql:query var="rs" dataSource="jdbc/JNDIPoolDS">
|
||||
SHOW TABLES
|
||||
</sql:query>
|
||||
|
||||
</sql:query>
|
||||
|
||||
<h3>Tables</h3>
|
||||
<ul>
|
||||
|
||||
<%--
|
||||
Loop through the result set and
|
||||
display the current column value
|
||||
--%>
|
||||
<ul>
|
||||
|
||||
<%--
|
||||
Loop through the result set and
|
||||
display the current column value
|
||||
--%>
|
||||
<c:forEach var="row" items="${rs.rowsByIndex}">
|
||||
<li><c:out value="${row[0]}"/></li>
|
||||
</c:forEach>
|
||||
|
||||
<ul>
|
||||
</c:forEach>
|
||||
|
||||
<ul>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
<%@page import="javax.naming.*, javax.sql.*, java.sql.*;" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool JNDI Example</title>
|
||||
<%@page import="javax.naming.*, javax.sql.*, java.sql.*;" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool JNDI Example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%
|
||||
// Get a new initial JNDI context
|
||||
Context ctx = new InitialContext();
|
||||
|
||||
<body>
|
||||
|
||||
<%
|
||||
// Get a new initial JNDI context
|
||||
Context ctx = new InitialContext();
|
||||
|
||||
// Get a reference to our JNDI DataSource
|
||||
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/JNDIPoolDS");
|
||||
|
||||
// Get a connection from the pool
|
||||
Connection conn = ds.getConnection();
|
||||
|
||||
// Create a new statement
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// Execute the query
|
||||
ResultSet rst = stmt.executeQuery("SHOW TABLES");
|
||||
%>
|
||||
|
||||
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/JNDIPoolDS");
|
||||
|
||||
// Get a connection from the pool
|
||||
Connection conn = ds.getConnection();
|
||||
|
||||
// Create a new statement
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// Execute the query
|
||||
ResultSet rst = stmt.executeQuery("SHOW TABLES");
|
||||
%>
|
||||
|
||||
<h3>Tables</h3>
|
||||
<ul>
|
||||
<%
|
||||
// Loop through the result set and
|
||||
// display the current column value
|
||||
while (rst.next()) {
|
||||
%>
|
||||
<li><%= rst.getString(1) %></li>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<ul>
|
||||
|
||||
<%
|
||||
// Close the result set, statement and connection
|
||||
rst.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
%>
|
||||
<ul>
|
||||
<%
|
||||
// Loop through the result set and
|
||||
// display the current column value
|
||||
while (rst.next()) {
|
||||
%>
|
||||
<li><%= rst.getString(1) %></li>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<ul>
|
||||
|
||||
<%
|
||||
// Close the result set, statement and connection
|
||||
rst.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
%>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,407 +0,0 @@
|
|||
<CENTER>
|
||||
GNU GENERAL PUBLIC LICENSE<BR>
|
||||
Version 2, June 1991
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.<BR>
|
||||
675 Mass Ave, Cambridge, MA 02139, USA<BR>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
<P>
|
||||
<CENTER>
|
||||
Preamble
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
<P>
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
<P>
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
<P>
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
<P>
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
<P>
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
<P>
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
<P>
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
<CENTER>
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
<P>
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
<P>
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
<P>
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
<P>
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
<BLOCKQUOTE>
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
<P>
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
<P>
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
<P>
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
<P>
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
<BLOCKQUOTE>
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
<P>
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
<P>
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
<P>
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
<P>
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
<P>
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
<P>
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
<P>
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
<P>
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
<P>
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
<P>
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
<P>
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
<P>
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
<P>
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
<P>
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
<CENTER>
|
||||
NO WARRANTY
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
<P>
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
<CENTER>
|
||||
END OF TERMS AND CONDITIONS
|
||||
<P>
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
<P>
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<BLOCKQUOTE>
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
<P>
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
<P>
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
<P>
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
<P>
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
<BLOCKQUOTE>
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
<P>
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
<BLOCKQUOTE>
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<P>
|
||||
<signature of Ty Coon>, 1 April 1989<BR>
|
||||
Ty Coon, President of Vice
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
|
@ -1,56 +1,56 @@
|
|||
/* ========================================================================= *
|
||||
* *
|
||||
* The Apache Software License, Version 1.1 *
|
||||
* *
|
||||
* Copyright (c) 1999, 2000 The Apache Software Foundation. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* ========================================================================= *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or without modi- *
|
||||
* fication, are permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* 1. Redistributions of source code must retain the above copyright notice, *
|
||||
* this list of conditions and the following disclaimer. *
|
||||
* *
|
||||
* 2. Redistributions in binary form must reproduce the above copyright *
|
||||
* notice, this list of conditions and the following disclaimer in the *
|
||||
* documentation and/or other materials provided with the distribution. *
|
||||
* *
|
||||
* 3. The end-user documentation included with the redistribution, if any, *
|
||||
* must include the following acknowlegement: *
|
||||
* *
|
||||
* "This product includes software developed by the Apache Software *
|
||||
* Foundation <http://www.apache.org/>." *
|
||||
* *
|
||||
* Alternately, this acknowlegement may appear in the software itself, if *
|
||||
* and wherever such third-party acknowlegements normally appear. *
|
||||
* *
|
||||
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software *
|
||||
* Foundation" must not be used to endorse or promote products derived *
|
||||
* from this software without prior written permission. For written *
|
||||
* permission, please contact <apache@apache.org>. *
|
||||
* *
|
||||
* 5. Products derived from this software may not be called "Apache" nor may *
|
||||
* "Apache" appear in their names without prior written permission of the *
|
||||
* Apache Software Foundation. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY *
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
|
||||
* THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY *
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, *
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
|
||||
* POSSIBILITY OF SUCH DAMAGE. *
|
||||
* *
|
||||
* ========================================================================= *
|
||||
* *
|
||||
* This software consists of voluntary contributions made by many indivi- *
|
||||
* duals on behalf of the Apache Software Foundation. For more information *
|
||||
* on the Apache Software Foundation, please see <http://www.apache.org/>. *
|
||||
* *
|
||||
* ========================================================================= */
|
||||
/* ========================================================================= *
|
||||
* *
|
||||
* The Apache Software License, Version 1.1 *
|
||||
* *
|
||||
* Copyright (c) 1999, 2000 The Apache Software Foundation. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* ========================================================================= *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or without modi- *
|
||||
* fication, are permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* 1. Redistributions of source code must retain the above copyright notice, *
|
||||
* this list of conditions and the following disclaimer. *
|
||||
* *
|
||||
* 2. Redistributions in binary form must reproduce the above copyright *
|
||||
* notice, this list of conditions and the following disclaimer in the *
|
||||
* documentation and/or other materials provided with the distribution. *
|
||||
* *
|
||||
* 3. The end-user documentation included with the redistribution, if any, *
|
||||
* must include the following acknowlegement: *
|
||||
* *
|
||||
* "This product includes software developed by the Apache Software *
|
||||
* Foundation <http://www.apache.org/>." *
|
||||
* *
|
||||
* Alternately, this acknowlegement may appear in the software itself, if *
|
||||
* and wherever such third-party acknowlegements normally appear. *
|
||||
* *
|
||||
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software *
|
||||
* Foundation" must not be used to endorse or promote products derived *
|
||||
* from this software without prior written permission. For written *
|
||||
* permission, please contact <apache@apache.org>. *
|
||||
* *
|
||||
* 5. Products derived from this software may not be called "Apache" nor may *
|
||||
* "Apache" appear in their names without prior written permission of the *
|
||||
* Apache Software Foundation. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY *
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
|
||||
* THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY *
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, *
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
|
||||
* POSSIBILITY OF SUCH DAMAGE. *
|
||||
* *
|
||||
* ========================================================================= *
|
||||
* *
|
||||
* This software consists of voluntary contributions made by many indivi- *
|
||||
* duals on behalf of the Apache Software Foundation. For more information *
|
||||
* on the Apache Software Foundation, please see <http://www.apache.org/>. *
|
||||
* *
|
||||
* ========================================================================= */
|
|
@ -1,38 +1,38 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/simplepool-examples/licenses/SimplePool License.txt,v $
|
||||
* $Revision: 1.1 $
|
||||
* $Date: 2004-03-28 02:04:54 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
/*
|
||||
* $Source: /home/cvsroot/manywhere/simplepool/simplepool-examples/licenses/SimplePool\040License.txt,v $
|
||||
* $Revision: 1.1 $
|
||||
* $Date: 2004/03/20 13:36:08 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
|
@ -1,77 +1,77 @@
|
|||
<!DOCTYPE html PUBLIC "-//Tigris//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://style.tigris.org/tigris_transitional.dtd">
|
||||
<%@page import="javax.naming.*" %>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
/* <![CDATA[ */
|
||||
@import "../includes/tigris.css";
|
||||
@import "../includes/inst.css";
|
||||
/* ]]> */
|
||||
</style>
|
||||
<title>simplepool: Servlet DataSource Examples</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
<script language="javascript" type="text/javascript">
|
||||
<% boolean enabled = (pageContext.findAttribute("ServletPoolDS") != null); %>
|
||||
function RTFM()
|
||||
{
|
||||
alert("Please read the instructions to enable this example.");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0" class="composite">
|
||||
<table border="0" cellspacing="0" cellpadding="4" width="100%" id="main">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div id="bodycol">
|
||||
<div id="apphead">
|
||||
<h2><small>simplepool</small><br />
|
||||
Servlet DataSource Examples</h2>
|
||||
</div>
|
||||
<p class="tasknav"><a href="../index.html">Examples Home</a></p>
|
||||
<p><strong>Please read the instructions before trying to run the examples.</strong></p>
|
||||
<div id="examples" class="app">
|
||||
<div class="axial">
|
||||
<table border="0" cellspacing="2" cellpadding="3">
|
||||
<tr>
|
||||
<th>Summary</th>
|
||||
<td>A simple database connection pool example using the SimplePool Servlet.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 1</th>
|
||||
<td><a href="<% if (enabled) { %>scriptlet.jsp<% } else { %>javascript:RTFM()<% } %>">Scriptlet Example</a> [<a href="../source.jsp?file=servlet/scriptlet.jsp">source</a>]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 2</th>
|
||||
<td><a href="<% if (enabled) { %>jstl.jsp<% } else { %>javascript:RTFM()<% } %>">JSTL Example</a> [<a href="../source.jsp?file=servlet/jstl.jsp">source</a>]</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="h3" id="instructions">
|
||||
<h3>Instructions</h3>
|
||||
<p>The SimplePoolServlet is used to create, access and manage the connection pool.</p>
|
||||
<p class="alert">First, make sure that your JDBC driver is available, by placing its components in this webapp's WEB-INF/lib/ directory.</p>
|
||||
<p>The SimplePoolServlet is configured using a set of required initialization parameters, as show in this webapp's <code><a href="../source.jsp?file=WEB-INF/web.xml">WEB-INF/web.xml</a></code> under the <code><servlet/></code> section:</p>
|
||||
<ul>
|
||||
<li>The <code class="info">varName</code> initialization parameter is used to specify the name of the variable which will hold a reference to the DataSource object created by the Servlet.</li>
|
||||
<li>The <code class="info">driver</code> initialization parameter is used to specify the name of the JDBC driver class to be registered. For <code>example: com.mysql.jdbc.Driver</code>.</li>
|
||||
<li>The <span class="info">user</span> initialization parameter is used to specify the database username, if any.</li>
|
||||
<li>The <code class="info">password</code> initialization parameter is used to specify the database password, if any.</li>
|
||||
<li>The <code class="info">jdbcUrl</code> initialization parameter is used to specify the JDBC URL associated with the database. For example: <code>jdbc:mysql://localhost:3306/dbname</code>.</li>
|
||||
<li>The <code class="info">minConns</code> initialization parameter is used to specify the minimum number of connections to start the pool with.</li>
|
||||
<li>The <code class="info">maxConns</code> initialization parameter is used to specify the maximum number of connections to be dynamically created in the pool.</li>
|
||||
<li>The <code class="info">maxConnTime</code> initialization parameter is used to specify the time (in days) between connection resets. The pool manager will perform a basic cleanup at the specified interval.</li>
|
||||
<li>The <code class="info">maxCheckoutSeconds</code> initialization parameter is used to specify the maximum time a connection can be checked out before being recycled. A zero value turns this option off.</li>
|
||||
</ul>
|
||||
<p>Please note that <em>all parameters are required</em>.</p>
|
||||
<p class="alert">Please take a minute to uncomment the <code><servlet/></code> declaration and configure the Servlet's initialization parameters in this webapp's <code><a href="../source.jsp?file=WEB-INF/web.xml">WEB-INF/web.xml</a></code>. Once done, please restart the webapp and/or Tomcat. The examples will be functional upon restart.</p>
|
||||
<p>Please look at the [source] of the provided examples to understand how to access the connection pool from a scriptlet or using the JSTL SQL tags. The examples demonstrates how to list all of the tables contained in the specified database.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html PUBLIC "-//Tigris//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://style.tigris.org/tigris_transitional.dtd">
|
||||
<%@page import="javax.naming.*" %>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
/* <![CDATA[ */
|
||||
@import "../includes/tigris.css";
|
||||
@import "../includes/inst.css";
|
||||
/* ]]> */
|
||||
</style>
|
||||
<title>simplepool: Servlet DataSource Examples</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
<script language="javascript" type="text/javascript">
|
||||
<% boolean enabled = (pageContext.findAttribute("ServletPoolDS") != null); %>
|
||||
function RTFM()
|
||||
{
|
||||
alert("Please read the instructions to enable this example.");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0" class="composite">
|
||||
<table border="0" cellspacing="0" cellpadding="4" width="100%" id="main">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div id="bodycol">
|
||||
<div id="apphead">
|
||||
<h2><small>simplepool</small><br />
|
||||
Servlet DataSource Examples</h2>
|
||||
</div>
|
||||
<p class="tasknav"><a href="../index.html">Examples Home</a></p>
|
||||
<p><strong>Please read the instructions before trying to run the examples.</strong></p>
|
||||
<div id="examples" class="app">
|
||||
<div class="axial">
|
||||
<table border="0" cellspacing="2" cellpadding="3">
|
||||
<tr>
|
||||
<th>Summary</th>
|
||||
<td>A simple database connection pool example using the SimplePool Servlet.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 1</th>
|
||||
<td><a href="<% if (enabled) { %>scriptlet.jsp<% } else { %>javascript:RTFM()<% } %>">Scriptlet Example</a> [<a href="../source.jsp?file=servlet/scriptlet.jsp">source</a>]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 2</th>
|
||||
<td><a href="<% if (enabled) { %>jstl.jsp<% } else { %>javascript:RTFM()<% } %>">JSTL Example</a> [<a href="../source.jsp?file=servlet/jstl.jsp">source</a>]</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="h3" id="instructions">
|
||||
<h3>Instructions</h3>
|
||||
<p>The SimplePoolServlet is used to create, access and manage the connection pool.</p>
|
||||
<p class="alert">First, make sure that your JDBC driver is available, by placing its components in this webapp's WEB-INF/lib/ directory.</p>
|
||||
<p>The SimplePoolServlet is configured using a set of required initialization parameters, as show in this webapp's <code><a href="../source.jsp?file=WEB-INF/web.xml">WEB-INF/web.xml</a></code> under the <code><servlet/></code> section:</p>
|
||||
<ul>
|
||||
<li>The <code class="info">varName</code> initialization parameter is used to specify the name of the variable which will hold a reference to the DataSource object created by the Servlet.</li>
|
||||
<li>The <code class="info">driver</code> initialization parameter is used to specify the name of the JDBC driver class to be registered. For <code>example: com.mysql.jdbc.Driver</code>.</li>
|
||||
<li>The <span class="info">user</span> initialization parameter is used to specify the database username, if any.</li>
|
||||
<li>The <code class="info">password</code> initialization parameter is used to specify the database password, if any.</li>
|
||||
<li>The <code class="info">jdbcUrl</code> initialization parameter is used to specify the JDBC URL associated with the database. For example: <code>jdbc:mysql://localhost:3306/dbname</code>.</li>
|
||||
<li>The <code class="info">minConns</code> initialization parameter is used to specify the minimum number of connections to start the pool with.</li>
|
||||
<li>The <code class="info">maxConns</code> initialization parameter is used to specify the maximum number of connections to be dynamically created in the pool.</li>
|
||||
<li>The <code class="info">maxConnTime</code> initialization parameter is used to specify the time (in days) between connection resets. The pool manager will perform a basic cleanup at the specified interval.</li>
|
||||
<li>The <code class="info">maxCheckoutSeconds</code> initialization parameter is used to specify the maximum time a connection can be checked out before being recycled. A zero value turns this option off.</li>
|
||||
</ul>
|
||||
<p>Please note that <em>all parameters are required</em>.</p>
|
||||
<p class="alert">Please take a minute to uncomment the <code><servlet/></code> declaration and configure the Servlet's initialization parameters in this webapp's <code><a href="../source.jsp?file=WEB-INF/web.xml">WEB-INF/web.xml</a></code>. Once done, please restart the webapp and/or Tomcat. The examples will be functional upon restart.</p>
|
||||
<p>Please look at the [source] of the provided examples to understand how to access the connection pool from a scriptlet or using the JSTL SQL tags. The examples demonstrates how to list all of the tables contained in the specified database.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
||||
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool Servlet/JSTL Example</title>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
||||
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool Servlet/JSTL Example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%-- Execute the query using our DataSource --%>
|
||||
<sql:query var="rs" dataSource="${ServletPoolDS}">
|
||||
<body>
|
||||
|
||||
<%-- Execute the query using our DataSource --%>
|
||||
<sql:query var="rs" dataSource="${ServletPoolDS}">
|
||||
SHOW TABLES
|
||||
</sql:query>
|
||||
|
||||
</sql:query>
|
||||
|
||||
<h3>Tables</h3>
|
||||
<ul>
|
||||
|
||||
<%--
|
||||
Loop through the result set and
|
||||
display the current column value
|
||||
--%>
|
||||
<ul>
|
||||
|
||||
<%--
|
||||
Loop through the result set and
|
||||
display the current column value
|
||||
--%>
|
||||
<c:forEach var="row" items="${rs.rowsByIndex}">
|
||||
<li><c:out value="${row[0]}"/></li>
|
||||
</c:forEach>
|
||||
|
||||
<ul>
|
||||
</c:forEach>
|
||||
|
||||
<ul>
|
||||
</body>
|
||||
</html>
|
|
@ -1,44 +1,44 @@
|
|||
<%@page import="javax.naming.*, javax.sql.*, java.sql.*;" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool Servlet Example</title>
|
||||
<%@page import="javax.naming.*, javax.sql.*, java.sql.*;" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool Servlet Example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%
|
||||
<body>
|
||||
|
||||
<%
|
||||
// Get a reference to our DataSource
|
||||
DataSource ds = (DataSource) pageContext.findAttribute("ServletPoolDS");
|
||||
|
||||
// Get a connection from the pool
|
||||
Connection conn = ds.getConnection();
|
||||
|
||||
// Create a new statement
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// Execute the query
|
||||
ResultSet rst = stmt.executeQuery("SHOW TABLES");
|
||||
%>
|
||||
|
||||
DataSource ds = (DataSource) pageContext.findAttribute("ServletPoolDS");
|
||||
|
||||
// Get a connection from the pool
|
||||
Connection conn = ds.getConnection();
|
||||
|
||||
// Create a new statement
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// Execute the query
|
||||
ResultSet rst = stmt.executeQuery("SHOW TABLES");
|
||||
%>
|
||||
|
||||
<h3>Tables</h3>
|
||||
<ul>
|
||||
<%
|
||||
// Loop through the result set and
|
||||
// display the current column value
|
||||
while (rst.next()) {
|
||||
%>
|
||||
<li><%= rst.getString(1) %></li>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<ul>
|
||||
|
||||
<%
|
||||
// Close the result set, statement and connection
|
||||
// and display the current column value
|
||||
rst.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
%>
|
||||
<ul>
|
||||
<%
|
||||
// Loop through the result set and
|
||||
// display the current column value
|
||||
while (rst.next()) {
|
||||
%>
|
||||
<li><%= rst.getString(1) %></li>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<ul>
|
||||
|
||||
<%
|
||||
// Close the result set, statement and connection
|
||||
// and display the current column value
|
||||
rst.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
%>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
<%@page import="java.io.*"%>
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<%
|
||||
<%@page import="java.io.*"%>
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<%
|
||||
String file = request.getParameter("file");
|
||||
if ((file != null) && (file.trim().length() > 0) && (file.indexOf( ".." ) == -1)) {
|
||||
InputStream is = pageContext.getServletContext().getResourceAsStream(file);
|
||||
if (is != null) {
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
for (int ch = isr.read(); ch != -1; ch = isr.read()) {
|
||||
if (ch == '<') {
|
||||
out.print("<");
|
||||
} else if (ch == '\t') {
|
||||
out.print(" ");
|
||||
} else {
|
||||
out.print((char) ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
</pre>
|
||||
if (is != null) {
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
for (int ch = isr.read(); ch != -1; ch = isr.read()) {
|
||||
if (ch == '<') {
|
||||
out.print("<");
|
||||
} else if (ch == '\t') {
|
||||
out.print(" ");
|
||||
} else {
|
||||
out.print((char) ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/src/net/java/dev/simplepool/SimplePool.java,v $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2004-03-30 02:10:16 $
|
||||
* $Source: /home/cvsroot/manywhere/simplepool/src/net/java/dev/simplepool/SimplePool.java,v $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2004/03/17 23:35:36 $
|
||||
*
|
||||
* Copyright (c) 2002, Marc A. Mnich (http://www.javaexchange.com/)
|
||||
* All rights reserved.
|
||||
|
@ -33,7 +33,7 @@ import java.util.Date;
|
|||
* @author <a href="http://www.javaexchange.com/">Marc A. Mnich</a>
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.2 $, $Date: 2004-03-30 02:10:16 $
|
||||
* @version $Revision: 1.5 $, $Date: 2004/03/17 23:35:36 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePool implements Runnable {
|
||||
|
@ -398,10 +398,9 @@ public class SimplePool implements Runnable {
|
|||
res = "freed " + conn.toString();
|
||||
log.debug("Freed connection [" + String.valueOf(thisconn) + ']');
|
||||
} else {
|
||||
log.error("Could not free connection.");
|
||||
log.error("Could not free connection [" + String.valueOf(thisconn) + ']');
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,362 +1,357 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/src/net/java/dev/simplepool/SimplePoolConnection.java,v $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2004-03-30 02:10:16 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Basic implementation of {@link java.sql.Connection}.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.2 $, $Date: 2004-03-30 02:10:16 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolConnection implements Connection {
|
||||
|
||||
private Connection conn;
|
||||
private SimplePool pool;
|
||||
|
||||
/**
|
||||
* Creates a new SimplePoolConnection object.
|
||||
*
|
||||
* @param pool The connection pool.
|
||||
*/
|
||||
public SimplePoolConnection(SimplePool pool)
|
||||
throws SQLException {
|
||||
this.pool = pool;
|
||||
conn = pool.getConnection();
|
||||
if (conn == null)
|
||||
{
|
||||
throw new SQLException("No connections currently available in the pool.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setAutoCommit(boolean)}.
|
||||
*/
|
||||
public void setAutoCommit(boolean autoCommit)
|
||||
throws SQLException {
|
||||
conn.setAutoCommit(autoCommit);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getAutoCommit}.
|
||||
*/
|
||||
public boolean getAutoCommit()
|
||||
throws SQLException {
|
||||
return conn.getAutoCommit();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setCatalog(String)}.
|
||||
*/
|
||||
public void setCatalog(String catalog)
|
||||
throws SQLException {
|
||||
conn.setCatalog(catalog);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getCatalog()}.
|
||||
*/
|
||||
public String getCatalog()
|
||||
throws SQLException {
|
||||
return conn.getCatalog();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#isClosed}.
|
||||
*/
|
||||
public boolean isClosed()
|
||||
throws SQLException {
|
||||
return conn.isClosed();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setHoldability(int)}.
|
||||
*/
|
||||
public void setHoldability(int holdability)
|
||||
throws SQLException {
|
||||
conn.setHoldability(holdability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getHoldability}.
|
||||
*/
|
||||
public int getHoldability()
|
||||
throws SQLException {
|
||||
return conn.getHoldability();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getMetaData}.
|
||||
*/
|
||||
public DatabaseMetaData getMetaData()
|
||||
throws SQLException {
|
||||
return conn.getMetaData();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setReadOnly(boolean)}.
|
||||
*/
|
||||
public void setReadOnly(boolean readOnly)
|
||||
throws SQLException {
|
||||
conn.setReadOnly(readOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#isReadOnly}.
|
||||
*/
|
||||
public boolean isReadOnly()
|
||||
throws SQLException {
|
||||
return conn.isReadOnly();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setSavepoint}.
|
||||
*/
|
||||
public Savepoint setSavepoint()
|
||||
throws SQLException {
|
||||
return conn.setSavepoint();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setSavepoint(String)}.
|
||||
*/
|
||||
public Savepoint setSavepoint(String savepoint)
|
||||
throws SQLException {
|
||||
return conn.setSavepoint(savepoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setTransactionIsolation(int)}.
|
||||
*/
|
||||
public void setTransactionIsolation(int level)
|
||||
throws SQLException {
|
||||
conn.setTransactionIsolation(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getTransactionIsolation}.
|
||||
*/
|
||||
public int getTransactionIsolation()
|
||||
throws SQLException {
|
||||
return conn.getTransactionIsolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setTypeMap(Map)}.
|
||||
*/
|
||||
public void setTypeMap(Map map)
|
||||
throws SQLException {
|
||||
conn.setTypeMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getTypeMap}.
|
||||
*/
|
||||
public Map getTypeMap()
|
||||
throws SQLException {
|
||||
return conn.getTypeMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getWarnings}.
|
||||
*/
|
||||
public SQLWarning getWarnings()
|
||||
throws SQLException {
|
||||
return conn.getWarnings();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#clearWarnings}.
|
||||
*/
|
||||
public void clearWarnings()
|
||||
throws SQLException {
|
||||
conn.clearWarnings();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#close}.
|
||||
*/
|
||||
public void close()
|
||||
throws SQLException {
|
||||
pool.freeConnection(conn);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#commit}.
|
||||
*/
|
||||
public void commit()
|
||||
throws SQLException {
|
||||
conn.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#createStatement}.
|
||||
*/
|
||||
public Statement createStatement()
|
||||
throws SQLException {
|
||||
return conn.createStatement();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#createStatement(int, int)}.
|
||||
*/
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency)
|
||||
throws SQLException {
|
||||
return conn.createStatement(resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#createStatement(int, int, int)}.
|
||||
*/
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
|
||||
throws SQLException {
|
||||
return conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#nativeSQL(String)}.
|
||||
*/
|
||||
public String nativeSQL(String sql)
|
||||
throws SQLException {
|
||||
return conn.nativeSQL(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareCall(String)}.
|
||||
*/
|
||||
public CallableStatement prepareCall(String sql)
|
||||
throws SQLException {
|
||||
return conn.prepareCall(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareCall(String, int, int)}.
|
||||
*/
|
||||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
|
||||
throws SQLException {
|
||||
return conn.prepareCall(sql, resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareCall(String, int, int, int)}.
|
||||
*/
|
||||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
|
||||
int resultSetHoldability)
|
||||
throws SQLException {
|
||||
return conn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, int, int)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, int, int, int)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
|
||||
int resultSetHoldability)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, int[])}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, columnIndexes);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, String[])}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, String[] columnNames)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, columnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#releaseSavepoint(Savepoint)}.
|
||||
*/
|
||||
public void releaseSavepoint(Savepoint savepoint)
|
||||
throws SQLException {
|
||||
conn.releaseSavepoint(savepoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#rollback}.
|
||||
*/
|
||||
public void rollback()
|
||||
throws SQLException {
|
||||
conn.rollback();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#rollback(Savepoint)}.
|
||||
*/
|
||||
public void rollback(Savepoint savepoint)
|
||||
throws SQLException {
|
||||
conn.rollback(savepoint);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Source: /home/cvsroot/manywhere/simplepool/src/net/java/dev/simplepool/SimplePoolConnection.java,v $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2004/03/17 23:35:36 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Basic implementation of {@link java.sql.Connection}.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.5 $, $Date: 2004/03/17 23:35:36 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolConnection implements Connection {
|
||||
|
||||
private Connection conn;
|
||||
private SimplePool pool;
|
||||
|
||||
/**
|
||||
* Creates a new SimplePoolConnection object.
|
||||
*
|
||||
* @param pool The connection pool.
|
||||
*/
|
||||
public SimplePoolConnection(SimplePool pool) {
|
||||
this.pool = pool;
|
||||
conn = pool.getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setAutoCommit(boolean)}.
|
||||
*/
|
||||
public void setAutoCommit(boolean autoCommit)
|
||||
throws SQLException {
|
||||
conn.setAutoCommit(autoCommit);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getAutoCommit}.
|
||||
*/
|
||||
public boolean getAutoCommit()
|
||||
throws SQLException {
|
||||
return conn.getAutoCommit();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setCatalog(String)}.
|
||||
*/
|
||||
public void setCatalog(String catalog)
|
||||
throws SQLException {
|
||||
conn.setCatalog(catalog);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getCatalog()}.
|
||||
*/
|
||||
public String getCatalog()
|
||||
throws SQLException {
|
||||
return conn.getCatalog();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#isClosed}.
|
||||
*/
|
||||
public boolean isClosed()
|
||||
throws SQLException {
|
||||
return conn.isClosed();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setHoldability(int)}.
|
||||
*/
|
||||
public void setHoldability(int holdability)
|
||||
throws SQLException {
|
||||
conn.setHoldability(holdability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getHoldability}.
|
||||
*/
|
||||
public int getHoldability()
|
||||
throws SQLException {
|
||||
return conn.getHoldability();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getMetaData}.
|
||||
*/
|
||||
public DatabaseMetaData getMetaData()
|
||||
throws SQLException {
|
||||
return conn.getMetaData();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setReadOnly(boolean)}.
|
||||
*/
|
||||
public void setReadOnly(boolean readOnly)
|
||||
throws SQLException {
|
||||
conn.setReadOnly(readOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#isReadOnly}.
|
||||
*/
|
||||
public boolean isReadOnly()
|
||||
throws SQLException {
|
||||
return conn.isReadOnly();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setSavepoint}.
|
||||
*/
|
||||
public Savepoint setSavepoint()
|
||||
throws SQLException {
|
||||
return conn.setSavepoint();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setSavepoint(String)}.
|
||||
*/
|
||||
public Savepoint setSavepoint(String savepoint)
|
||||
throws SQLException {
|
||||
return conn.setSavepoint(savepoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setTransactionIsolation(int)}.
|
||||
*/
|
||||
public void setTransactionIsolation(int level)
|
||||
throws SQLException {
|
||||
conn.setTransactionIsolation(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getTransactionIsolation}.
|
||||
*/
|
||||
public int getTransactionIsolation()
|
||||
throws SQLException {
|
||||
return conn.getTransactionIsolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setTypeMap(Map)}.
|
||||
*/
|
||||
public void setTypeMap(Map map)
|
||||
throws SQLException {
|
||||
conn.setTypeMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getTypeMap}.
|
||||
*/
|
||||
public Map getTypeMap()
|
||||
throws SQLException {
|
||||
return conn.getTypeMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getWarnings}.
|
||||
*/
|
||||
public SQLWarning getWarnings()
|
||||
throws SQLException {
|
||||
return conn.getWarnings();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#clearWarnings}.
|
||||
*/
|
||||
public void clearWarnings()
|
||||
throws SQLException {
|
||||
conn.clearWarnings();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#close}.
|
||||
*/
|
||||
public void close()
|
||||
throws SQLException {
|
||||
pool.freeConnection(conn);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#commit}.
|
||||
*/
|
||||
public void commit()
|
||||
throws SQLException {
|
||||
conn.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#createStatement}.
|
||||
*/
|
||||
public Statement createStatement()
|
||||
throws SQLException {
|
||||
return conn.createStatement();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#createStatement(int, int)}.
|
||||
*/
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency)
|
||||
throws SQLException {
|
||||
return conn.createStatement(resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#createStatement(int, int, int)}.
|
||||
*/
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
|
||||
throws SQLException {
|
||||
return conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#nativeSQL(String)}.
|
||||
*/
|
||||
public String nativeSQL(String sql)
|
||||
throws SQLException {
|
||||
return conn.nativeSQL(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareCall(String)}.
|
||||
*/
|
||||
public CallableStatement prepareCall(String sql)
|
||||
throws SQLException {
|
||||
return conn.prepareCall(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareCall(String, int, int)}.
|
||||
*/
|
||||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
|
||||
throws SQLException {
|
||||
return conn.prepareCall(sql, resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareCall(String, int, int, int)}.
|
||||
*/
|
||||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
|
||||
int resultSetHoldability)
|
||||
throws SQLException {
|
||||
return conn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, int, int)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, int, int, int)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
|
||||
int resultSetHoldability)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, int[])}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, columnIndexes);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, String[])}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, String[] columnNames)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, columnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#releaseSavepoint(Savepoint)}.
|
||||
*/
|
||||
public void releaseSavepoint(Savepoint savepoint)
|
||||
throws SQLException {
|
||||
conn.releaseSavepoint(savepoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#rollback}.
|
||||
*/
|
||||
public void rollback()
|
||||
throws SQLException {
|
||||
conn.rollback();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#rollback(Savepoint)}.
|
||||
*/
|
||||
public void rollback(Savepoint savepoint)
|
||||
throws SQLException {
|
||||
conn.rollback(savepoint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,319 +1,319 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/src/net/java/dev/simplepool/SimplePoolDataSource.java,v $
|
||||
* $Revision: 1.1 $
|
||||
* $Date: 2004-03-28 02:04:57 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Basic implementation of {@link javax.sql.DataSource}.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.1 $, $Date: 2004-03-28 02:04:57 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolDataSource implements DataSource {
|
||||
|
||||
private PrintWriter logWriter = new PrintWriter(System.out);
|
||||
private SimplePool pool = null;
|
||||
|
||||
private String driver = "";
|
||||
private String jdbcUrl = "";
|
||||
private String user = "";
|
||||
private String password = "";
|
||||
private String minConns = "";
|
||||
private String maxConns = "";
|
||||
private String maxConnTime = "";
|
||||
private String maxCheckoutSeconds = "";
|
||||
|
||||
/**
|
||||
* Initializes the connection pool.
|
||||
*
|
||||
* @throws Exception if the pool could not be intialized.
|
||||
*/
|
||||
protected void init() throws Exception {
|
||||
|
||||
pool = new SimplePool(driver, jdbcUrl, user, password,
|
||||
Integer.parseInt(minConns), Integer.parseInt(maxConns),
|
||||
Double.parseDouble(maxConnTime), Integer.parseInt(maxCheckoutSeconds));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getConnection()}.
|
||||
*/
|
||||
public Connection getConnection() throws SQLException {
|
||||
|
||||
if (pool == null) {
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new SQLException("Error initializing Connection Broker.");
|
||||
}
|
||||
}
|
||||
|
||||
return new SimplePoolConnection(pool);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getConnection(String, String)}.
|
||||
*/
|
||||
public Connection getConnection(String username, String password)
|
||||
throws SQLException {
|
||||
|
||||
throw new SQLException("Not supported in this DataSource.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#setLogWriter(PrintWriter)}.
|
||||
*/
|
||||
public void setLogWriter(PrintWriter out) throws SQLException {
|
||||
logWriter = out;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getLogWriter}.
|
||||
*/
|
||||
public PrintWriter getLogWriter() {
|
||||
return logWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#setLoginTimeout(int)}.
|
||||
*/
|
||||
public void setLoginTimeout(int seconds) throws SQLException {
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getLoginTimeout}.
|
||||
*/
|
||||
public int getLoginTimeout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the connection pool.
|
||||
*/
|
||||
public void close() {
|
||||
pool.destroy();
|
||||
pool = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JDBC driver.
|
||||
*
|
||||
* @param driver The JDBC driver. e.g. 'com.mysql.jdbc.Driver'
|
||||
*
|
||||
* @see #getDriver()
|
||||
*/
|
||||
public void setDriver(String driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JDBC driver.
|
||||
*
|
||||
* @return The JDBC driver string.
|
||||
*
|
||||
* @see #setDriver(String)
|
||||
*/
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JDBC connect string.
|
||||
*
|
||||
* @param jdbcUrl The JDBC connection URL string. e.g. 'jdbc:mysql://localhost:3306/dbname'
|
||||
*
|
||||
* @see #getJdbcUrl()
|
||||
*/
|
||||
public void setJdbcUrl(String jdbcUrl) {
|
||||
this.jdbcUrl = jdbcUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JDBC connect string.
|
||||
*
|
||||
* @return The JDBC connection URL string.
|
||||
*
|
||||
* @see #setJdbcUrl(String)
|
||||
*/
|
||||
public String getJdbcUrl() {
|
||||
return jdbcUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the database login name.
|
||||
*
|
||||
* @param user The database login name. e.g. 'Scott'
|
||||
*
|
||||
* @see #getUser()
|
||||
*/
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database login name.
|
||||
*
|
||||
* @return The login name string.
|
||||
*
|
||||
* @see #setUser(String)
|
||||
*/
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the database password.
|
||||
*
|
||||
* @param password The database password. e.g. 'Tiger'
|
||||
*
|
||||
* @see #getPassword()
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database password.
|
||||
*
|
||||
* @return The password string.
|
||||
*
|
||||
* @see #setPassword(String)
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum number of connections to start with.
|
||||
*
|
||||
* @param minConns The minimum number of connections.
|
||||
*
|
||||
* @see #getMinConns()
|
||||
*/
|
||||
public void setMinConns(String minConns) {
|
||||
this.minConns = minConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minimum number of connections to start with.
|
||||
*
|
||||
* @return The minimum number of connections string.
|
||||
*
|
||||
* @see #setMinConns(String)
|
||||
*/
|
||||
public String getMinConns() {
|
||||
return minConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of connections in dynamic pool.
|
||||
*
|
||||
* @param maxConns The maximum number of connections.
|
||||
*
|
||||
* @see #getMaxConns()
|
||||
*/
|
||||
public void setMaxConns(String maxConns) {
|
||||
this.maxConns = maxConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum number of connections in dynamic pool.
|
||||
*
|
||||
* @return The maximum number of connection string.
|
||||
*
|
||||
* @see #setMaxConns(String)
|
||||
*/
|
||||
public String getMaxConns() {
|
||||
return maxConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time in days between connection resets.
|
||||
*
|
||||
* @param maxConnTime The maximum connection time.
|
||||
*
|
||||
* @see #getMaxConnTime()
|
||||
*/
|
||||
public void setMaxConnTime(String maxConnTime) {
|
||||
this.maxConnTime = maxConnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time in days between connection resets.
|
||||
*
|
||||
* @return The maximum connection time string.
|
||||
*
|
||||
* @see #setMaxConnTime(String)
|
||||
*/
|
||||
public String getMaxConnTime() {
|
||||
return maxConnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max time a connection can be checked out before being recycled.
|
||||
*
|
||||
* @param maxCheckoutSeconds The maximum number of seconds to wait before recycling a connection.
|
||||
*
|
||||
* @see #getMaxCheckoutSeconds()
|
||||
*/
|
||||
public void setMaxCheckoutSeconds(String maxCheckoutSeconds) {
|
||||
this.maxCheckoutSeconds = maxCheckoutSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max time a connection can be checked out before being recycled.
|
||||
*
|
||||
* @return The maximum checkout time string.
|
||||
*
|
||||
* @see #setMaxCheckoutSeconds(String)
|
||||
*/
|
||||
public String getMaxCheckoutSeconds() {
|
||||
return maxCheckoutSeconds;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Source: /home/cvsroot/manywhere/simplepool/src/net/java/dev/simplepool/SimplePoolDataSource.java,v $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2004/03/17 23:19:02 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Basic implementation of {@link javax.sql.DataSource}.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.4 $, $Date: 2004/03/17 23:19:02 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolDataSource implements DataSource {
|
||||
|
||||
private PrintWriter logWriter = new PrintWriter(System.out);
|
||||
private SimplePool pool = null;
|
||||
|
||||
private String driver = "";
|
||||
private String jdbcUrl = "";
|
||||
private String user = "";
|
||||
private String password = "";
|
||||
private String minConns = "";
|
||||
private String maxConns = "";
|
||||
private String maxConnTime = "";
|
||||
private String maxCheckoutSeconds = "";
|
||||
|
||||
/**
|
||||
* Initializes the connection pool.
|
||||
*
|
||||
* @throws Exception if the pool could not be intialized.
|
||||
*/
|
||||
protected void init() throws Exception {
|
||||
|
||||
pool = new SimplePool(driver, jdbcUrl, user, password,
|
||||
Integer.parseInt(minConns), Integer.parseInt(maxConns),
|
||||
Double.parseDouble(maxConnTime), Integer.parseInt(maxCheckoutSeconds));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getConnection()}.
|
||||
*/
|
||||
public Connection getConnection() throws SQLException {
|
||||
|
||||
if (pool == null) {
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new SQLException("Error initializing Connection Broker.");
|
||||
}
|
||||
}
|
||||
|
||||
return new SimplePoolConnection(pool);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getConnection(String, String)}.
|
||||
*/
|
||||
public Connection getConnection(String username, String password)
|
||||
throws SQLException {
|
||||
|
||||
throw new SQLException("Not supported in this DataSource.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#setLogWriter(PrintWriter)}.
|
||||
*/
|
||||
public void setLogWriter(PrintWriter out) throws SQLException {
|
||||
logWriter = out;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getLogWriter}.
|
||||
*/
|
||||
public PrintWriter getLogWriter() {
|
||||
return logWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#setLoginTimeout(int)}.
|
||||
*/
|
||||
public void setLoginTimeout(int seconds) throws SQLException {
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getLoginTimeout}.
|
||||
*/
|
||||
public int getLoginTimeout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the connection pool.
|
||||
*/
|
||||
public void close() {
|
||||
pool.destroy();
|
||||
pool = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JDBC driver.
|
||||
*
|
||||
* @param driver The JDBC driver. e.g. 'com.mysql.jdbc.Driver'
|
||||
*
|
||||
* @see #getDriver()
|
||||
*/
|
||||
public void setDriver(String driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JDBC driver.
|
||||
*
|
||||
* @return The JDBC driver string.
|
||||
*
|
||||
* @see #setDriver(String)
|
||||
*/
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JDBC connect string.
|
||||
*
|
||||
* @param jdbcUrl The JDBC connection URL string. e.g. 'jdbc:mysql://localhost:3306/dbname'
|
||||
*
|
||||
* @see #getJdbcUrl()
|
||||
*/
|
||||
public void setJdbcUrl(String jdbcUrl) {
|
||||
this.jdbcUrl = jdbcUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JDBC connect string.
|
||||
*
|
||||
* @return The JDBC connection URL string.
|
||||
*
|
||||
* @see #setJdbcUrl(String)
|
||||
*/
|
||||
public String getJdbcUrl() {
|
||||
return jdbcUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the database login name.
|
||||
*
|
||||
* @param user The database login name. e.g. 'Scott'
|
||||
*
|
||||
* @see #getUser()
|
||||
*/
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database login name.
|
||||
*
|
||||
* @return The login name string.
|
||||
*
|
||||
* @see #setUser(String)
|
||||
*/
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the database password.
|
||||
*
|
||||
* @param password The database password. e.g. 'Tiger'
|
||||
*
|
||||
* @see #getPassword()
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database password.
|
||||
*
|
||||
* @return The password string.
|
||||
*
|
||||
* @see #setPassword(String)
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum number of connections to start with.
|
||||
*
|
||||
* @param minConns The minimum number of connections.
|
||||
*
|
||||
* @see #getMinConns()
|
||||
*/
|
||||
public void setMinConns(String minConns) {
|
||||
this.minConns = minConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minimum number of connections to start with.
|
||||
*
|
||||
* @return The minimum number of connections string.
|
||||
*
|
||||
* @see #setMinConns(String)
|
||||
*/
|
||||
public String getMinConns() {
|
||||
return minConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of connections in dynamic pool.
|
||||
*
|
||||
* @param maxConns The maximum number of connections.
|
||||
*
|
||||
* @see #getMaxConns()
|
||||
*/
|
||||
public void setMaxConns(String maxConns) {
|
||||
this.maxConns = maxConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum number of connections in dynamic pool.
|
||||
*
|
||||
* @return The maximum number of connection string.
|
||||
*
|
||||
* @see #setMaxConns(String)
|
||||
*/
|
||||
public String getMaxConns() {
|
||||
return maxConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time in days between connection resets.
|
||||
*
|
||||
* @param maxConnTime The maximum connection time.
|
||||
*
|
||||
* @see #getMaxConnTime()
|
||||
*/
|
||||
public void setMaxConnTime(String maxConnTime) {
|
||||
this.maxConnTime = maxConnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time in days between connection resets.
|
||||
*
|
||||
* @return The maximum connection time string.
|
||||
*
|
||||
* @see #setMaxConnTime(String)
|
||||
*/
|
||||
public String getMaxConnTime() {
|
||||
return maxConnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max time a connection can be checked out before being recycled.
|
||||
*
|
||||
* @param maxCheckoutSeconds The maximum number of seconds to wait before recycling a connection.
|
||||
*
|
||||
* @see #getMaxCheckoutSeconds()
|
||||
*/
|
||||
public void setMaxCheckoutSeconds(String maxCheckoutSeconds) {
|
||||
this.maxCheckoutSeconds = maxCheckoutSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max time a connection can be checked out before being recycled.
|
||||
*
|
||||
* @return The maximum checkout time string.
|
||||
*
|
||||
* @see #setMaxCheckoutSeconds(String)
|
||||
*/
|
||||
public String getMaxCheckoutSeconds() {
|
||||
return maxCheckoutSeconds;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,141 +1,141 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/src/net/java/dev/simplepool/SimplePoolDataSourceFactory.java,v $
|
||||
* $Revision: 1.1 $
|
||||
* $Date: 2004-03-28 02:04:58 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.Reference;
|
||||
import javax.naming.spi.ObjectFactory;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* JNDI object factory that creates an instance of {@link SimplePoolDataSource}.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.1 $, $Date: 2004-03-28 02:04:58 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolDataSourceFactory implements ObjectFactory {
|
||||
/**
|
||||
* Creates a {@link SimplePoolDataSource} instance.
|
||||
*
|
||||
* @param obj The object containing location or reference information that is used in creating the
|
||||
* <code>DataSource</code>.
|
||||
* @param name The name of this object relative to <code>ctx</code>, or null if no name is specified.
|
||||
* @param ctx The context relative to which the <code>name</code> parameter is specified, or null if
|
||||
* <code>name</code> is relative to the default initial context.
|
||||
* @param env The possibly null environment that is used in creating the <code>DataSource</code>.
|
||||
*
|
||||
* @return The <code>DataSource</code>; null if it cannot be created.
|
||||
*
|
||||
* @throws Exception if the factory encountered an exception while attempting to create the <code>DataSource</code>,
|
||||
* and no other object factories are to be tried.
|
||||
*/
|
||||
public Object getObjectInstance(Object obj, Name name, Context ctx, Hashtable env)
|
||||
throws Exception {
|
||||
|
||||
Reference ref = (Reference) obj;
|
||||
SimplePoolDataSource dataSource = new SimplePoolDataSource();
|
||||
|
||||
/*
|
||||
driver: JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'<br>
|
||||
jdbcUrl: JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'<br>
|
||||
user: Database login name. e.g. 'Scott'<br>
|
||||
password: Database password. e.g. 'Tiger'<br>
|
||||
minConns: Minimum number of connections to start with.<br>
|
||||
maxConns: Maximum number of connections in dynamic pool.<br>
|
||||
maxConnTime: Time in days between connection resets. (Reset does a basic cleanup)<br>
|
||||
maxCheckoutSeconds: Max time a connection can be checked out before being recycled. Zero value turns option
|
||||
off, default is 60 seconds.
|
||||
*/
|
||||
|
||||
String driver = (String) ref.get("driver").getContent();
|
||||
|
||||
if (driver != null) {
|
||||
dataSource.setDriver(driver);
|
||||
}
|
||||
|
||||
String user = (String) ref.get("user").getContent();
|
||||
|
||||
if (user != null) {
|
||||
dataSource.setUser(user);
|
||||
}
|
||||
|
||||
String password = (String) ref.get("password").getContent();
|
||||
|
||||
if (password != null) {
|
||||
dataSource.setPassword(password);
|
||||
}
|
||||
|
||||
String jdbcUrl = (String) ref.get("jdbcUrl").getContent();
|
||||
|
||||
if (jdbcUrl != null) {
|
||||
dataSource.setJdbcUrl(jdbcUrl);
|
||||
}
|
||||
|
||||
String minConns = (String) ref.get("minConns").getContent();
|
||||
|
||||
if (minConns != null) {
|
||||
dataSource.setMinConns(minConns);
|
||||
}
|
||||
|
||||
String maxConns = (String) ref.get("maxConns").getContent();
|
||||
|
||||
if (maxConns != null) {
|
||||
dataSource.setMaxConns(maxConns);
|
||||
}
|
||||
|
||||
String maxConnTime = (String) ref.get("maxConnTime").getContent();
|
||||
|
||||
if (maxConnTime != null) {
|
||||
dataSource.setMaxConnTime(maxConnTime);
|
||||
}
|
||||
|
||||
String maxCheckoutSeconds = (String) ref.get("maxCheckoutSeconds").getContent();
|
||||
|
||||
if (maxCheckoutSeconds != null) {
|
||||
dataSource.setMaxCheckoutSeconds(maxCheckoutSeconds);
|
||||
}
|
||||
|
||||
dataSource.init();
|
||||
|
||||
return dataSource;
|
||||
}
|
||||
/*
|
||||
* $Source: /home/cvsroot/manywhere/simplepool/src/net/java/dev/simplepool/SimplePoolDataSourceFactory.java,v $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2004/03/17 23:19:02 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.Reference;
|
||||
import javax.naming.spi.ObjectFactory;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* JNDI object factory that creates an instance of {@link SimplePoolDataSource}.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.5 $, $Date: 2004/03/17 23:19:02 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolDataSourceFactory implements ObjectFactory {
|
||||
/**
|
||||
* Creates a {@link SimplePoolDataSource} instance.
|
||||
*
|
||||
* @param obj The object containing location or reference information that is used in creating the
|
||||
* <code>DataSource</code>.
|
||||
* @param name The name of this object relative to <code>ctx</code>, or null if no name is specified.
|
||||
* @param ctx The context relative to which the <code>name</code> parameter is specified, or null if
|
||||
* <code>name</code> is relative to the default initial context.
|
||||
* @param env The possibly null environment that is used in creating the <code>DataSource</code>.
|
||||
*
|
||||
* @return The <code>DataSource</code>; null if it cannot be created.
|
||||
*
|
||||
* @throws Exception if the factory encountered an exception while attempting to create the <code>DataSource</code>,
|
||||
* and no other object factories are to be tried.
|
||||
*/
|
||||
public Object getObjectInstance(Object obj, Name name, Context ctx, Hashtable env)
|
||||
throws Exception {
|
||||
|
||||
Reference ref = (Reference) obj;
|
||||
SimplePoolDataSource dataSource = new SimplePoolDataSource();
|
||||
|
||||
/*
|
||||
driver: JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'<br>
|
||||
jdbcUrl: JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'<br>
|
||||
user: Database login name. e.g. 'Scott'<br>
|
||||
password: Database password. e.g. 'Tiger'<br>
|
||||
minConns: Minimum number of connections to start with.<br>
|
||||
maxConns: Maximum number of connections in dynamic pool.<br>
|
||||
maxConnTime: Time in days between connection resets. (Reset does a basic cleanup)<br>
|
||||
maxCheckoutSeconds: Max time a connection can be checked out before being recycled. Zero value turns option
|
||||
off, default is 60 seconds.
|
||||
*/
|
||||
|
||||
String driver = (String) ref.get("driver").getContent();
|
||||
|
||||
if (driver != null) {
|
||||
dataSource.setDriver(driver);
|
||||
}
|
||||
|
||||
String user = (String) ref.get("user").getContent();
|
||||
|
||||
if (user != null) {
|
||||
dataSource.setUser(user);
|
||||
}
|
||||
|
||||
String password = (String) ref.get("password").getContent();
|
||||
|
||||
if (password != null) {
|
||||
dataSource.setPassword(password);
|
||||
}
|
||||
|
||||
String jdbcUrl = (String) ref.get("jdbcUrl").getContent();
|
||||
|
||||
if (jdbcUrl != null) {
|
||||
dataSource.setJdbcUrl(jdbcUrl);
|
||||
}
|
||||
|
||||
String minConns = (String) ref.get("minConns").getContent();
|
||||
|
||||
if (minConns != null) {
|
||||
dataSource.setMinConns(minConns);
|
||||
}
|
||||
|
||||
String maxConns = (String) ref.get("maxConns").getContent();
|
||||
|
||||
if (maxConns != null) {
|
||||
dataSource.setMaxConns(maxConns);
|
||||
}
|
||||
|
||||
String maxConnTime = (String) ref.get("maxConnTime").getContent();
|
||||
|
||||
if (maxConnTime != null) {
|
||||
dataSource.setMaxConnTime(maxConnTime);
|
||||
}
|
||||
|
||||
String maxCheckoutSeconds = (String) ref.get("maxCheckoutSeconds").getContent();
|
||||
|
||||
if (maxCheckoutSeconds != null) {
|
||||
dataSource.setMaxCheckoutSeconds(maxCheckoutSeconds);
|
||||
}
|
||||
|
||||
dataSource.init();
|
||||
|
||||
return dataSource;
|
||||
}
|
||||
}
|
|
@ -1,141 +1,141 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/src/net/java/dev/simplepool/SimplePoolServlet.java,v $
|
||||
* $Revision: 1.1 $
|
||||
* $Date: 2004-03-28 02:04:58 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a pool of database connection based on the specific intialization parameters.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.1 $, $Date: 2004-03-28 02:04:58 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolServlet extends HttpServlet {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SimplePoolServlet.class);
|
||||
private static SimplePoolDataSource dataSource;
|
||||
|
||||
/**
|
||||
* Closes the connection pool.
|
||||
*
|
||||
* @see javax.servlet.http.HttpServlet#destroy
|
||||
*/
|
||||
public void destroy() {
|
||||
if (dataSource != null) {
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the connection pool.
|
||||
* <p/>
|
||||
* The required intialization parameters are:
|
||||
* <p/>
|
||||
* <ul>
|
||||
* <li><code>varName</code> – Name of the variable used to hold a reference to the
|
||||
* {@link SimplePoolDataSource}.</li>
|
||||
* <li><code>driver</code> – JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'</li>
|
||||
* <li><code>jdbcUrl</code> – JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'</li>
|
||||
* <li><code>user</code> – Database login name. e.g. 'Scott'</li>
|
||||
* <li><code>password</code> – Database password. e.g. 'Tiger'</li>
|
||||
* <li><code>minConns</code> – Minimum number of connections to start with.</li>
|
||||
* <li><code>maxConns</code> – Maximum number of connections in dynamic pool.</li>
|
||||
* <li><code>maxConnTime</code> – Time in days between connection resets.</li>
|
||||
* <li><code>maxCheckoutSeconds</code> – Max time a connection can be checked out before being recycled.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see javax.servlet.http.HttpServlet#init(ServletConfig)
|
||||
*/
|
||||
public void init(ServletConfig servletConfig)
|
||||
throws ServletException {
|
||||
log.info("Initializing " + servletConfig.getServletName() + " Servlet");
|
||||
|
||||
String varName = servletConfig.getInitParameter("varName");
|
||||
String driver = servletConfig.getInitParameter("driver");
|
||||
String jdbcUrl = servletConfig.getInitParameter("jdbcUrl");
|
||||
String user = servletConfig.getInitParameter("user");
|
||||
String password = servletConfig.getInitParameter("password");
|
||||
String minConns = servletConfig.getInitParameter("minConns");
|
||||
String maxConns = servletConfig.getInitParameter("maxConns");
|
||||
String maxConnTime = servletConfig.getInitParameter("maxConnTime");
|
||||
String maxCheckoutSeconds = servletConfig.getInitParameter("maxCheckoutSeconds");
|
||||
|
||||
if (isValid(varName) && isValid(driver) && isValid(jdbcUrl) && (user != null) && (password != null)
|
||||
&& isValid(minConns) && isValid(maxConns) && isValid(maxConnTime) && isValid(maxCheckoutSeconds)) {
|
||||
dataSource = new SimplePoolDataSource();
|
||||
|
||||
dataSource.setDriver(driver);
|
||||
dataSource.setJdbcUrl(jdbcUrl);
|
||||
dataSource.setUser(user);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setMinConns(minConns);
|
||||
dataSource.setMaxConns(maxConns);
|
||||
dataSource.setMaxConnTime(maxConnTime);
|
||||
dataSource.setMaxCheckoutSeconds(maxCheckoutSeconds);
|
||||
|
||||
try {
|
||||
dataSource.init();
|
||||
|
||||
servletConfig.getServletContext().setAttribute(varName, dataSource);
|
||||
} catch (Exception e) {
|
||||
log.error("An error occurred while starting the connection pool.", e);
|
||||
throw new ServletException("Error starting the connection pool.");
|
||||
}
|
||||
} else {
|
||||
log.error("One or more intialization parameter is invalid or missing.");
|
||||
throw new ServletException("Invalid or missing initialization parameter.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValid(String s) {
|
||||
if ((s != null) && (s.length() > 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Source: /home/cvsroot/manywhere/simplepool/src/net/java/dev/simplepool/SimplePoolServlet.java,v $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2004/03/17 23:35:36 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a pool of database connection based on the specific intialization parameters.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.5 $, $Date: 2004/03/17 23:35:36 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolServlet extends HttpServlet {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SimplePoolServlet.class);
|
||||
private static SimplePoolDataSource dataSource;
|
||||
|
||||
/**
|
||||
* Closes the connection pool.
|
||||
*
|
||||
* @see javax.servlet.http.HttpServlet#destroy
|
||||
*/
|
||||
public void destroy() {
|
||||
if (dataSource != null) {
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the connection pool.
|
||||
* <p/>
|
||||
* The required intialization parameters are:
|
||||
* <p/>
|
||||
* <ul>
|
||||
* <li><code>varName</code> – Name of the variable used to hold a reference to the
|
||||
* {@link SimplePoolDataSource}.</li>
|
||||
* <li><code>driver</code> – JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'</li>
|
||||
* <li><code>jdbcUrl</code> – JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'</li>
|
||||
* <li><code>user</code> – Database login name. e.g. 'Scott'</li>
|
||||
* <li><code>password</code> – Database password. e.g. 'Tiger'</li>
|
||||
* <li><code>minConns</code> – Minimum number of connections to start with.</li>
|
||||
* <li><code>maxConns</code> – Maximum number of connections in dynamic pool.</li>
|
||||
* <li><code>maxConnTime</code> – Time in days between connection resets.</li>
|
||||
* <li><code>maxCheckoutSeconds</code> – Max time a connection can be checked out before being recycled.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see javax.servlet.http.HttpServlet#init(ServletConfig)
|
||||
*/
|
||||
public void init(ServletConfig servletConfig)
|
||||
throws ServletException {
|
||||
log.info("Initializing " + servletConfig.getServletName() + " Servlet");
|
||||
|
||||
String varName = servletConfig.getInitParameter("varName");
|
||||
String driver = servletConfig.getInitParameter("driver");
|
||||
String jdbcUrl = servletConfig.getInitParameter("jdbcUrl");
|
||||
String user = servletConfig.getInitParameter("user");
|
||||
String password = servletConfig.getInitParameter("password");
|
||||
String minConns = servletConfig.getInitParameter("minConns");
|
||||
String maxConns = servletConfig.getInitParameter("maxConns");
|
||||
String maxConnTime = servletConfig.getInitParameter("maxConnTime");
|
||||
String maxCheckoutSeconds = servletConfig.getInitParameter("maxCheckoutSeconds");
|
||||
|
||||
if (isValid(varName) && isValid(driver) && isValid(jdbcUrl) && (user != null) && (password != null)
|
||||
&& isValid(minConns) && isValid(maxConns) && isValid(maxConnTime) && isValid(maxCheckoutSeconds)) {
|
||||
dataSource = new SimplePoolDataSource();
|
||||
|
||||
dataSource.setDriver(driver);
|
||||
dataSource.setJdbcUrl(jdbcUrl);
|
||||
dataSource.setUser(user);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setMinConns(minConns);
|
||||
dataSource.setMaxConns(maxConns);
|
||||
dataSource.setMaxConnTime(maxConnTime);
|
||||
dataSource.setMaxCheckoutSeconds(maxCheckoutSeconds);
|
||||
|
||||
try {
|
||||
dataSource.init();
|
||||
|
||||
servletConfig.getServletContext().setAttribute(varName, dataSource);
|
||||
} catch (Exception e) {
|
||||
log.error("An error occurred while starting the connection pool.", e);
|
||||
throw new ServletException("Error starting the connection pool.");
|
||||
}
|
||||
} else {
|
||||
log.error("One or more intialization parameter is invalid or missing.");
|
||||
throw new ServletException("Invalid or missing initialization parameter.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValid(String s) {
|
||||
if ((s != null) && (s.length() > 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool API</title>
|
||||
</head>
|
||||
<body>
|
||||
This package contains a simple database connection pool implementation for web applications, specifically those using JSTL.
|
||||
<p/>
|
||||
The connection pool can be created, accessed and managed via JNDI or through the {@link net.java.dev.simplepool.SimplePoolServlet}.
|
||||
|
||||
@since 1.0
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool API</title>
|
||||
</head>
|
||||
<body>
|
||||
This package contains a simple database connection pool implementation for web applications, specifically those using JSTL.
|
||||
<p/>
|
||||
The connection pool can be created, accessed and managed via JNDI or through the {@link net.java.dev.simplepool.SimplePoolServlet}.
|
||||
|
||||
@since 1.0
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Default Project Content</title>
|
||||
</head>
|
||||
<body>
|
||||
This is the default project content.
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue