ORM(Object-Relational
Mapping, Object relation mapping ), Yes JAVA Objects in correspond to data in the database , The basic idea is , Class corresponds to the table structure in the database , Property and field correspondence in class , Records in the table correspond to objects .

Overall structure

Core classes and interfaces

Query: Responsible for inquiry , Core categories of external services ( Add, delete, modify and query )

QueryFactory class : Responsible for creating according to configuration information query object ( If the configuration information is queryClass=com.ustc.core.MySQLQuery, Then create MySqlQuery Object of class ;queryClass=com.ustc.core.OracleQuery Then create OracleQuery Object of class )

TableContext class : Responsible for getting the relationship between all table structures and class structures of the management database , The class structure can be generated according to the table structure .

DBManager class : According to the configuration information , Maintain management of connection objects ( Get configuration information , Create connection , Close connection )

TypeConvertor Interface : Responsible for type conversion

core bean( Encapsulate relevant data )

ColumnInfo class : Encapsulate a field information in a table ( Field type , Field name , Key type, etc )

Configuration class : Encapsulate profile information

TableInfo class : Encapsulate information from a table

JavaFiledGetSet class : Package corresponds to table structure java Properties of class ,get and set Source code of method

Tools

JDBCUtils class : Package common JDBC operation

StringUtils class : Encapsulate common string operations

JavaFileUtils: encapsulation Java File operation

ReflectUtils class : Encapsulate common reflection operations

* Connect to database according to configuration information

Configuration information is stored in Configuration Class , The object is in the DBManager Class ,DBManager Mainly used to obtain configuration information , Connect and close the database according to the configuration information .

1.1 configuration information
driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/sorm?useSSL=false
user=root pwd=123456 usingDB=mysql srcPath=C\:\\WorkSpace\\eclipse\\orm\\src
poPackage=com.ustc.test.po queryClass=com.ustc.core.MySQLQuery
1.2 Configuration information management class
package com.ustc.core; import java.io.IOException; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.PreparedStatement; import
java.sql.ResultSet; import java.sql.SQLException; import java.util.Properties;
import com.ustc.bean.Configuration; /** * According to the configuration information , Maintain management of connection objects * @author GuoJun *
*/ public class DBManager { /** * Connection information */ private static Configuration conf;
/** * Write configuration information Configuration */ static { Properties pros = new Properties(); try
{
pros.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("db.properties"));
} catch (IOException e) { e.printStackTrace(); } conf = new Configuration();
conf.setDriver(pros.getProperty("driver"));
conf.setPoPackage(pros.getProperty("poPackage"));
conf.setPwd(pros.getProperty("pwd"));
conf.setSrcPath(pros.getProperty("srcPath"));
conf.setUrl(pros.getProperty("url")); conf.setUser(pros.getProperty("user"));
conf.setUsingDB(pros.getProperty("usingDB"));
conf.setQueryClass(pros.getProperty("queryClass")); // load tableContext
System.out.println(TableContext.class); } /** * Create connection object * @return */ public
static Connection creatConn() { try { Class.forName(conf.getDriver()); return
DriverManager.getConnection(conf.getUrl(), // Connect directly , Increase connection pool treatment in later stage , increase of efficiency
conf.getUser(),conf.getPwd()); } catch (Exception e) { e.printStackTrace();
return null; } } /** * Close connection * @param con Connections to close * @param ps * @param rs */
public static void close(Connection con, PreparedStatement ps, ResultSet rs) {
try { con.close(); } catch (SQLException e1) { e1.printStackTrace(); } try {
if(ps != null) ps.close(); } catch (SQLException e) { e.printStackTrace(); }
try { if(rs != null) rs.close(); } catch (SQLException e) {
e.printStackTrace(); } } /** * Close connection * @param con * @param ps */ public static
void close(Connection con, PreparedStatement ps) { try { con.close(); } catch
(SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }
try { if(ps != null) ps.close(); } catch (SQLException e) {
e.printStackTrace(); } } /** * Get configuration information * @return */ public static Configuration
getConfiguration() { return conf; } }

Technology
©2019-2020 Toolsou All rights reserved,
element-ui Of el-date-picker Component get value Spark SQL- programming about Bellman-Ford Personal understanding of algorithms [work] python read txt Last line of file ( Essence )2020 year 7 month 12 day webpack Use of common plug-ins Vue Transfer parameters and receiving of page Jump 11-5 Output string at specified position el-select At the same time label and value value Three methods of value transfer between non parent and child components use mt-range The effect of changing a number with the sliding bar is realized