blob: 70038d28b3e1789b819f0d1c27cf734873422665 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_191) on Sat Feb 27 13:52:04 CET 2021 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DataSourceResourceLoader (Apache Velocity 2.3 API)</title>
<meta name="date" content="2021-02-27">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="DataSourceResourceLoader (Apache Velocity 2.3 API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/DataSourceResourceLoader.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../../org/apache/velocity/runtime/resource/loader/FileResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html" target="_top">Frames</a></li>
<li><a href="DataSourceResourceLoader.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#fields.inherited.from.class.org.apache.velocity.runtime.resource.loader.ResourceLoader">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.velocity.runtime.resource.loader</div>
<h2 title="Class DataSourceResourceLoader" class="title">Class DataSourceResourceLoader</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader">org.apache.velocity.runtime.resource.loader.ResourceLoader</a></li>
<li>
<ul class="inheritance">
<li>org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="typeNameLabel">DataSourceResourceLoader</span>
extends <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader">ResourceLoader</a></pre>
<div class="block"><p>This is a simple template file loader that loads templates
from a DataSource instead of plain files.</p>
<p>It can be configured with a datasource name, a table name,
id column (name), content column (the template body) and a
datetime column (for last modification info).</p>
<br>
<p>Example configuration snippet for velocity.properties:</p>
<br>
<pre><code>
resource.loaders = file, ds
resource.loader.ds.description = Velocity DataSource Resource Loader <br>
resource.loader.ds.class = org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader <br>
resource.loader.ds.resource.datasource_url = java:comp/env/jdbc/Velocity <br>
resource.loader.ds.resource.table = tb_velocity_template <br>
resource.loader.ds.resource.key_column = id_template <br>
resource.loader.ds.resource.template_column = template_definition <br>
resource.loader.ds.resource.timestamp_column = template_timestamp <br>
resource.loader.ds.cache = false <br>
resource.loader.ds.modification_check_interval = 60 <br>
</code></pre>
<p>Optionally, the developer can instantiate the DataSourceResourceLoader and set the DataSource via code in
a manner similar to the following:</p>
<br>
<pre><code>
DataSourceResourceLoader ds = new DataSourceResourceLoader();
ds.setDataSource(DATASOURCE);
Velocity.setProperty("resource.loader.ds.instance",ds);
</code></pre>
<p> The property <code>resource.loader.ds.class</code> should be left out, otherwise all the other
properties in velocity.properties would remain the same.</p>
<br>
<p>Example WEB-INF/web.xml:</p>
<br>
<pre><code>
&lt;resource-ref&gt;
&lt;description&gt;Velocity template DataSource&lt;/description&gt;
&lt;res-ref-name&gt;jdbc/Velocity&lt;/res-ref-name&gt;
&lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
&lt;res-auth&gt;Container&lt;/res-auth&gt;
&lt;/resource-ref&gt;
</code></pre>
<br>
and Tomcat 4 server.xml file: <br>
<pre><code>
[...]
&lt;Context path="/exampleVelocity" docBase="exampleVelocity" debug="0"&gt;
[...]
&lt;ResourceParams name="jdbc/Velocity"&gt;
&lt;parameter&gt;
&lt;name&gt;driverClassName&lt;/name&gt;
&lt;value&gt;org.hsql.jdbcDriver&lt;/value&gt;
&lt;/parameter&gt;
&lt;parameter&gt;
&lt;name&gt;driverName&lt;/name&gt;
&lt;value&gt;jdbc:HypersonicSQL:database&lt;/value&gt;
&lt;/parameter&gt;
&lt;parameter&gt;
&lt;name&gt;user&lt;/name&gt;
&lt;value&gt;database_username&lt;/value&gt;
&lt;/parameter&gt;
&lt;parameter&gt;
&lt;name&gt;password&lt;/name&gt;
&lt;value&gt;database_password&lt;/value&gt;
&lt;/parameter&gt;
&lt;/ResourceParams&gt;
[...]
&lt;/Context&gt;
[...]
</code></pre>
<br>
<p>Example sql script:</p>
<pre><code>
CREATE TABLE tb_velocity_template (
id_template varchar (40) NOT NULL ,
template_definition text (16) NOT NULL ,
template_timestamp datetime NOT NULL
);
</code></pre></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.5</dd>
<dt><span class="simpleTagLabel">Version:</span></dt>
<dd>$Id$</dd>
<dt><span class="simpleTagLabel">Author:</span></dt>
<dd><a href="mailto:wglass@forio.com">Will Glass-Husain</a>, <a href="mailto:matt@raibledesigns.com">Matt Raible</a>, <a href="mailto:david.kinnvall@alertir.com">David Kinnvall</a>, <a href="mailto:paulo.gaspar@krankikom.de">Paulo Gaspar</a>, <a href="mailto:lachiewicz@plusnet.pl">Sylwester Lachiewicz</a>, <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<ul class="blockList">
<li class="blockList"><a name="fields.inherited.from.class.org.apache.velocity.runtime.resource.loader.ResourceLoader">
<!-- -->
</a>
<h3>Fields inherited from class&nbsp;org.apache.velocity.runtime.resource.loader.<a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader">ResourceLoader</a></h3>
<code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#className">className</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#isCachingOn">isCachingOn</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#log">log</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#modificationCheckInterval">modificationCheckInterval</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#rsvc">rsvc</a></code></li>
</ul>
</li>
</ul>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html#DataSourceResourceLoader--">DataSourceResourceLoader</a></span>()</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>protected <a href="https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html?is-external=true" title="class or interface in java.sql">ResultSet</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html#fetchResult-java.sql.PreparedStatement-java.lang.String-">fetchResult</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html?is-external=true" title="class or interface in java.sql">PreparedStatement</a>&nbsp;ps,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;templateName)</code>
<div class="block">Fetches the result for a given template name.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>protected void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html#finalize--">finalize</a></span>()</code>
<div class="block">Close DB connection on finalization</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html#getLastModified-org.apache.velocity.runtime.resource.Resource-">getLastModified</a></span>(<a href="../../../../../../org/apache/velocity/runtime/resource/Resource.html" title="class in org.apache.velocity.runtime.resource">Resource</a>&nbsp;resource)</code>
<div class="block">Get the last modified time of the InputStream source
that was used to create the template.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>protected <a href="https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html?is-external=true" title="class or interface in java.io">Reader</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html#getReader-java.sql.ResultSet-java.lang.String-java.lang.String-">getReader</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html?is-external=true" title="class or interface in java.sql">ResultSet</a>&nbsp;resultSet,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;column,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;encoding)</code>
<div class="block">Gets a reader from a result set's column</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html?is-external=true" title="class or interface in java.io">Reader</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html#getResourceReader-java.lang.String-java.lang.String-">getResourceReader</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;encoding)</code>
<div class="block">Get an InputStream so that the Runtime can build a
template with it.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html#init-org.apache.velocity.util.ExtProperties-">init</a></span>(<a href="../../../../../../org/apache/velocity/util/ExtProperties.html" title="class in org.apache.velocity.util">ExtProperties</a>&nbsp;configuration)</code>
<div class="block">Initialize the template loader with a
a resources class.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html#isSourceModified-org.apache.velocity.runtime.resource.Resource-">isSourceModified</a></span>(<a href="../../../../../../org/apache/velocity/runtime/resource/Resource.html" title="class in org.apache.velocity.runtime.resource">Resource</a>&nbsp;resource)</code>
<div class="block">Given a template, check to see if the source of InputStream
has been modified.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>protected <a href="https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html?is-external=true" title="class or interface in java.sql">PreparedStatement</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html#prepareStatement-java.sql.Connection-java.lang.String-java.lang.String-java.lang.String-">prepareStatement</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html?is-external=true" title="class or interface in java.sql">Connection</a>&nbsp;conn,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;columnNames,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;tableName,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;keyColumn)</code>
<div class="block">Creates the following PreparedStatement query :
<br>
SELECT <i>columnNames</i> FROM <i>tableName</i> WHERE <i>keyColumn</i>
= '<i>templateName</i>'
<br>
where <i>keyColumn</i> is a class member set in init()</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html#setDataSource-javax.sql.DataSource-">setDataSource</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/javax/sql/DataSource.html?is-external=true" title="class or interface in javax.sql">DataSource</a>&nbsp;dataSource)</code>
<div class="block">Set the DataSource used by this resource loader.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.org.apache.velocity.runtime.resource.loader.ResourceLoader">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;org.apache.velocity.runtime.resource.loader.<a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader">ResourceLoader</a></h3>
<code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#buildReader-java.io.InputStream-java.lang.String-">buildReader</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#commonInit-org.apache.velocity.runtime.RuntimeServices-org.apache.velocity.util.ExtProperties-">commonInit</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#getClassName--">getClassName</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#getModificationCheckInterval--">getModificationCheckInterval</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#isCachingOn--">isCachingOn</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#resourceExists-java.lang.String-">resourceExists</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#setCachingOn-boolean-">setCachingOn</a>, <a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#setModificationCheckInterval-long-">setModificationCheckInterval</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="DataSourceResourceLoader--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>DataSourceResourceLoader</h4>
<pre>public&nbsp;DataSourceResourceLoader()</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="init-org.apache.velocity.util.ExtProperties-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>init</h4>
<pre>public&nbsp;void&nbsp;init(<a href="../../../../../../org/apache/velocity/util/ExtProperties.html" title="class in org.apache.velocity.util">ExtProperties</a>&nbsp;configuration)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from class:&nbsp;<code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#init-org.apache.velocity.util.ExtProperties-">ResourceLoader</a></code></span></div>
<div class="block">Initialize the template loader with a
a resources class.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#init-org.apache.velocity.util.ExtProperties-">init</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader">ResourceLoader</a></code></dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#init-org.apache.velocity.util.ExtProperties-"><code>ResourceLoader.init(org.apache.velocity.util.ExtProperties)</code></a></dd>
</dl>
</li>
</ul>
<a name="setDataSource-javax.sql.DataSource-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setDataSource</h4>
<pre>public&nbsp;void&nbsp;setDataSource(<a href="https://docs.oracle.com/javase/8/docs/api/javax/sql/DataSource.html?is-external=true" title="class or interface in javax.sql">DataSource</a>&nbsp;dataSource)</pre>
<div class="block">Set the DataSource used by this resource loader. Call this as an alternative to
specifying the data source name via properties.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>dataSource</code> - The data source for this ResourceLoader.</dd>
</dl>
</li>
</ul>
<a name="isSourceModified-org.apache.velocity.runtime.resource.Resource-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isSourceModified</h4>
<pre>public&nbsp;boolean&nbsp;isSourceModified(<a href="../../../../../../org/apache/velocity/runtime/resource/Resource.html" title="class in org.apache.velocity.runtime.resource">Resource</a>&nbsp;resource)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from class:&nbsp;<code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#isSourceModified-org.apache.velocity.runtime.resource.Resource-">ResourceLoader</a></code></span></div>
<div class="block">Given a template, check to see if the source of InputStream
has been modified.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#isSourceModified-org.apache.velocity.runtime.resource.Resource-">isSourceModified</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader">ResourceLoader</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>True if the resource has been modified.</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#isSourceModified-org.apache.velocity.runtime.resource.Resource-"><code>ResourceLoader.isSourceModified(org.apache.velocity.runtime.resource.Resource)</code></a></dd>
</dl>
</li>
</ul>
<a name="getLastModified-org.apache.velocity.runtime.resource.Resource-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getLastModified</h4>
<pre>public&nbsp;long&nbsp;getLastModified(<a href="../../../../../../org/apache/velocity/runtime/resource/Resource.html" title="class in org.apache.velocity.runtime.resource">Resource</a>&nbsp;resource)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from class:&nbsp;<code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#getLastModified-org.apache.velocity.runtime.resource.Resource-">ResourceLoader</a></code></span></div>
<div class="block">Get the last modified time of the InputStream source
that was used to create the template. We need the template
here because we have to extract the name of the template
in order to locate the InputStream source.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#getLastModified-org.apache.velocity.runtime.resource.Resource-">getLastModified</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader">ResourceLoader</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Time in millis when the resource has been modified.</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#getLastModified-org.apache.velocity.runtime.resource.Resource-"><code>ResourceLoader.getLastModified(org.apache.velocity.runtime.resource.Resource)</code></a></dd>
</dl>
</li>
</ul>
<a name="getResourceReader-java.lang.String-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getResourceReader</h4>
<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html?is-external=true" title="class or interface in java.io">Reader</a>&nbsp;getResourceReader(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;encoding)
throws <a href="../../../../../../org/apache/velocity/exception/ResourceNotFoundException.html" title="class in org.apache.velocity.exception">ResourceNotFoundException</a></pre>
<div class="block">Get an InputStream so that the Runtime can build a
template with it.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html#getResourceReader-java.lang.String-java.lang.String-">getResourceReader</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader">ResourceLoader</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>name</code> - name of template</dd>
<dd><code>encoding</code> - asked encoding</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>InputStream containing template</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../../../../../org/apache/velocity/exception/ResourceNotFoundException.html" title="class in org.apache.velocity.exception">ResourceNotFoundException</a></code></dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.0</dd>
</dl>
</li>
</ul>
<a name="finalize--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>finalize</h4>
<pre>protected&nbsp;void&nbsp;finalize()
throws <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html?is-external=true" title="class or interface in java.lang">Throwable</a></pre>
<div class="block">Close DB connection on finalization</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a></code>&nbsp;in class&nbsp;<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html?is-external=true" title="class or interface in java.lang">Throwable</a></code></dd>
</dl>
</li>
</ul>
<a name="prepareStatement-java.sql.Connection-java.lang.String-java.lang.String-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>prepareStatement</h4>
<pre>protected&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html?is-external=true" title="class or interface in java.sql">PreparedStatement</a>&nbsp;prepareStatement(<a href="https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html?is-external=true" title="class or interface in java.sql">Connection</a>&nbsp;conn,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;columnNames,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;tableName,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;keyColumn)
throws <a href="https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html?is-external=true" title="class or interface in java.sql">SQLException</a></pre>
<div class="block">Creates the following PreparedStatement query :
<br>
SELECT <i>columnNames</i> FROM <i>tableName</i> WHERE <i>keyColumn</i>
= '<i>templateName</i>'
<br>
where <i>keyColumn</i> is a class member set in init()</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>conn</code> - connection to datasource</dd>
<dd><code>columnNames</code> - columns to fetch from datasource</dd>
<dd><code>tableName</code> - table to fetch from</dd>
<dd><code>keyColumn</code> - column whose value should match templateName</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>PreparedStatement</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html?is-external=true" title="class or interface in java.sql">SQLException</a></code></dd>
</dl>
</li>
</ul>
<a name="fetchResult-java.sql.PreparedStatement-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>fetchResult</h4>
<pre>protected&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html?is-external=true" title="class or interface in java.sql">ResultSet</a>&nbsp;fetchResult(<a href="https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html?is-external=true" title="class or interface in java.sql">PreparedStatement</a>&nbsp;ps,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;templateName)
throws <a href="https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html?is-external=true" title="class or interface in java.sql">SQLException</a></pre>
<div class="block">Fetches the result for a given template name.
Inherit this method if there is any calculation to perform on the template name.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>ps</code> - target prepared statement</dd>
<dd><code>templateName</code> - input template name</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>result set</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html?is-external=true" title="class or interface in java.sql">SQLException</a></code></dd>
</dl>
</li>
</ul>
<a name="getReader-java.sql.ResultSet-java.lang.String-java.lang.String-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getReader</h4>
<pre>protected&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html?is-external=true" title="class or interface in java.io">Reader</a>&nbsp;getReader(<a href="https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html?is-external=true" title="class or interface in java.sql">ResultSet</a>&nbsp;resultSet,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;column,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;encoding)
throws <a href="https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html?is-external=true" title="class or interface in java.sql">SQLException</a></pre>
<div class="block">Gets a reader from a result set's column</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>resultSet</code> - </dd>
<dd><code>column</code> - </dd>
<dd><code>encoding</code> - </dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>reader</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html?is-external=true" title="class or interface in java.sql">SQLException</a></code></dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/DataSourceResourceLoader.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../../org/apache/velocity/runtime/resource/loader/FileResourceLoader.html" title="class in org.apache.velocity.runtime.resource.loader"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.html" target="_top">Frames</a></li>
<li><a href="DataSourceResourceLoader.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#fields.inherited.from.class.org.apache.velocity.runtime.resource.loader.ResourceLoader">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2000&#x2013;2021 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>