General J2EE: Data Access Design Pattern what is it &how to use it .. ????
this is the prob...
- Posted by: Nehal Dave
- Posted on: December 02 2002 22:16 EST
Context ctx = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("nehalDS");
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.getResultSet();
the same code i am using in all the jsps through out the site to access the oracle database. I need to abstract it into some reuseable pattern.i found out Data Access Object pattern is the solution but how to use it... can any1 help me with some small example on which i can built up...
- Data Access Design Pattern what is it &how to use it .. ???? by Dorel Vaida on December 03 2002 03:52 EST
- Data Access Design Pattern what is it &how to use it .. ???? by Web Master on December 03 2002 13:51 EST
If I understand right you are looking for a replaceable persistence layer ? You might look into EJB Design Patterns of Floyd Marinescu and search for Data Access Command Bean pattern. It's lightweight and extremely effective unless you have lotsa domain objects, situation when your persistence layer becomes clutterd with small classes... but it's your choice at last
Dunno if this helps, sorry. you might be a little more specific in your next note ... :-)
DAO Pattern - http://java.sun.com/blueprints/patterns/DAO.html
You should also consider using the MVC pattern instead of having your JSPs talk directly to your DB. JSP's should simply present data w/o needing to know where it came from.