Tag: equals start direct Query driver img Character init
Textbook Knowledge Summary 11th chapter JDBC and MySQL Database
- Install XAMPP software and start MySQL
- Download Link: XAMPP
- Installation steps: Refer to Tutorial xampp Beginner Learning Guidelines (Windows sample)
- 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
- Download Jdbc-mysql Database Driver
- Load Jdbc-mysql Database Driver
- Connecting to a database
Connection getConnection(java.lang.String,java.lang.String,java.lang.String)Connection getConnection(java.lang.String)
- Sending SQL query statements to the database
try { statement sql=con.createStatement();}catch(SQLException e) {}
- Sequential query
- Use the next () method to move to the next data row
- The move succeeds returns True, otherwise returns false
- 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
- Generic query: Use a result set returned to a program to get related information
- Update, add, and delete operations
- Update: The update table SET field = new value where < conditional clauses >
- Add: INSERT into table (field list) values (corresponding specific records)
- 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
- Turn off autocommit mode with the Setautocommit (Booean B) method
con.setAutoCommit(false);sql = con.createStatement();
- Handling transactions with the commit () method
- Handling transaction failures with the rollback () method: Undo the operations done by the firm
Problems encountered and their solutions
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
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
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
Parsing: C: Class variables and class methods cannot be declared in the class body of an inner class.
Parsing: For serious errors, described by the error class, and for non-serious problems, it is described by the exception class.
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.
Parsing: The file class does not involve read and write operations on files.
Analysis: Through the query API, the above are the method of constructing the file class.
Parse: public int hashcode (): Computes the hash code for this abstract pathname.
Parsing: InputStream is the parent class.
Parse: The file specified by the parameter name is called the destination of the output stream.
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