jdbc notes


1. Specify rules
2. Reduce the coupling synergy between the files in the Java project. So as to reduce maintenance costs [Design Principles]

1.javase: Refers to the Java class is performed separately, and the law rules are required when dealing with business separately. For example, inheritance, access permissions, interface implementation, control statement, identifier named. Essence Essence
2.javaee: Java complies with the development rules when developing business development. During the business development process, Java often needs to communicate with different servers to solve the current business. Because in the business development process, Java needs to communicate with 13 different servers. Therefore, Sun Company specifies the 13 package interfaces according to the characteristics of 13 servers, which are collectively referred to as the Javaee specification. Sun Company is equivalent to [Automobile Manufacturing Factory] to provide interfaces (Engine), but it is not responsible for providing a class in the interface. The implementation class in the interface is provided by different server manufacturers. The server manufacturer will complete the interface implementation class provided in the form of jar package. Java programmers get the implementation class in the interface through the jar package, so as to achieve communication with the designated server.

1. A specification in Javaee

2. Specify the communication rules between Java class and relational database servers [MySQL, Oracle, SQLServer]

3.JDBC specifications provide interfaces in JDKJAR. java.sql bag

4.JDBC specification interface implementation classes are provided by different relational database server manufacturers in the form of jar package

Through the tool [PreparedStatement interface implementation class], push the Java project [SQL command] to the MySQL server. The MySQL server performs corresponding operations to the table file based The operation results returned to the Java project that initiated the request. JDBC standard call process

1. Register the Driver interface implementation class to JVM with the Driver interface implementation of the MySQL server manufacturer

2. DriverManager in the JDBC specification establishes a [connection channel] between the Java project and the MySQL server in the Java project and the MySQL server

3. Provide the Connection interface through the MySQL server manufacturer to implement a transportation tool [PreparedStatement]

4. Push the SQL command from the Java project to the MySQL server through the transportation [PreparedStatement]

5. Destruction of this transaction involve all resource objects

1. Location: java.sql package under jdk_1.8.jar under jdk_1.8.jar

  • 2. Classification:

    • (1) java.sql.driverManager Class: This class exists under JDK 1.8.

    Responsible for providing the Driver interface implementation of the database manufacturer for registration.

    • (2) Java.sql.connection interface: Responsible for managing the Java engineering and database services [Connection channel]
    • (3) java.sql.preparedStatemen interface: Responsible for managing management on the [Connection Channel] for round -trip transportation tools
    • (4) java.sql.ResultSet interface: Responsible for managing the database server to return [temporary table]

  • ps.executeUpdate
    • (1). Responsible for push the insertion command [INSERT], update the command [update], delete the command [delete]
    • (2) When the return result operates the table file, receive the number of influence rows, such as inserting multiple lines, how many rows are updated, how many lines are deleted
  • ps.executeQuery
    • (1) Responsible for pushing the query command [Select * from table name]
    • (2) The return result is to query the command to get the [temporary table], and the [temporary table] in the JDBC specification is handed over to the ResultSet interface to implement the class management. Actually return to ResultSet instance object

  • 1. Introduction:
    • (1) dao = database access object; database access object
    • (2) Function: Database access objects provide operational details for a certain table when developing [addition, deletion, change check]
    • (3) Advantages: Advantage 1: During the development of management system, you can avoid repeated SQL commands to write advantages through the database position object 2: During the development of management system, you can avoid repeated JDBC development steps through the database position object.
    • (4) DAO class: Class of providing database access objects 2. Dao class development rules:
  • (1) Details of operation when a DAO class is packaged
    • (2) The rules of the DAIO class command: Table name+DAO.
    • (3) DAO Category is located. DAO,

1. A physical class is used to describe a table structure 2. The class name of the physical class should be consistent with the associated table name, but it can be ignored

DEPT.FRM ————-> Public Class dept () 3. The attributes of the physical class should be consistent with the associated table file fields. FRM ———————————————————————————————————————————————————————————————————————- -> PUBLIC Class DEPT {deptno int Private Integer deptno; dname varchar (20) Private String Dname; Loc Varchar (20) Private String Loc;} 4. An example object of the physical class is used in the tabletop file in the memory. A data line


Random Posts

spark-dataframe data Insert mysql performance optimization IT


Start writing blogs! Intersection The first one today: The general process of FFMPEG decoding network RTSP stream and the problems encountered these days, especially the AVFORMATINPUTOPEN analysis of the error network stream for a long time without returning!

PURE.CSS source code analysis

How to guide the high -definition diagram of Matlab/Simulink simulation box (vector map)