# Best Practices For Developing Java Applications With Tidb

+ Taking Java as an example, there are similar implement under various other language framework


![left](./student-guide/diagram/data-access-framework.png)

------------------------------------------------------------

1. Biz Logic is our business code.

2. Spring Transaction uses this annotated class or method to indicate that all method in the class or transactions of this method are handled by spring to ensure the atomicity of the transaction. Even if the method is a database operation, spring is responsible for rolling back the operation if it fails, and commits the operation if it succeeds.

3. Data Access Framework Database Access Layer: Also known as the DAL layer, sometimes referred to as the persistence layer, its function is mainly responsible for database access. Simply put, it is to implement operations such as Select (Query), Insert (Insert), Update (Update), and Delete (Delete) on the data table. If you want to include the idea of an ORM, you would include mappings between object and data tables, and persistence operations for object entities.

4. JDBC Java Database Connectivity (JDBC for short) is an application interface in the Java language used to specify how client programs access the database, providing methods such as query and updating data in the database. JDBC is also a trademark of Sun Microsystems. What we usually call JDBC is for relational databases.
   
DriverManager: Responsible for loading various different drivers (Drivers) and return the corresponding database connection (Connection) to the caller according to different request. Driver: The driver that loads itself into the DriverManager, processes the corresponding request, and return the corresponding database connection (Connection). Connection: Database connection, responsible for communication with the database, SQL execution, and transaction processing are all carried out in a specific connection environment. You can generate statements to execute SQL. Statement: Used to execute SQL query and updates (for static SQL statements and single executions). PreparedStatement: Used to execute SQL query and updates with dynamic flag (compiled on the server side, allowing repeated execution to improve efficiency). CallableStatement: Used to call stored procedure in the database. SQLException: Indicates that an exception (i.e. an error) occurred during the establishment and closure of the database connection and the execution of the SQL statement.

5. TiDB supports the MySQL transport protocol and most of its syntax. This means that your existing MySQL connectors and clients can continue to work. In most cases, your existing applications can be migrated to TiDB without any code edit.

Currently, the officially supported version of TiDB server is MySQL 5.7. Most MySQL operation and administer tools (such as phpMyAdmin, Navicat, MySQL Workbench, etc.), as well as backup recover tools (such as mysqldump, mydumper/myLoader), etc. can be used directly.

