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?
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.
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 , , , , . .
Java DAO ? , ?
DAO - , . , , , , . , , - . , DAO , .
, . ?
. , , . , ? , - . API. . , , .
, , o.close(); close? DAO , . beans. , -, .
o.close();
(DAO) CRUD (, , ). EntityTable Gateway, . :
DAO , .
. , , , . .
DAO , , . DAO Java, Connection, Normal Bean, . . Connection, , Normal Bean . , - . , , . , , .
Source: https://habr.com/ru/post/1773246/More articles:using user input such as YES and NO to control program flow in C ++ - c ++Is there a way to extract the individual parts of a single XML tag using PHP or Xslt? - xmlHow to guarantee space for ImageView so that it does not shrink? - androidPHP, problem with str_replace when reading from an array - phpmethods that do against methods that delegate - designSQLException: operation not allowed after closing ResultSet - javaClojure content type? - content-typeSELECT INTO with EF4 - linq-to-entitiesIs it possible to optimize array access? - javaCould anyone use a fast path PDU in an RDP client? - encryptionAll Articles