DAO framework - from "1" (one)

background:

For a long time (4 years) before writing a DAO framework -zxdata ( https://github.com/shuimutong/zxdata ), this is the first framework I wrote. Since no documents, now if I want to use, then you have to start looking at the code, not too practical. zxdata not using connection pooling, so practiced hand significance than the use of sense. Recently want to override a DAO framework, hoping to ease of use, in terms of performance also has good performance.

-----Split-------

Work for so many years, rewrite DAO framework, found that the framework is not easy to write:

First, too simple. Can not let users use only a framework, the framework had to first read through the code to know how to use.

Secondly, the package get package together. A release of code, specifically how to use? Use what? It is the user's own decision. For sustainable iterative framework, can not be upgraded later realizations, resulting in previously incompatible code.

Finally, under the premise of the package, must try to provide sufficient freedom to the user to use. Connection pooling and ORM framework contains two mapping functions, I think the connection pooling feature very good use, I just want to use connection pooling function, you have to let me use the frame alone.

This is more than three points, that I think needs. If not all, welcome comments that.

 

Oaks from little acorns, I am from the configuration designed from the start.

"Configuration"

First, the connection parameters

    1, driver class name

    2, the connection

    3, the user name

    4, password

Second, connection pool parameters

    1, the number of initial connection

    2, the maximum number of connections

    3, the maximum wait time (0 - infinite wait)

Generated questions:

https://www.cnblogs.com/JavaSubin/p/5294721.html

1, described look online, connected with the minimum number of connections and the number of initial connection.

The two separate configuration What view?

a, if the initial number of connections is less than the minimum number of connections, it would mean that even new?

b, if the initial number of connections is greater than the minimum number of connections, and that the initial so much to do?

2, remember to have seen the largest number of idle connections. Say now basically no.

Looked at the original connection could have been a valid time. So do not consider the initiative to destroy a connection, simply remove invalid on the line at the time of detection.

Original words: maxIdle attribute indicates the maximum number of idle connections, over idle connections will be released, the default is 8. The corresponding attribute is deprecated Druid connection pool, the configuration has no effect

Reference configuration:

## drive name 
driverName = com.mysql.jdbc.Driver 
## connected url 
connectionURL = jdbc: MySQL: // localhost:? 3306 / useServerPrepStmts the Simple = false to true & connectTimeout & rewriteBatchedStatements = = = 1000 & useUnicode to true characterEncoding = UTF-8 & 
## User Name 
userName = Simple 
## user password 
the userPassword = 123456 
## initializes the number of connections 
initConnectionNum 10 = 
## the maximum number of connections 
maxConnectionNum = 50 
## maximum latency query 
maxQueryTime = 3

"Configuration - introductions"

Configuration is more than that. After configuring the good column, I began to organize the function point .

 

"function points"

I use the hierarchy to function in accordance with points points.

First, the top

  1, the object level

    New objects, update, query, delete.

  2, SQL level

    a, custom SQL query

    b, execute custom SQL

    c, call Method: execute stored procedures, functions,

  3, affairs

    Open transactions, closes rollback

Second, the base layer - Connection Pool

  1, Function Point

    Initialize the connection, get a connection, create a new connection

    I began to think that the time to get connected to wait a while and try again if there is no connection, and later found not necessary to refer to another frame, the connection is not directly connected to the depletion return bin. Simple, simply.

  2, Notes

    a, pre-caching settings?

      Currently not get to know what is

    b, validity detector connected

      Connection is available

      Close connection timeout setting: a longer survival time of connection, connection to prevent leakage

"Function Point - introductions"

Finishing point is the function of these, I was sort of mind map, the overall structure is as follows:

- To learn how the next, until next time please explain -

 

Guess you like

Origin www.cnblogs.com/shuimutong/p/10962182.html