diff --git a/build.properties b/build.properties index dc31e89..8d51885 100644 --- a/build.properties +++ b/build.properties @@ -1,11 +1,23 @@ -appname=simplepool +# Project +proj.name=simplepool +proj.version=1.0 -path.classes=build +# 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 + + +# 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/ diff --git a/build.xml b/build.xml index 58a2be5..aa8ae40 100644 --- a/build.xml +++ b/build.xml @@ -1,6 +1,8 @@ + + @@ -11,23 +13,33 @@ - + - - + + - + - + + + + + + + + + + + @@ -40,7 +52,7 @@ - + diff --git a/simplepool-examples/WEB-INF/lib/jstl.jar b/simplepool-examples/WEB-INF/lib/jstl.jar new file mode 100644 index 0000000..63e135a Binary files /dev/null and b/simplepool-examples/WEB-INF/lib/jstl.jar differ diff --git a/simplepool-examples/WEB-INF/lib/standard.jar b/simplepool-examples/WEB-INF/lib/standard.jar new file mode 100644 index 0000000..7f662a6 Binary files /dev/null and b/simplepool-examples/WEB-INF/lib/standard.jar differ diff --git a/simplepool-examples/WEB-INF/web.xml b/simplepool-examples/WEB-INF/web.xml new file mode 100644 index 0000000..9d99df2 --- /dev/null +++ b/simplepool-examples/WEB-INF/web.xml @@ -0,0 +1,52 @@ + + + + SimplePool Examples + + + + \ No newline at end of file diff --git a/simplepool-examples/conf/server.xml b/simplepool-examples/conf/server.xml new file mode 100644 index 0000000..d433ec5 --- /dev/null +++ b/simplepool-examples/conf/server.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + factory + net.java.dev.simplepool.SimplePoolDataSourceFactory + + + driver + com.mysql.jdbc.Driver + + + user + dbuser + + + password + dbpassword + + + jdbcUrl + jdbc:mysql://localhost:3306/dbname + + + minConns + 8 + + + maxConns + 30 + + + maxConnTime + 1 + + + maxCheckoutSeconds + 60 + + + + + + + + + \ No newline at end of file diff --git a/simplepool-examples/includes/inst.css b/simplepool-examples/includes/inst.css new file mode 100644 index 0000000..df6d749 --- /dev/null +++ b/simplepool-examples/includes/inst.css @@ -0,0 +1,251 @@ +/* $Id$ + +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. + +*/ + +/* colors, backgrounds, borders, link indication */ +#cn { + background-image: url(../images/corporate_logo.gif); + display: block; + height: 17px; + width: 138px; +} + +#poweredby { + background-image: url(../images/poweredby_036.gif); + display: block; + height: 38px; + width: 102px; +} + +#sc { + background-image: url(../images/product_logo.gif); + display: block; + height: 25px; + width: 138px; +} + +#toptabs td, #toptabs th { + background-image: url(../images/nw_min_036.gif); +} + +.app h3, #banner, #banner td, #toptabs { + background-color: #036; + color: #fff; +} + +body #banner td a, .app h3 a, .app h4 a { + color: #fff !important; +} + +#banner { + border-top: 1px solid #369; +} + +#mytools .label, #projecttools .label, #admintools .label, #communitytools .label { + background-color: #ddd; + border: none; +} + +#mytools .body, #projecttools .body, #admintools .body, #communitytools .body { + background-color: #fff; + border-right: none; + border-bottom: none; + border-top: 1px solid #999; +} + +#mytools, #projecttools, #admintools, #communitytools { + background-color: #ddd; + border-right: 1px solid #666; + border-bottom: 1px solid #666; +} + +#helptext { + background-color: #ffc; +} + +#helptext .label { + border-bottom: 1px solid #996; + border-right: 1px solid #996; + background-color: #cc9; +} + +#helptext .body { + border-bottom: 1px solid #cc9; + border-right: 1px solid #cc9; +} + +#topmodule { + background-color: #ddd; + border-top: 1px solid #fff; + border-bottom: 1px solid #aaa; +} + +#topmodule #issueid { + border-right: 1px solid #aaa; +} + +#login a:link, #login a:visited { + color: white; + text-decoration: underline; +} + +#banner a:active, #banner a:hover { + color: #f90 !important; +} + +#toptabs td { + border-bottom: 1px solid #666; + border-right: 1px solid #333; + border-left: 1px solid #036; +} + +#toptabs th { + border-left: 1px solid #036; +} + +/* font and text properties, exclusive of link indication, alignment, text-indent */ +#bodycol h2 { + font-family: Tahoma, Verdana, Helvetica, Arial, sans-serif; + font-size: 1.5em; + font-weight: normal; +} + +/* box properties (exclusive of borders), positioning, alignments, list types, text-indent */ +#toptabs { + margin: 0; + padding-top: .67em; + padding-left: 8px; +} + +#topmodule { + margin: -4px -4px 0 -4px; +} + +#topmodule td { + vertical-align: middle; + padding: 2px 8px; +} + +#navcolumn { + margin-right: -4px; +} + +#mytools .body, #projecttools .body, #admintools .body, #communitytools .body { + padding-top: .33em; +} + +#mytools, #projecttools, #admintools, #communitytools { + padding: 0 6px 6px 6px; + margin: -4px 0 6px -4px; +} + +#mytools .label, #projecttools .label, #admintools .label, #communitytools .label { + padding-left: 2px; +} + + + +/* java.net dev stylesheet */ + +/* colors, backgrounds, borders, link indication */ +body { + color: #333; + } +.app h3, .app h4, .functnbar { + background-image: none; + background-repeat: no-repeat; + } +#toptabs td, #toptabs th { + background-image: url(../images/nw_min.gif); + } + + +#navcolumn .body div, body.docs #toc li li { + background-image: url(../images/strich.gif); + background-repeat: no-repeat; + background-position: .5em .5em; + } + +#banner, #banner td, #toptabs { + background-color: #fff; + color: #333; + } +.app h3 { + background-color: #594FBF; + color: #fff; + } +#toptabs th { + border-left: 1px solid #fff; + } +#toptabs td { + border-right: 1px solid #333; + border-left: 1px solid #fff; + } +#login, #banner { + color: #333; + } +a:link, a:visited, #navcolumn a:visited, #navcolumn a:link,.app a:visited, .tasknav a:visited { + color: #594FBF; +} +#mytools a:link, #banner a:link, #banner a:visited { + border-bottom: none; + } +a:link.selfref, a:visited.selfref { + color: #555 !important; + text-decoration: none; + } +#banner a:active, #banner a:hover { + color: #f60 !important; + } +#login a:link, #login a:visited, #banner a:link, #banner a:visited { + color: #594FBF !important; + font-weight: bold; + } +#bannerbottom1 td, #bannerbottom2 td { + background: #EFEFEF; + } +#bannerbottom1 th { + background: #2E1772; + } +#bannerbottom2 th { + background: #594FBF; + } + + +.grid td { border-top: 1px solid #ccc; border-left: 1px solid #ccc; } +.grid { border-bottom: 1px solid #ccc; border-right: 1px solid #ccc; } + + + +/* font and text properties, exclusive of link indication, alignment, text-indent */ + +#banner { + font-size: xx-small; + voice-family: "\"}\""; + voice-family: inherit; + font-size: x-small + } + +/* box properties (exclusive of borders), positioning, alignments, list types, text-indent */ + +.app h3, .app h4 { + padding: 3px; + margin-right: 2px; + margin-left: 2px; + } +#rightcol div.www, #rightcol div.help { + border: none; + } +#rightcol div.www h3 { + background-color: #ddd; + color: #000; + } +#rightcol div.www h3 { + padding: 3px; + } +#bannerbottom1 th, #bannerbottom2 th { + text-align: left; + vertical-align: bottom; + } diff --git a/simplepool-examples/includes/tigris.css b/simplepool-examples/includes/tigris.css new file mode 100644 index 0000000..85892d0 --- /dev/null +++ b/simplepool-examples/includes/tigris.css @@ -0,0 +1,785 @@ +/* $Id$ + + 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. */ + +/* colors, backgrounds, borders, link indication */ +body { + background: #fff; + color: #000; +} + +.app h3, .app h4, .tabs td, .tabs th, .functnbar { + background-image: url(../images/nw_maj_rond.gif); + background-repeat: no-repeat; +} + +.functnbar, .functnbar2 { + background-color: #aaa; +} + +.functnbar2, .functnbar3 { + background-color: #aaa; + background-image: url(../images/sw_maj_rond.gif); + background-repeat: no-repeat; + background-position: bottom left; +} + +.functnbar3 { + background-color: #ddd; + background-image: url(../images/sw_med_rond.gif); +} + +.functnbar, .functnbar2, .functnbar3 { + color: #000; +} + +.functnbar a, .functnbar2 a, .functnbar3 a { + color: #000; + text-decoration: underline; +} + +#navcolumn .body div, body.docs #toc li li { + background-image: url(../images/strich.gif); + background-repeat: no-repeat; + background-position: .5em .5em; +} + +#searchbox .body div, #navcolumn .body .heading { + background-image: none; +} + +a:link, #navcolumn a:visited, .app a:visited, .tasknav a:visited { + color: blue; +} + +a:link.selfref, a:visited.selfref { + color: #555 !important; + text-decoration: none; +} + +a:active, a:hover, #leftcol a:active, #leftcol a:hover { + color: #f30 !important; +} + +#leftcol a, #breadcrumbs a { + text-decoration: none; +} + +.app h3, .app h4 { + color: #fff; +} + +.app h3 { + background-color: #333; +} + +.app h3 a:link, .app h3 a:visited, .app h4 a:link, .app h4 a:visited { + color: #fff !important; + text-decoration: underline; +} + +.app h4 { + background-color: #888; +} + +.a td { + background: #ddd; +} + +.b td { + background: #efefef; +} + +table, th, td { + border: none; +} + +div.colbar { + background: #eee; + border-color: #999 #EEE #EEE #999; + border-width: 1px; + border-style: solid; +} + +.toolgroup { + background: #efefef; +} + +.toolgroup .label { + border-bottom: 1px solid #666; + border-right: 1px solid #666; + background: #ddd; + color: #555; +} + +.toolgroup .body { + border-right: 1px solid #aaa; + border-bottom: 1px solid #aaa; +} + +#breadcrumbs { + border-top: 1px solid #fff; + background-color: #ccc; +} + +#main { + border-top: 1px solid #999; +} + +#rightcol div.www, #rightcol div.help { + border: 1px solid #ddd; +} + +body.docs div.docs { + background-color: #fff; + border-left: 1px solid #ddd; + border-top: 1px solid #ddd; +} + +#helptext .label { + background-image: url(../images/icon_help_sml.gif); + background-repeat: no-repeat; + background-position: 97%; +} + +body.docs { + background: #eee url(../images/help_logo.gif) top right no-repeat !important; +} + +.docs h3, .docs h4 { + border-top: solid 1px #000; +} + +#apphead h2 em { + color: #777; +} + +.app th { + background-color: #bbb; +} + +.tabs th { + border-right: 1px solid #333; + background-color: #ddd; + color: #fff; + border-left: 1px solid #fff; +} + +.tabs td { + background-color: #999; + border-bottom: 1px solid #fff; + border-right: 1px solid #fff; + border-left: 1px solid #fff; +} + +.tabs { + border-bottom: 6px #ddd solid; +} + +.tabs th, .tabs th a:link, .tabs th a:visited { + color: #555; +} + +.tabs td, .tabs td a:link, .tabs td a:visited { + color: #fff; +} + +.tabs a { + text-decoration: none; +} + +.axial th { + background-color: #ddd; + color: black; +} + +.alert { + background-color: #ff9; +} + +.expandedwaste { + background: url(../images/icon_arrowwaste2_sml.gif) no-repeat; +} + +.collapsedwaste { + background: url(../images/icon_arrowwaste1_sml.gif) no-repeat; +} + +.filebrowse .expanded, .filebrowse-alt .expanded { + background-image: url(../images/icon_arrowfolderopen2_sml.gif); + background-repeat: no-repeat; +} + +.filebrowse .collapsed, .filebrowse-alt .collapsed { + background-image: url(../images/icon_arrowfolderclosed1_sml.gif); + background-repeat: no-repeat; +} + +.filebrowse .leafnode, .filebrowse-alt .leafnode { + background-image: url(../images/icon_folder_sml.gif); + background-repeat: no-repeat; +} + +.filebrowse .leaf, .filebrowse-alt .leaf { + background-image: url(../images/icon_doc_sml.gif); + background-repeat: no-repeat; +} + +.sortup { + background: url(../images/icon_sortup.gif) no-repeat; +} + +.sortdown { + background: url(../images/icon_sortdown.gif) no-repeat; +} + +.collapsedwaste { + background: url(../images/icon_arrowwaste1_sml.gif) no-repeat; +} + +body .grid td { + border-top: 1px solid #ccc; + border-left: 1px solid #ccc; + background-color: transparent; +} + +.confirm { + color: #090; +} + +.info { + color: #069; +} + +.errormessage, .warningmessage, .donemessage, .infomessage { + border-top: 5px solid #900; + border-left: 1px solid #900; + background-image: url(../images/icon_error_lrg.gif); + background-repeat: no-repeat; + background-position: 5px 1.33em; +} + +.warningmessage { + background-image: url(../images/icon_warning_lrg.gif); + border-color: #c60; +} + +.donemessage { + background-image: url(../images/icon_success_lrg.gif); + border-color: #090; +} + +.infomessage { + background-image: url(../images/icon_info_lrg.gif); + border-color: #069; +} + +.docinfo { + background: url(../images/icon_doc_lrg.gif) no-repeat; +} + +.dirinfo { + background: url(../images/icon_folder_lrg.gif) no-repeat; +} + +.memberinfo { + background: url(../images/icon_members_lrg.gif) no-repeat; +} + +.usergroupinfo { + background: url(../images/icon_usergroups_lrg.gif) no-repeat; +} + +.errormark, .warningmark, .donemark, .infomark { + background: url(../images/icon_error_sml.gif) no-repeat; +} + +.warningmark { + background-image: url(../images/icon_warning_sml.gif); +} + +.donemark { + background-image: url(../images/icon_success_sml.gif); +} + +.infomark { + background-image: url(../images/icon_info_sml.gif); +} + +.cvsdiff, .cvsblame { + background-color: #ccc; +} + +.cvsdiffadd { + background-color: #afa; +} + +.cvsdiffremove { + background-color: #faa; +} + +.cvsdiffchanges1 { + background-color: #ff7; +} + +.cvsdiffchanges2 { + background-color: #ff7; +} + +li.selection ul a { + background: #fff; +} + +.band1 { + color: #fff; + background-color: #663; +} + +.band2 { + color: #fff; + background-color: #66C; +} + +.band3 { + background-color: #C99; +} + +.band4 { + background-color: #CFF; +} + +.band5 { + color: #fff; + background-color: #336; +} + +.band6 { + color: #fff; + background-color: #966; +} + +.band7 { + background-color: #9CC; +} + +.band8 { + background-color: #FFC; +} + +.band9 { + color: #fff; + background-color: #633; +} + +.band10 { + color: #fff; + background-color: #699; +} + +.band11 { + background-color: #CC9; +} + +.band12 { + background-color: #CCF; +} + +.band13 { + color: #fff; + background-color: #366; +} + +.band14 { + color: #fff; + background-color: #996; +} + +.band15 { + background-color: #99C; +} + +.band16 { + background-color: #FCC; +} + +.app .helplink, #helptext .helplink { + cursor: help; +} + +.legend th, .bars th { + background-color: #fff; +} + +/* font and text properties, exclusive of link indication, alignment, text-indent */ +body, th, td, input, select { + font-family: Verdana, Helvetica, Arial, sans-serif; +} + +code, pre { + font-family: 'Andale Mono', Courier, monospace; +} + +body, .app h3, .app h4, #rightcol h3, pre, code, #apphead h2 small, h4, table { + font-size: x-small; + voice-family: "\"}\""; + voice-family: inherit; + font-size: small; +} + +small, div#footer, div#footer table, div#login, div.tabs th, div.tabs td, input, select, .paginate, .functnbar, .functnbar2, .functnbar3, #breadcrumbs, .courtesylinks, #rightcol div.help, .colbar, .tasknav, body.docs div#toc, #leftcol, .legend, .bars { + font-size: xx-small; + voice-family: "\"}\""; + voice-family: inherit; + font-size: x-small; +} + +.tabs td, .tabs th, dt, .tasknav .selfref, #login .username, .selection { + font-weight: bold; +} + +li.selection ul { + font-weight: normal; +} + +#apphead h2 em { + font-style: normal; +} + +#banner h1 { + font-size: 1.25em; +} + +/* box properties (exclusive of borders), positioning, alignments, list types, text-indent */ +#bodycol h2 { + margin-top: .3em; + margin-bottom: .5em; +} + +p, ul, ol, dl, .bars table { + margin-top: .67em; + margin-bottom: .67em; +} + +h3, h4 { + margin-bottom: 0; +} + +form { + margin: 0; +} + +#bodycol { + padding-left: 12px; + padding-right: 12px; + width: 100%; + voice-family: "\"}\""; + voice-family: inherit; + width: auto; +} + +html>body #bodycol { + width: auto; +} + +.docs { + line-height: 1.4; +} + +ol ol { + list-style-type: lower-alpha; +} + +ol ol ol { + list-style-type: lower-roman; +} + +.app h3, .app h4 { + padding: 5px; + margin-right: 2px; + margin-left: 2px; +} + +.app td, .app th { + padding: 2px 3px; +} + +.h3 p, .h4 p, .h3 dt, .h4 dt { + margin-right: 7px; + margin-left: 7px; +} + +.tasknav { + margin-bottom: 1.33em; +} + +div.colbar { + padding: 3px; + margin: 2px 2px 0; +} + +.tabs { + margin-top: .67em; + margin-right: 2px; + margin-left: 2px; + padding-left: 8px; +} + +.tabs td, .tabs th { + padding: 3px 9px; +} + +#rightcol div.www, #rightcol div.help { + padding: 0 .5em; +} + +body.docs #toc { + position: absolute; + top: 15px; + left: 0px; + width: 120px; + padding: 0 20px 0 0; +} + +body.docs #toc ul, #toc ol { + margin-left: 0; + padding-left: 0; +} + +body.docs #toc li { + margin-top: 7px; + padding-left: 10px; + list-style-type: none; +} + +body.docs div.docs { + margin: 61px 0 0 150px; + padding: 1em 2em 1em 1em !important; +} + +.docs p+p { + text-indent: 5%; + margin-top: -.67em; +} + +.docs h3, .docs h4 { + margin-bottom: .1em; + padding-top: .3em; +} + +.functnbar, .functnbar2, .functnbar3 { + padding: 5px; + margin: .67em 2px; +} + +.functnbar3 { + margin-top: 0; +} + +body { + padding: 1em; +} + +body.composite, body.docs { + margin: 0; + padding: 0; +} + +th, td { + text-align: left; + vertical-align: top; +} + +.bars th { + vertical-align: middle; +} + +.right { + text-align: right !important; +} + +.center { + text-align: center !important; +} + +.axial th, .axial th .strut { + text-align: right; +} + +.app .axial td th { + text-align: left; +} + +body .stb { + margin-top: 1em; + text-indent: 0; +} + +body .mtb { + margin-top: 2em; + text-indent: 0; +} + +.courtesylinks { + margin-top: 1em; + padding-top: 1em; +} + +dd { + margin-bottom: .67em; +} + +.toolgroup { + margin-bottom: 6px; +} + +.toolgroup .body { + padding: 4px 4px 4px 0; +} + +.toolgroup .label { + padding: 4px; +} + +.toolgroup .body div { + padding-bottom: .3em; + padding-left: 1em; +} + +.toolgroup .body div div { + margin-top: .3em; + padding-bottom: 0; +} + +.tier1 { + margin-left: 0; +} + +.tier2 { + margin-left: 1.5em; +} + +.tier3 { + margin-left: 3em; +} + +.tier4 { + margin-left: 4.5em; +} + +.tier5 { + margin-left: 6em; +} + +.tier6 { + margin-left: 7.5em; +} + +.tier7 { + margin-left: 9em; +} + +.tier8 { + margin-left: 10.5em; +} + +.tier9 { + margin-left: 12em; +} + +.tier10 { + margin-left: 13.5em; +} + +.filebrowse .expanded, .filebrowse .collapsed { + padding-left: 34px; +} + +.filebrowse .leafnode, .filebrowse .leaf { + padding-left: 20px; +} + +.messagechild { + padding-left: 34px; +} + +.filebrowse-alt .expanded, .filebrowse-alt .collapsed, .filebrowse-alt .leaf, .filebrowse-alt .leafnode, .expandedwaste, .collapsedwaste, .sortup, .sortdown { + /* hide from macie5\*/ + float: left; + /* resume */ + display: inline-block; + height: 15px; + width: 34px; + padding-left: 0 !important; +} + +.filebrowse-alt .leaf, .filebrowse-alt .leafnode, .sortup, .sortdown { + width: 20px; +} + +.filebrowse ul, .filebrowse-alt ul { + list-style-type: none; + padding-left: 0; + margin-left: 0; +} + +.filebrowse ul ul, .filebrowse-alt ul ul { + margin-left: 1.5em; + margin-top: 0; + padding-top: .67em; +} + +.filebrowse li, .filebrowse-alt li { + margin-bottom: .67em; +} + +td.filebrowse h3 { + margin-top: 0; +} + +.errormessage, .warningmessage, .donemessage, .infomessage, .docinfo, .dirinfo, .memberinfo, .usergroupinfo { + margin: .67em 0; + padding: .33em 0 .67em 42px; + min-height: 32px; +} + +.errormark, .warningmark, .donemark, .infomark { + padding-left: 20px; + min-height: 15px; +} + +.alt { + display: none; +} + +#banner h1 { + margin: 0; +} + +#leftcol, #leftcol .strut { + width: 14em; +} + +.axial th, .axial th .strut { + width: 12em; +} + +#breadcrumbs { + padding: 2px 8px; +} + +.app h3, .app h4 { + clear: both; +} + +.legend { + float: right; +} + +.legend th, .bars th { + text-align: right; + padding-left: 1em; +} + +#projectdocumentlist td.filebrowse-alt { + padding-right: .75em; +} diff --git a/simplepool-examples/index.html b/simplepool-examples/index.html new file mode 100644 index 0000000..2719bc3 --- /dev/null +++ b/simplepool-examples/index.html @@ -0,0 +1,54 @@ + + + + +simplepool: Examples + + + + + + + + +
+
+
+

simplepool
+ Examples

+
+

Project Home

+
+
+ + + + + + + + + + + + + +
SummaryA simple database connection pool for webapps using JSTL.
Example 1JNDI DataSource Examples
Example 2Servlet DataSource Examples
+
+
+

Description

+

SimplePool is a simple database connection pool implementation for web applications, specifically those using JSTL.

+

The connection pool can be created, accessed and managed via JNDI or a provided Servlet.

+

The examples above have been tailored for use with Tomcat and MySQL.

+
+
+
+
+ + diff --git a/simplepool-examples/jndi/index.jsp b/simplepool-examples/jndi/index.jsp new file mode 100644 index 0000000..4ef704f --- /dev/null +++ b/simplepool-examples/jndi/index.jsp @@ -0,0 +1,78 @@ + +<%@page import="javax.naming.*" %> + + + +simplepool: JNDI DataSource Examples + + + + + + + + + +
+
+
+

simplepool
+ JNDI DataSource Examples

+
+

Examples Home

+

Please read the instructions before trying to run the examples.

+
+
+ + + + + + + + + + + + + +
SummaryA simple database connection pool example using JDNI.
Example 1Scriptlet Example [source]
Example 2JSTL Example [source]
+
+
+

Instructions

+

JNDI is used to create, access and manage the connection pool.

+

First, make sure that your JDBC driver is available, by placing its components in this webapp's WEB-INF/lib/ directory.

+

The JNDI DataSource is defined as naming resource in the current webapp context, as shown in this minimal server configuration file.

+

The JNDI DataSource is configured using the following parameters:

+
    +
  • The varName parameter is used to specify the name of the variable which will hold a reference to the DataSource object created by the Servlet.
  • +
  • The driver parameter is used to specify the name of the JDBC driver class to be registered. For example: com.mysql.jdbc.Driver.
  • +
  • The user parameter is used to specify the database username, if any.
  • +
  • The password parameter is used to specify the database password, if any.
  • +
  • The jdbcUrl parameter is used to specify the JDBC URL associated with the database. For example: jdbc:mysql://localhost:3306/dbname.
  • +
  • The minConns parameter is used to specify the minimum number of connections to start the pool with.
  • +
  • The maxConns parameter is used to specify the maximum number of connections to be dynamically created in the pool.
  • +
  • The maxConnTime parameter is used to specify the time (in days) between connection resets. The pool manager will perform a basic cleanup at the specified interval.
  • +
  • The maxCheckoutSeconds parameter is used to specify the maximum time a connection can be checked out before being recycled. A zero value turns this option off.
  • +
+

Please note that all parameters are required.

+

Please take a minute to incorporate the JDNI DataSource example in your $CATALINE_HOME/conf/server.xml. Once done, please restart Tomcat. The examples will be functional upon restart.

+

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.

+
+
+
+
+ + diff --git a/simplepool-examples/jndi/jstl.jsp b/simplepool-examples/jndi/jstl.jsp new file mode 100644 index 0000000..7d1eead --- /dev/null +++ b/simplepool-examples/jndi/jstl.jsp @@ -0,0 +1,27 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> +<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %> + + + SimplePool JNDI/JSTL Example + + + + <%-- Execute the query using our JNDI DataSource --%> + + SHOW TABLES + + +

Tables

+
    + + <%-- + Loop through the result set and + display the current column value + --%> + +
  • +
    + +
      + + diff --git a/simplepool-examples/jndi/scriptlet.jsp b/simplepool-examples/jndi/scriptlet.jsp new file mode 100644 index 0000000..928bc4d --- /dev/null +++ b/simplepool-examples/jndi/scriptlet.jsp @@ -0,0 +1,45 @@ +<%@page import="javax.naming.*, javax.sql.*, java.sql.*;" %> + + + SimplePool JNDI Example + + + + <% + // 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"); + %> + +

      Tables

      +
        + <% + // Loop through the result set and + // display the current column value + while (rst.next()) { + %> +
      • <%= rst.getString(1) %>
      • + <% + } + %> +
          + + <% + // Close the result set, statement and connection + rst.close(); + stmt.close(); + conn.close(); + %> + + diff --git a/simplepool-examples/licenses/JSTL License.txt b/simplepool-examples/licenses/JSTL License.txt new file mode 100644 index 0000000..c62d44b --- /dev/null +++ b/simplepool-examples/licenses/JSTL License.txt @@ -0,0 +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 ." * + * * + * 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 . * + * * + * 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 . * + * * + * ========================================================================= */ diff --git a/simplepool-examples/licenses/SimplePool License.txt b/simplepool-examples/licenses/SimplePool License.txt new file mode 100644 index 0000000..f4a44ec --- /dev/null +++ b/simplepool-examples/licenses/SimplePool License.txt @@ -0,0 +1,38 @@ +/* + * $Source$ + * $Revision$ + * $Date$ + * + * 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. + */ \ No newline at end of file diff --git a/simplepool-examples/servlet/index.jsp b/simplepool-examples/servlet/index.jsp new file mode 100644 index 0000000..4ddbb09 --- /dev/null +++ b/simplepool-examples/servlet/index.jsp @@ -0,0 +1,77 @@ + +<%@page import="javax.naming.*" %> + + + +simplepool: Servlet DataSource Examples + + + + + + + + + +
          +
          +
          +

          simplepool
          + Servlet DataSource Examples

          +
          +

          Examples Home

          +

          Please read the instructions before trying to run the examples.

          +
          +
          + + + + + + + + + + + + + +
          SummaryA simple database connection pool example using the SimplePool Servlet.
          Example 1Scriptlet Example [source]
          Example 2JSTL Example [source]
          +
          +
          +

          Instructions

          +

          The SimplePoolServlet is used to create, access and manage the connection pool.

          +

          First, make sure that your JDBC driver is available, by placing its components in this webapp's WEB-INF/lib/ directory.

          +

          The SimplePoolServlet is configured using a set of required initialization parameters, as show in this webapp's WEB-INF/web.xml under the <servlet/> section:

          +
            +
          • The varName initialization parameter is used to specify the name of the variable which will hold a reference to the DataSource object created by the Servlet.
          • +
          • The driver initialization parameter is used to specify the name of the JDBC driver class to be registered. For example: com.mysql.jdbc.Driver.
          • +
          • The user initialization parameter is used to specify the database username, if any.
          • +
          • The password initialization parameter is used to specify the database password, if any.
          • +
          • The jdbcUrl initialization parameter is used to specify the JDBC URL associated with the database. For example: jdbc:mysql://localhost:3306/dbname.
          • +
          • The minConns initialization parameter is used to specify the minimum number of connections to start the pool with.
          • +
          • The maxConns initialization parameter is used to specify the maximum number of connections to be dynamically created in the pool.
          • +
          • The maxConnTime 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.
          • +
          • The maxCheckoutSeconds 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.
          • +
          +

          Please note that all parameters are required.

          +

          Please take a minute to uncomment the <servlet/> declaration and configure the Servlet's initialization parameters in this webapp's WEB-INF/web.xml. Once done, please restart the webapp and/or Tomcat. The examples will be functional upon restart.

          +

          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.

          +
          +
          +
          +
          + + diff --git a/simplepool-examples/servlet/jstl.jsp b/simplepool-examples/servlet/jstl.jsp new file mode 100644 index 0000000..a895343 --- /dev/null +++ b/simplepool-examples/servlet/jstl.jsp @@ -0,0 +1,27 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> +<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %> + + + SimplePool Servlet/JSTL Example + + + + <%-- Execute the query using our DataSource --%> + + SHOW TABLES + + +

          Tables

          +
            + + <%-- + Loop through the result set and + display the current column value + --%> + +
          • +
            + +
              + + \ No newline at end of file diff --git a/simplepool-examples/servlet/scriptlet.jsp b/simplepool-examples/servlet/scriptlet.jsp new file mode 100644 index 0000000..fa83103 --- /dev/null +++ b/simplepool-examples/servlet/scriptlet.jsp @@ -0,0 +1,44 @@ +<%@page import="javax.naming.*, javax.sql.*, java.sql.*;" %> + + + SimplePool Servlet Example + + + + <% + // 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"); + %> + +

              Tables

              +
                + <% + // Loop through the result set and + // display the current column value + while (rst.next()) { + %> +
              • <%= rst.getString(1) %>
              • + <% + } + %> +
                  + + <% + // Close the result set, statement and connection + // and display the current column value + rst.close(); + stmt.close(); + conn.close(); + %> + + + diff --git a/simplepool-examples/source.jsp b/simplepool-examples/source.jsp new file mode 100644 index 0000000..7c080eb --- /dev/null +++ b/simplepool-examples/source.jsp @@ -0,0 +1,25 @@ +<%@page import="java.io.*"%> + + +
                  +<%
                  +	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);
                  +				}
                  +			}
                  +		}       
                  +	}
                  +%>
                  +
                  + +