Jose Sandoval Google
 Resume     Book     Software     Drawings     Home     Subscribe to RSS feed Search Web Search josesandoval.com

DAO + my DBUtil + Struts 1.2
Sunday, April 03, 2005

DBUtil is my freely available database utility based on the Jakarta commons-dbutils. It also includes a database connection pool, which is easily configurable via a db.properties file.


Running Application and Source Code
You can think of the application I provide in the tutorial as a canonical example of a Struts application + my DAO-like pattern and DBUtil + a working example of and app using Jakarta commons packages.

You can find online:My DBUtil + Modified DAO Pattern
The approach I describe is DAO-like in the sense that your database interactions are delegated away from your controller classes or business objects to DBUtil.

Your Action and BO classes don't know nor care how the persistence layer is implemented. More over, the code you need to interact with the database is minimal.

For example, this is what a method to create a new record looks like:

public static void create(DemoVO vo) throws Exception {
DBUtil.update(Constants.POOL_NAME,
propertiesSQL.getProperty(Constants.SQL_CREATE),
new Object[] {vo.getName(), vo.getLastName()});
}

Perhaps someone out there can make use of it - It defenetely has saved me countless hours of coding in the last couple of years.


4:39 PM | 2 comment(s) |

Comments:

hola Jose, me llamo Fernando, soy argentino pero vivo y trabajo en Italia (soy programador). La verdad es que hoy descubri tu sitio y me gusta mucho, no hay demasiados sitios que traten temas de programacion al nivel que los tratas vos.
Te felicito y seguramente voy a seguir leyendo tus notas.

Fernando Arturi
fernando.arturi@gmail.com
By Anonymous fernando, at 4:10 AM


Hi, i've tried out your dbutil but i always get a java.lang.exception when i try to create a query based on parameters different from String...i wonder why...
Anyway congratulations on your site.

Nuno Rodrigues
nunoalexandre.rodrigues@gmail.com
By Anonymous Anonymous, at 5:45 PM



This page is powered by Blogger. Isn't yours?

Guestbook
© Jose Sandoval 2004-2009 jose@josesandoval.com