DAO(Data Access Object)- main aim is to interact with data machines
DataSource is interface given by Sun, for implementing connection pool. Similarly DriverManagerDataSource is given by Spring
WeblogicDataSource by Weblogic
BasicDataSource by Apache
Sample code to create connection pool:
BasicDataSource bds=new BasicDataSource(); //pool reference.
bds.setDriverClassName(driver);
bds.url(dburl);
bds.setUsername(user);
bds.setPassword(pass);
bds.setMaxActiveConnections(20);
bds.setMinIdle(5);
bds.setWaitTime(1000*5);
bds.getConnection() -> To get a connection object
Pool is maintained using map objects(freeMap and consumed map). When user closes a connection, it is moved from consumed map to freemap
http://theblasfrompas.blogspot.in/2007/10/using-dao-j2ee-design-pattern-with-adf.html
- Do persistence operations
- Interact with rdbms, ldap, nosql or xml
- Interface between Business & data machine for simple data access operations
- We can implement DAO using
- jdbc from sun
- jax-b, jax-p parsers for xml files
- ORM tools to access data from rdbms database
- EJB
- JPA
- Hybernate
- ibates
- OGM to interact with nosql
- Spring-jdbc for rdbms machines
- Spring-orm for rdbms machines
- Standard way of creating DAO
- Create a modal with fields/structure same as DB table. Add getters/setters
- Create DAO interface with all the required methods(signatures and return values). eg: update, delete, findByName, findAll
- Create DAOImpl1 implementing all the methods of DAO interface in previous step using JDBC
- in side the method, get the connection from pool, do operation, and release the connection to pool
DataSource is interface given by Sun, for implementing connection pool. Similarly DriverManagerDataSource is given by Spring
WeblogicDataSource by Weblogic
BasicDataSource by Apache
Sample code to create connection pool:
BasicDataSource bds=new BasicDataSource(); //pool reference.
bds.setDriverClassName(driver);
bds.url(dburl);
bds.setUsername(user);
bds.setPassword(pass);
bds.setMaxActiveConnections(20);
bds.setMinIdle(5);
bds.setWaitTime(1000*5);
bds.getConnection() -> To get a connection object
Pool is maintained using map objects(freeMap and consumed map). When user closes a connection, it is moved from consumed map to freemap
http://theblasfrompas.blogspot.in/2007/10/using-dao-j2ee-design-pattern-with-adf.html





