20165235 Qi Ying 2018-4 Java Programming Seventh Week study summary textbook learning content summary MySQL data management system
MySQL数据管理系统, short MySQL , is the world's popular data management system.
MySQLis a network database management system that enables a remote computer to access the database it manages.
Windows MySQL after downloading, go to Windows the command line, enter MySQL the directory to enter the bin file directory to --initialize-insecure MySQL data initialize. You can then bin re-enable it in the directory mysql MySQL . When enabled, you MySQL cannot end a process by closing the command line, and you Windows can use shortcut keys to end a process by using Task Manager on. shift+ctrl+Esc
- Can download the
Navicat software, this is a good MySQL client management tool (but to charge, I use the free version). Then follow the steps of the textbook to establish the link.
MySQLThe port is occupied 3360 . The host name can be written directly localhost . (Take the MySQL domain name or IP of the calculator where the server is located)
JDBC-MySQLDrivers can make Java connections between applications and MySQL databases.
- Programs commonly used
JDBC to do the following: 1. Establish a connection to a database. 2. Send the statement to the connected data path SQL . 3. Process SQL the returned results.
- Using a
JDBC- database-driven approach to establishing a connection with a database requires the following steps: 1. Load the JDBC- database driver. 2. Establish a connection to the specified database.
- Download the file on the MySQL official website
mysqld-connector-java-bin.jar and copy it to the jdk1.8/jre/lib/ext directory.
- Drive the JDBC code as follows:
try{ Class.forName("com.mysql.jdbc.Driver"); } catch(Exception e){}
To establish a connection after starting the JDBC driver, establish the connection code as follows:
connection con;String uri="jdbc:mysql://localhost:3306/students?useSSL=true";try{con= DriverManager.getConnection(uri,user,password);}catch(SQLException e){ }
If the user password is 123 available &password=改成&password=123 .
Query operations
- After establishing a connection with the database, you can use the API and database interaction information provided by JDBC, query, modify and so on.
Sending SQL statements to the database
try {statement sql =con.ctrateStatement();}catch(SQLException e){}
With the SQL object, you can invoke the appropriate method to implement the query operation of the data and store the query operations in the ResultSet object declared by the class. For example, the following code:
ResultSet rs = sql.executeQuery("SELECT*FROM student"),//此处我建立的数据库名为student
As the textbook Code query is the mess table:
rs=sql.executeQuery("SELECT * FROM mess");
One final step is to close the connection ascon.close()
Textbook Example11_1 Code test Operations and:
- This time I was in the
Windows dos command line under the database operation, so downloaded MySQL , the Navicat software, but also downloaded the JDBC- database driver mysqld-connector-java-bin.jar and to put this .jar file in the jdk1.8/jre/lib/ext directory. After completing these, follow the tutorial in the textbook to initialize the MySQL bin file directory under, data and enable MySQL , this is enabled MySQL :
- Establish a connection to the database and establish a
Navicat database named, student and create a mess table, such as:
- Then open another
dos command line, run the Example11_1.java file, and run the result as follows:
Problems in teaching materials learning and the solving process
- In this operation encountered a lot of problems
- Issue one: In the run
MySQL times the error is as follows:
- WORKAROUND: I downloaded to the file on the Internet
MSVCR120.dll and then copied to the directory under the system directory SysWOW64 , the results are still error, and then search the Web to download the repair program to repair it, and finally succeeded. As follows:
Code hosting 1 Code hosting 2
Last week's five-week error summary of the wrong question summary:
- 6. Calling a linear
interrupt() method throws: The CloseByInterruptException exception object
- 8. Custom exception classes can be more specific to determine the location of the error of the bit and give detailed error information.
-
FileInputStreamclass inherits from InputStream the ability to read files in bytes.
ByteArrayOutputStream(int size)the buffer default size is determined by size.
- A stream
BufferedWriter can point to a FileWriter stream.
javause throw the throws declaration method to throw an exception using the throw exception.
45. For a serious error, it is described by a class Error , and a very serious error is described by the Exception class.
Summary of six-week wrong questions:
- 6. Throws an exception if the specified object cannot be compared with the
set current element in the. ClassCastException \b\w{6}\bmatches exactly 6 characters of a word.
new Data(System.currentTimeMillis())equivalence andnew Date()
Sentiment
This time learning MySQL feel learned a lot of things, the database also has a lot of understanding. In the operation of the time will inevitably encounter some mistakes, it is important to try to solve, instead of relying on classmates, teachers (really can not solve is to teachers, students seeking help). And in the study of the database will use some SQL statements, learning SQL statements for the master MySQL database operation is also an important method. Because the last time did not finish the eighth chapter of the code, this time I fill in the code, the link to the code.
Learning progress Bar
|
lines of code (new/cumulative) |
Blog Volume (Add/accumulate) |
Learning Time (new/cumulative) |
Important Growth |
| Goal |
5000 rows |
30 Articles |
400 hours |
|
| First week |
31/31 |
1/1 |
20/20 |
The use of Git |
| Second week |
373/404 |
2/3 |
18/38 |
Java Basic Data syntax |
| Third week |
547/920 |
1/4 |
22/60 |
Classes and objects and packaging |
| Week Four |
919/1839 |
2/6 |
30/80 |
Subclass and inheritance, interface and interface-oriented programming |
| Week Five |
500/2300 |
3/9 |
20/100 |
Input and output streams and internal classes |
| Week Six |
300/2600 |
1/10 |
25/125 |
Generic and aggregate frameworks, common utility classes |
| Seventh Week |
447/3047 |
3/13 |
25/150 |
MySQL database and JDBC |
Resources
20165235 Qi Ying 2018-4 "Java Programming" Seventh Week study summary