20165308 Make up in class

20165308 Make up in class

1. Summary of relevant knowledge points:

  • Sequential query: that is, the ResultSrt object can only see one data row at a time, use the next() method to move to the next data row, and the initial query position of the next() method, that is, the cursor position, is located in front of the first row. The next() method moves the cursor down, and returns true if the move is successful, otherwise returns false.
  • Condition and sort query:
  • General format:
  • select field form table name while condition

    (1) Field value and fixed value comparison, for example:

  • selet name,height form mess where name=“李四”

    (2) The field value is in a certain range, for example:

  • select * form mess where height>1.60 and height<=1.8
    select * form mess where mess>1.7 and name !=“张山”

    (3) Use some special date functions, such as year, month, day:

  • select * form mess where year(birthday)<1980 and month(birthday)<=10
    select * form mess where year(birthday) between 1983 and 1986

2. Make up screenshots of homework in class:



3. Chapter 11 Code Analysis:

  • Example11_1

    The function of this code is to query all records in the message table in the student database.

  • Example11_2:

    This code is to encapsulate the database connection code into a GetDatebaseConnection class, and randomly query the two records of mess in the student database

  • Example11_3:

    The function of this code is to query the students with the surname Zhang in the message table, the height is higher than 1.65, the birth year is before 2000 or 2001, and the students are after July, and they are sorted by birth date.

  • Example11_4:

    The code is to insert two records into mess.

  • Example11_5:

    The code uses prepared statements to add records to the mess table and query the records of Zhang's surname.

  • Example11_6:

    The code passes the database name along with the SQL statement to an object of the Query class.

  • Example11_7:

    The code uses transaction processing to reduce the value of the height of R1001 in the number field of the message by n, and add the reduced n to the height of the field of R1002

  • Example10_8:

    The code uses the Derby database management system to create a database named student, and create a score table in the database

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324753560&siteId=291194637