- Add annotation to the table class:
Table
,Id
andColumn
; - Add a child class for the
JdbcUtils
class; - Initialization the child class by uri, username, password and parameters array;
- Use
JdbcUtils#Connection()
function to connect to the MySQL database; - You can use
insert
,updateById
,deleteById
andselectById
; - You can use
delete
andselect
function; - NOW you can use
setAutoCommit()
,commit()
,rollback()
,rollback(sp)
andgetSavepoint()
to transactional.
- If you MySQL database have used
datetime
, it can only be converted intoString
; - It supports
int
,Integer
,double
, 'Doubleand
String`. - The function
select
has a parameterwhere
, equals SQL's, but now it is only support=
. Thedelete
function also.
This code is mainly referenced 【Java进阶】实现自己的ORM框架.