Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Renaming it is totally upto you. DAO pattern abstracts any type of data access not necessarily a Database access. So you can definitely go ahead with your plan. </p> <p>You can use a framework like spring, instead of manually creating the patterns.</p> <p>I had tried hardcoding these patterns just once. </p> <pre><code>public abstract class DAOFactory { // List of DAO types supported by the factory public static final int MYSQL = 1; public static final int ORACLE = 2; public abstract UserDAO getUserDAO() throws SQLException; public static DAOFactory getDAOFactory(int whichFactory) { switch (whichFactory) { case MYSQL: return new MySQLDAOFactory(); case ORACLE : ...... public class MySQLDAOFactory extends DAOFactory { public MySQLDAOFactory() { } public static final String DRIVER= "/*driver here*/"; public static final String DBURL="/*conn string here*/"; /* instead of using constants you could read them from an external xml file*/ public static Connection createConnection() { /*create connection object here*/ return conn; } public UserDAO getUserDAO() throws SQLException{ return new MySQLUserDAO(); } public interface UserDAO { public int insertUser(String fname, String lname); public ArrayList&lt;User&gt; selectUsers(); } public class MySQLUserDAO implements UserDAO { Connection conn=null; Statement s=null; public MySQLUserDAO() throws SQLException{ conn = MySQLDAOFactory.createConnection(); s = conn.createStatement(); } public int insertUser(String fname, String lname) { //implementation } public ArrayList&lt;User&gt; selectUsers() { //implementation } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload