Part I: Experimental projects
Item One: Random photo display. Objective: To understand the generation of random numbers and the display of pictures. Goal:
(1) On the basis of existing code, complete the random (or sequential) display of three pictures of the function.
(2) When guessing accurate, or error, pop-up dialog box to respond.
Item II: Preliminary database. Objective: To understand the steps and methods of Java connection database, as well as the installation and use of MySQL database. Objective: (1) The MySQL database is installed in the computer room. (2) Create data tables
(3) When the guess is correct, success+1 in the datasheet, failure+1 when the error is guessed.
Related courseware: 10th chapter: Database (Network disk download). Please practice database operations, familiar with the Java database Additions and deletions to check operations.
Part II: Job Blog Requirements1. In the Homework blog, use this week and 17 weeks Monday morning time, complete two projects, and the running results, code written to the blog.
2. In the Homework blog, answer the following four questions:
(1) Briefly describe the basic steps of connecting to a database in Java. The corresponding core class and code are respectively. ① load JDBC driver class.forname ("Com.mysql.jdbc.Driver"); ② Establish database connection {String uri= "jdbc:mysql://localhost/test";//test is the library name
Connection con=drivermanager.getconnection (URI, "root", "123"); ③ Create a Statement object Statement stmt = Con.createstatement (); ④ executes the MySQL statement ResultSet executequery (String sqlstring): Executes the SQL statement that queries the database, returns a result set (ResultSet) object ⑤ closes the JDBC object to release the resource rs.cl OSE (); Stmt.close (); Conn.close ();
(2) briefly describe the SQL statement in MySQL that creates a data table. CREATE table < table name >
(3) A brief description of what the core code of the random number between [1,53] is generated in Java.
Package Qiang;
Import Java.util.Random;
@SuppressWarnings ("unused") public
class FA {public
static void Main (String args[]) {
long Temp;
Temp = Math.Round (Math.random () * + 1);
System.out.println ("" + Temp);
}
(4) A brief description of what classes are in Java for reading and writing text files. What the core code is, respectively.
Fileinputstream/fileoutputstream