All the products and materials by OOP-Research are developed and published based on your feed back. When you are using our products or reading our articles, you may have questions or difficulties. Whenever this is true for you, don't hesitate to contact us. Please share your opinion with us. Then, you will get the better products. (We offer 1 year FREE upgrade!) Or the new articles or examples may be published and they may shed the light on your Java development.
The more you talk, the more you get!
Based on your feed back, OOP-Research will continue to publish the new examples, sample source codes and articles for Simple DAO Helper. You will find the links to them on our web site at the URL of:
On the upper part of this web page, there is the section titled Related Pages. And the links to the new resources will be listed in this section. So, please visit the above URL periodically.
In this distribution, you will find the following files and directories:
| README.html | This file. |
| LICENSE | The license agreement of this product. Please read this file before using this product. |
| conf | The directory for the configuration files. Only if you use DaoHelperForJdbc, you need to edit DaoHelperForJdbc.properties. |
| apiDoc | The directory for the API documentation (Java Doc). This Java Doc describes the details about the classes and their methods of this API. Please read it while you develop your web application using this API. |
| daohelper_x_y.jar | The binary file of this API. Please make it visible to the class-loader of your web application. Putting it under WEB-INF/lib directory will be enough. |
| oop_util_x_y.jar | Another binary file of this API, which includes the class files shared with other APIs by OOP-Research. Please make it visible to the class-loader of your web application. Putting it under WEB-INF/lib directory will be enough. |
By the help of this Java API, your Data Access Object (DAO) can get the JDBC Connection in the various way. If the JNDI DataSource is available in your environment, your DAO can depend on it to query the JDBC Connection. Otherwise, your DAO can create the JDBC Connection from the JDBC driver. In any case, you need to install the JDBC driver for your SQL database. The available JDBC drivers are listed at the URL below:
Optionally, your DAO can take the full advantage of PooledStatement, another Java API from OOP-Research.
This API implements the pooling mechanism for the JDBC PreparedStatement and ensures the Thread Safety of your web application.
Because you can select how to get the JDBC Connection, the different configuration will be required for your strategy.
Please go to the section suitable for your strategy:
If you use:
SimpleDaoHelper will look up the JNDI DataSource within your J2EE environment and will ask it the JDBC Connection. To make it possible, the intended JNDI DataSource must be found by:
within your J2EE environment.
And the res-auth element of this JNDI DataSource must be Container.
Then, SimpleDaoHelper can look up the intended JNDI DataSource and can obtain the JDBC Connection from it.
As an example, let's look into the required configuration for Tomcat 4.1.x and Tomcat 5.1.x .
To make the JNDI DataSource available for your web application, you will need to insert the elements like below into the intended <Context> element in your server.xml.
<Resource name="jdbc/DaoHelperDataSource"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/DaoHelperDataSource">
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/somedb?autoReconnect=true</value>
</parameter>
<parameter>
<name>username</name>
<value>foo</value>
</parameter>
<parameter>
<name>password</name>
<value>bar</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value>
</parameter>
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
</ResourceParams>
|
In case of Tomcat 5.5.x, the definition of JDBC DataSource will look like this:
<Resource name="jdbc/DaoHelperDataSource"
auth="Container"
type="javax.sql.DataSource"
maxActive="40"
maxIdle="10"
maxWait="10000"
username="foo"
password="bar"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/somedb?autoReconnect=true"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="false"
/>
|
In addition, you also need to edit web.xml for the intended web application context.
After <welcome-file-list> element, please insert the elements like:
<resource-ref>
<description>
JNDI DataSource for MailScheduler.
</description>
<res-ref-name>jdbc/DaoHelperDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
|
For details, please consult:
On any JSP/Servlet server, the docBase directory of your web applications will include the following JAR files:
Be sure to give the Read permission for these files.
NOTE for oop_util_x_y.jar:
If you have the older version oop_util_x_y.jar, please replace it with the new one. In other words, please be sure to find only the latest version of oop_util_x_y.jar under WEB-INF/lib directory.
If you use:
SimpleDaoHelper will get the JDBC Connection from the specified JDBC driver. To make it possible, the JDBC driver must be available to your web application. Please place the JAR file of your JDBC driver under:
or other directory if several web applications share the same JDBC driver. In addition, you need to edit:
and specify the following properties:
| Property name | Value |
|---|---|
| jdbc_drv | The fully qualified class name of your JDBC driver |
| jdbc_url | The URL for the intended database |
| jdbc_usr | The user name for the specified database |
| jdbc_pss | The password for the specified database |
You will find the template of DaoHelperForJdbc.properties under conf directory of this distribution.
Based on the properties in this file, this API can establish the JDBC Connection to your data base and create PreparedStatement from the JDBC Connection.
The docBase directory of your web applications will include the following JAR files and property files:
Be sure to give the Read permission for these files.
NOTE for oop_util_x_y.jar:
If you have the older version oop_util_x_y.jar, please replace it with the new one. In other words, please be sure to find only the latest version of oop_util_x_y.jar under WEB-INF/lib directory.
If you use:
PooledStatement is responsible for all the details, i.e. it establishes the JDBC Connection to your SQL database, creates the JDBC PreparedStatement and keeps it in the pool.
The required configuration is described in the README.html of PooledStatement, so please consult it.
The docBase directory of your web applications will include the following JAR files and property files:
Be sure to give the Read permission for these files.
NOTE for oop_util_x_y.jar:
If you have the older version oop_util_x_y.jar, please replace it with the new one. In other words, please be sure to find only the latest version of oop_util_x_y.jar under WEB-INF/lib directory.
To add the required JAR files to the new project ...
Dialog titled New Project will be shown. Please go ahead, then you will reach the section titled Java Setting Otherwise, please finish to set up the new project. You can add the JAR files later on the existing project.
For existing project ...
Dialog titled Properties for xyz (where xyz is the name of the project) will be shown. On the left navigation tree, select Java Build Path
To add the required JAR files to the new project ...
Dialog titled Project Wizard will be shown. Go ahead to the section titled Step 2 of 3
For existing project ...
Dialog titled Project properties will be shown. On the left navigation tree, select the item titled Paths
The distribution of this API is available at:
Whenever you have questions, please feel free to contact us at tech@oop-research.com. Please include your serial ID within your message.
ALL CONTENTS COPYRIGHT 2006, OOP-Research Corporation. All rights reserved.