I have learned four articles about Java, which is a basic route and division of key and difficult points. Next, I will enter the real journey of Java back-end development. Let’s go together!
This piece of content is not much, but it is also very important. Although it may not be often used in development, it is often used inLook at the source codeSome scenarios will be encountered in the actual development, so mastering the content of this section will help you advance!
By studying the contents of the previous chapters, you should be familiar with the structure of a class. Then the reflection provides the corresponding API to call, as shown in the figure aboveCommon reflection objects, master their writing and calling methods, and try to write a class to reflect and experience the process. And get
ClassThe method of object will be used below.
If you are a computer major, you may have met in college
SQL Server, so you’re right
JDBCIt won’t be strange. At least I’ve heard of it. The code won’t be written. It’s all right. I’ll tell you next.
All the knowledge we have learned above is at the basic operation level, and the content to be learned next is complete and systematic. For example, your wechat Avatar has been modified. After changing your mobile phone, your avatar is still modified, so youWhere is the avatar stored?This is the database related knowledge we need to learn. You should understand that the original avatar is placed in the database. Whether you log in to wechat on your mobile phone or computer, your avatar will be taken from the database, so you see the same avatar.
We are developers and users don’t care where the avatar is stored, so JDBC is to let us understand the principle and basic operation methods (add, delete, modify and query).
So,Common databasesWhat are there?
- SQL Server
- MySQL: a typical relational database, commonly used in java development
- Postgre SQL
As shown in the figure above, a complete process (principle) of JDBC is divided into four steps
- Load driver
- Link to database
- Execute SQL
- Release resources
In the actual development, these bottom steps can hardly be written by ourselves. On the one hand, the open source framework (database connection pool) of world-class large companies has done this work; On the other hand, you have a big cow in your company, which has already done a good job. But we still need to understand, because the interview may need to ask you (because only when you answer, the interviewer can rest assured that you have really learned Java, ha ha).
For each of the above processes, there is a corresponding API, and the API exposed after encapsulation of different frameworks may be different. We need to adapt and learn constantly.
Database connection poolOne of the most widely used is the open source of Alibaba, a large domestic manufacturer
https://github.com/alibaba/druid）, you can see the official documentation for the specific use of the tutorial.
Look at the official documents, learn the usage of the framework, look at the framework source code, and learn programming ideas. We will go on this road all the time!
Installation: you can basically go all the way to next. If you encounter execute, click execute first
Test for successful installation: open
MySQL 8.0 Command Line Client, enter
The password you set during installationPress enter to see the following information, which indicates that the installation is successful.
SQL is a particularly important content. There is no SQL in the Java back end. In fact, it is relatively simple. You can understand it as a small and unique language. Here are some basic contents.
There are many kinds of databases with different usage scenarios. Generally, small and medium-sized Internet companies mostly use mysql.
View MySQL version
Command line input
mysql -uroot -prootIf the following prompt appears, the installation is successful. (
-uFollowed by the user name,
-p(followed by the password)
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.5.27 MySQL Community Server (GPL) Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Common database operations
This part of the content is much less than the operation of tables in the database. In the actual development, if you are not responsible for the creation of libraries and tables, you rarely use them. Generally, you can create them only after the administrator opens the permission. Of course, many people also like to create them using the graphical interface. The following are common commands and tools, general
1. Create database
Create database database name;
2. Create a database and specify the encoding method
Create database database name character set utf8;
3. View all databases
4. View the creation of a database
Show create database database name;
5. Modify the database
Alter database database name character set character set;
6. Delete the database
Drop database database name;
7. Select a database
Use database name;
8. View the database currently in use
This section has entered the Java back-end development, and the operation of databases and tables is a necessary skill. The next section will focus on the operation of tables in the database, which is a very important content. Hurry to keep up with the pace and start the Java journey!
Xiao Bian has deliberately created a official account.
Recommend learning java, will share with
javaRelevant content, and mainly original, wechat search attention (pay attention to the high-quality video tutorial selected by Xiaobian immediately), and learn java together!