20155208 Xu Zihan 2016-2017-2 "Java Programming" 9th Week study Summary

Source: Internet
Author: User

20155208 Xu Zihan 2016-2017-2 "java program Design" 9th Week study summary Textbook Learning content summary 16th Chapter Integration Database

16.1 JDBC Primer

The composing application uses the communication protocol to carry on the instruction exchange to the database, in order to carry on the data deletion search.

JDBC Purpose: To allow Java program designers to compose a database operation program can have a unified interface, no need to rely on a specific database API, "Write a Java program, operate all databases."

Online database, you need to set the JDBC driver in classpath.

Basic database operations are related to JDBC interfaces or classes that are located in the java.sql package.

The action object of the connection interface is the database online representative object.

Statement is a representative object of SQL description and can be executed using methods such as executeupdate (), ExecuteQuery (), and so on.

The statement executeupdate () method is used for SQL that queries the database, such as SELECT, and returns an int result that represents the number of changes in the data.

The statement executequery () method returns the Java.sql.ResultSet object, which represents the query result.

The Execute () method of the statement is used to execute SQL, which returns true to indicate that SQL execution will return.

If some of the operations are just some of the parameters in the SQL statement, and the rest of the SQL clauses are the same, you can use Java.sql.PreparedStatement. Call Clearparametere () to clear the parameters of the setting, and then use the PreparedStatement instance again.

If you compose a stored procedure for a database and want to invoke it using JDBC, you can use Java.sql.CallableStatement. You must call Preparecall () to establish the CallableStatement exception, and you can register the output parameters with Registeroutparameter ().

16.2 JDBC Advanced

Let Messagedao rely on the Java.sql.DataSource interface, which can be connection by its defined getconnection () method.

In the future to modify the database server host location, in order to reuse the connection object and want to join the online pool mechanism, and so on, this messagedao without modification.

Online related information can be set using the. Properties.

When you create an statement or PreparedStatement instance, you can specify the result set type and parallel mode.

The limit for batch updates is that SQL cannot make a select, otherwise it throws an exception.

To support batch updates, you must append the Rewritebatchedstatements = True parameter to the JDBC URL to have a practical effect.

BLOBs are used to store large amounts of binary data, such as image files, audio files, etc., and CLOB are used to store large amounts of literal data.

The Blob field can be byte[] or input \ output stream.

In transaction management, you can set a storage point only if you want to recall a SQL execution point.

Through JDBC to know whether the database supports an isolation behavior setting, you can obtain the DatabaseMetaData object through connection's GetMetaData (). The DatabaseMetaData supporttransaction-isolationlevel () is known to support an isolated behavior.

Metadata is "the data of reading data" can be obtained through the connection GetMetaData () method DatabaseMetaData object, can obtain the overall information of the database, and resultset represents the query to the data, The ResultSetMetaData object can be obtained by ResultSet's GetMetaData () method.

A Javax.sql.RowSet interface that represents a collection of columns of data. The collection of columns can be added and checked. The query instruction is set by SetCommand (), and execute () executes the query instruction to populate the data.

17th Chapter

Using reflection Java really requires a class to load the corresponding. class document, not load all classes when the program starts.

Use the GetClass () method of object, or the. class constant to get the class object for each object, and if it is a base type, you can also get the class object by using the corresponding package class plus. Type. For example, Integer.type can get a class object representing int.

Use the ' Class.forName () method to implement the dynamic load class.

The Java.lang.reflect.Method instance is the representative object of the method, and you can use the Invoke () method to invoke the specified method dynamically.

Understanding the ClassLoader (ClassLoader)

is to read the binary data in the. class file into memory, place it in the method area of the run-time data, and then create the Java.lang.Class object of the class in the heap to encapsulate the class's objects in the method area class.

The JVM divides the class loading process into three steps: Mount (load), link, and Initialize (Initialize) links in a three-step way.

18th Chapter

Custom generics

When you define a generic, you must be a subclass of a class when you specify the actual type of T with the extends qualification. When you define a generic, you must be a subclass of a class when you specify the actual type of T with the extends qualification.

Covariance (covariance): B is a subclass of a, Node B can be considered a node A, which is called node has covariance.

wildcard character "? "The type with extends limit T, can only be specified by the name of the T declaration to object, or the name of the T declaration is specified as null.

Other (sentiment, thinking, etc., optional)

This week's study content has three chapters, the task is heavier, but fortunately only one chapter, so I spend most of the time to study the 16th chapter above, the time quickly, originally felt the thick of the "Java study notes" so learned, but these weekly self-study and then write study blog days past, How much knowledge have I really mastered? Have to say, for the first few chapters of the knowledge point, I still have some certainty, but the more to the back of the chapter, the content more and more difficult to understand, really learn less knowledge, but I think learning Java This course the biggest harvest or let me learn how to self-study.

Last week's summary of the wrong quiz
    • In the "Problem One" NIO2, you can use the method in (D) to remove the file system root directory information.

A. Path

E I Directorystream

C. Filestore

D. FileSystem

"Test Center": FileSystem's Getrootdirectorie method can remove the file system root directory information. The various methods of NIO are not familiar enough.

    • "Problem two": Regular expression "(' |") (.*?) \1 "Match" ' Hello ', the result of "world" is (BC)

A. does not match

B. ' Hello '

C. " World "

D. ' Hello ', "World"

reviewed the classmates blog and code

Study No. 1

Study No. 2

Study No. 3

Study No. 4

Study No. 5

Learning progress Bar new/accumulated
Number of lines of code (new/accumulated) Blog Volume (learning Time (new/cumulative)
Goal 5000 rows 30 Articles 400 hours
First week 16/16 1/1 8/8
Second week 120/120 2/2 12/12
Third week 130/150 1/1 9/9
Week Four 180/200 1/1 15/15
Week Five 150/300 1/1 12/12
Week Six 120/300 1/1 8/8
Seventh Week 300/300 2/2 10/10
Eighth Week 100/300 1/1 7/7
Nineth Week 100/200 1/1 8/8
Resources
    • Java Learning Notes
    • Java Learning Notes (8th Edition) Learning Guide

20155208 Xu Zihan 2016-2017-2 "Java Programming" 9th Week study 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.