More servicesWindows Live
HomeHotmailSpacesOneCare
 
MSN
Sign in
 
 
Spaces home  Laney ConsultingProfileFriendsBlog Tools Explore the Spaces community

Laney Consulting

Application Development using Java and Open Source Technologies

Laney Consulting

View spaceSend a message
Occupation:
Location:
Working in Information Technology since 1997, with progressive experience in Enterprise Application Development using Open Source and Java technologies.
View space
Jennifer

July 23

Implement connection pooling in Tomcat 5.5 using Hibernate 3, MySQL 5

Culled from various sources:

Add JDBC driver, mysql-connector-java-5.1.5.jar to apache-tomcat-5.5.xx\common\lib

Add resource-ref to WEB-INF/web.xml

=================================================================

<web-app ...>

...

<resource-ref>
    <description>
        Resource reference to a factory for java.sql.Connection
        instances that may be used for talking to a particular
        database that is configured in the server.xml file.
    </description>
    <res-ref-name>jdbc/MySqlDb</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

</web-app>

================================================================

Add session-factory name attribute and property elements to WEB-INF/classes/hibernate.cfg.xml

=================================================================

<hibernate-configuration>
    <session-factory name="java:hibernate/SessionFactory">

        <!-- JNDI Connection -->
        <property name="hibernate.connection.datasource">
            java:comp/env/jdbc/MySqlDS
        </property>

        <property name="hibernate.dialect">
            org.hibernate.dialect.MySQLDialect
        </property>

...

    </session-factory>
</hibernate-configuration>

==================================================================

Add Resource to META-INF/context.xml, alternatively add Resource to GlobalResources in tomcat server.xml

==================================================================

<?xml version="1.0" encoding="UTF-8"?>

<Context path="/MyApp" reloadable="true">

  <Resource name="jdbc/MySqlDS" auth="Container"
    type="javax.sql.DataSource"
    maxActive="100" maxIdle="10" maxWait="10000"
    username="myUsername" password="myPassword"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/bookstore?autoReconnect=true"/>

</Context>

==================================================================

That should work!

StrutsTestCase for JUnit

Not sure if this is going to work for the Struts 1.1 app I support at work. Doesn't seem to be support for Struts 2, either, but it's worth a look. More later if I ever get around to implementation.

StrutsTestCase for JUnit

June 16

Unit test JPA Entities with in-memory database « Eskatos’s thoughts on JEE development

I've been looking for a way to JUnit test my applications using Hibernate which require a  database connection. This looks promising!

Unit test JPA Entities with in-memory database « Eskatos’s thoughts on JEE development

June 06

Struts2 checkboxlist UI tag rendering one item per line

After struggling with this UI tag for a some time today, I gave up and was attempting to use s:checkbox inside of an s:iterator to render one item per line, unsuccessfully.

So, upon revisiting s:checkboxlist, I found that it's a relatively painless thing to override the checkboxlist.ftl file described here, http://struts.apache.org/2.0.9/docs/template-loading.html, add a break at the end of this line

<label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label><br />
and save the file in the webapp/template/simple dir of my web application.

Hello, all!

I've maintained a blog for several years on my own server, and decided it was time to move to a lower maintenance solution. Spaces looked like a good choice, so here goes!
 
Most of my posts will be technically oriented, simply because there's never enough good information when looking for a solution to a tough problem. Blogging serves as documentation for myself, as much as it does for anyone else trying to solve the same or similar problems.
 
I have experience using Java, CSS, HTML, JavaScript, Struts 2, Maven 2, Hibernate 3 and other Open Source and Internet technologies. Please feel free to contact me with any questions or comments.