20165330 2017-2018-2 "Java Programming" 7th Week study Summary

Source: Internet
Author: User

Tag: equals start direct Query driver img Character init

Textbook Knowledge Summary 11th chapter JDBC and MySQL Database
    • Install XAMPP software and start MySQL
    1. Download Link: XAMPP
    2. Installation steps: Refer to Tutorial xampp Beginner Learning Guidelines (Windows sample)
    3. Start MySQL: Open the system cmd command and go to the MySQL bin directory
      • Initialization: Mysqld--initialize-insecure
      • Start: Mysqld or Mysqld-nt
      • Modify root user password: mysqladmin-u root-p password
    • Connecting to a database
    1. Download Jdbc-mysql Database Driver
    2. Load Jdbc-mysql Database Driver
    3. Connecting to a database
Connection getConnection(java.lang.String,java.lang.String,java.lang.String)Connection getConnection(java.lang.String)
    • Query operations
    1. Sending SQL query statements to the database
try {  statement sql=con.createStatement();}catch(SQLException e) {}
    1. Sequential query
      • Use the next () method to move to the next data row
      • The move succeeds returns True, otherwise returns false
    2. Condition and sort Query
      • Where Child statement: Select field from table name where condition
      • Sort: Sort records with an order by child statement
select * from mess order by heightselect * from mess where name like ‘%林%‘ order by name
    1. Generic query: Use a result set returned to a program to get related information
    • Update, add, and delete operations
    1. Update: The update table SET field = new value where < conditional clauses >
    2. Add: INSERT into table (field list) values (corresponding specific records)
    3. Delete: Delete from table name where < conditional clauses >
    • Preprocessing statements: Wildcard characters can be used instead of the value of a field
    • JDBC Transaction processing
    1. Turn off autocommit mode with the Setautocommit (Booean B) method
con.setAutoCommit(false);sql = con.createStatement();
    1. Handling transactions with the commit () method
    2. Handling transaction failures with the rollback () method: Undo the operations done by the firm
Problems encountered and their solutions
    1. Tomcat download was unsuccessful while installing XAMPP

      Solution: Surf the Internet a lot of did not understand, I uninstall re-download and restart the computer, found that the download was successful

    2. Occurs when input 127.0.0.1来 enters Xampp

      After looking at the classmate's blog to find, as long as the URL is changed to Http://localhost/phpmyadmin can be directly into the

    3. Running code in a virtual machine is encountered

      Workaround: 1. Download mysql, input sudo apt-get install Mysql-server mysql-client 2. Locate the directory where MySQL is located:/var/lib/mysql 3. Start Mysql:mysql Start

Code Hosting

Fifth week of the wrong title summary
    1. Parsing: C: Class variables and class methods cannot be declared in the class body of an inner class.

    2. Parsing: For serious errors, described by the error class, and for non-serious problems, it is described by the exception class.

    3. Parsing: Item B: The finally code block defines code that is bound to execute, which is typically used to close a resource. For the exception of the part, if not done finally, then the program is flawed, each call to the resources and then release the resources is necessary, otherwise the operating pressure will be particularly large.

    4. Parsing: The file class does not involve read and write operations on files.

    5. Analysis: Through the query API, the above are the method of constructing the file class.

    6. Parse: public int hashcode (): Computes the hash code for this abstract pathname.

    7. Parsing: InputStream is the parent class.

    8. Parse: The file specified by the parameter name is called the destination of the output stream.

    9. Parse: A to exchange space for time.

Week Six
    • Due to time estimation errors and mobile phone problems, although the answer has been completed, but in the final submission of the missed submission time, so failed to submit the answer on time, there is no error correction, the following only by the impression of the wrong question:
    • 1: The following statement about the math class, the right thing is
      A. public static double CBRT (double A) returns the cube root of a double value. If the argument is Nan, the result is Nan.
      B. public static double cos (double A) returns the trigonometric cosine of the angle. If the argument is Nan or infinity, the result is Nan.
      C. public static double floor (double a) returns the largest (closest to positive infinity) Double value, which is less than or equal to the parameter and equals an integer. If the argument is Nan or infinity, the result is Nan.
      D. public static double log10 (double A) returns the logarithm of the base 10 of the double value. If the parameter is positive 0 or minus 0, then the result is negative infinity.

Answer: ABD Answer: Query API. C: If the parameter is NaN, infinity, positive 0, or negative 0, then the result is the same as the parameter.

    • 2: Which of the following statements is correct for the following code?
      public class E {
      public static void Main (String args[]) {
      String S1 = args[1];
      String s2 = args[2];
      String s3 = args[3];
      System.out.println (S3);
      }
      }
      A. A compilation error has occurred in the program.
      B. No compile error, execute program at command line: "Java E I love this game", program output this.
      C. No compile error, execute program at command line: "Java E let us go", program no run exception.
      D. No compile error, execute program at command line: "java E 0 1 2 3 4 5 6 7 8 9" program output 3.

Answer: D

    • 3: Which of the following statements is wrong?
      A. The value of "9dog". Matches ("\ddog") is true.
      B. "12hello567". ReplaceAll ("[123456789]+", "@") the returned string is @[email protected].
      C. New Date (1000) object contains time of 1000 hours after A.D.
      D. "\hello\n" is the correct string constant.

Answer: C

20165330 2017-2018-2 "Java Programming" 7th Week study Summary

Related Article

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.