JDBC Phase Summary

Source: Internet
Author: User

First, the concept of JDBC: Java Database Connectivity working with the Java language databases (via SQL)
Second, the database driver and the JDBC relationship
Third, the steps to write JDBC:
A, registered driver
b, establish a link with the database
C, create an object that represents the statement
D. Execute statement
E, if there is a result set, traverse
F. Releasing resources
Iv. a detailed description of JDBC-related classes and interfaces
1, DriverManager
Registration driver
Get a link to a database
2, Connection
All interactions with the database are based on the interface
Function:
Create an object that represents an SQL statement (normal statement, precompiled statement, call stored procedure)
Transaction control
Transaction ISOLATION Level Control
Access to database metadata information
3, Statement
Execute SQL statement: ExecuteQuery executeupdate
Perform batch processing
4, ResultSet
The results of the query should be encapsulated in the JavaBean
5, PreparedStatement (preferred)
Parameters take placeholders
Prevent SQL injection
Precompiled SQL statements for high execution efficiency
V. Release of resources
JDBC Tool classes are extracted (easy to switch databases)
Coded with template
VI. Basic CRUD Operations
Seven, in the real case wrote a DAO implementation (user registration and login case)
Viii. Javaweb Case: Customer Information Management CRUD

Nine, access to Big data: CLOB and BLOBs
10, Batch SQL statements: Improve database utilization (execution efficiency)
11, how JDBC invokes stored procedures in the database
SQL: {Call stored procedure name (?,?)}
input parameter to value, output parameter to register data type (Java.sql.Type)
12, get started with transaction
Mysql:start Transaction;commit;rollback;
JDBC:conn.setAutocommit (False) commit () rollback ()
13, characteristics of the transaction (atomicity consistency persistence isolation)
14, Isolation topic:
Concept: Dirty read, non-repeatable read, virtual read
Prevent these incorrect conditions by adjusting the isolation level:
READ UNCOMMITTED
Read COMMITTED
Repeatable read
SERIALIZABLE

level higher, less efficient, The more secure the data, the
the isolation level must be set before the transaction is opened
15, link pooling principle
connection pooling: Lifting efficiency
Packaging design mode
Dynamic Agent
16, open source data source
DBCP
C3p0
Get the data source in Tomcatjndi: Configure
17, get the database metadata information (prepare for writing the framework)
18, write your own JDBC framework (simplified JDBC encoding only)
Policy design mode: Resultsethandler interface
19, dbutils framework Queryrunner Basic Use
batch, query; DML
20, dbutils Resultsethandler implementation class
encapsulates the result set
21, ThreadLocal (it is important.) Thread local variable)
22, how to control transactions in real development
1, DAO is only responsible for CRUD
2, Aspect-oriented programming: With Dynamic proxy
23, multi-table operation with Dbutils (very helpful for learning hibernate)
One-to-many
Many-to-many
one-to-one

focus on how the tables are designed; the correspondence between them must be clear that the relationship between the
table is related by a foreign key
the relationship between objects is referenced by association

24, large result set of paging (improve efficiency)
Mysql:limit M,n
Index of M start record
n number of strips per fetch

The common code was extracted: Page.java page.jsp










































JDBC Phase Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.