What is the need for a DAO architecture?

  • When programming in Java, is it always necessary to code in accordance with the DAO architecture? If so, what are the benefits of using it?

  • I am doing a project with a class diagram as shown below. What are the disadvantages of this?

alt text

Entity Class:

private void fillSONumber() {
    try {
        ZnAlSalesOrder o = new ZnAlSalesOrder();
        ArrayList a = o.getPendingSalesOrderIDs();
        for (int i = 0; i < a.size(); i++) {
            cmbSoNo.addItem(a.get(i));
        }
        o.close();
    } catch (Terminated ex) {

    }
}

EntityTable class example:

public ResultSet select(String fields, String selection) {
    db = new Database();
    db.select("SELECT " + fields + " FROM " + name + " WHERE " + selection);
    return rs = db.rs;
}

and the database class establishes a connection and destroys.

+3
source share
4 answers

The purpose of the DAO template is to separate the data that you are trying to get from how it is stored.

, DAO, , MySQL. - , MSSQL Oracle, , , .

, .

, , , . , - , .

, - , .

SQL , , , , . .

+2

Java DAO ? , ?

DAO - , . , , , , . , , - . , DAO , .

, . ?

. , , . , ? , - . API. . , , .

, , o.close(); close? DAO , . beans. , -, .

+4

(DAO) CRUD (, , ). EntityTable Gateway, . :

DAO , .

. , , , . .

+1

DAO , , . DAO Java, Connection, Normal Bean, . . Connection, , Normal Bean . , - . , , . , , .

+1

Source: https://habr.com/ru/post/1773246/


All Articles