头图

introduction

I have learned four articles about Java before, which can be regarded as a basic route and the division of important and difficult points. Next, we will enter the real Java back-end development journey, let's go!

Java reflection

java反射知识导图

The content of this section is not much, but it is also very important. Although it may not be used frequently in development, it is often looking at the source code . In actual development, some scenarios will also be encountered, so master this section The content will help you advance!

By studying the content of the previous chapters, you should be familiar with the structure of a class (Class), then the reflection provides the corresponding API to call, such as the commonly used reflection object above figure, and master their writing and Calling method, and try to write a class to reflect, experience this process. The way to get the Class object will be used below.

JDBC

JDBC知识导图

If you are a computer major, you may have been in contact with SQL Server in university, then you JDBC . At least I have heard that the code will not be written, so I will tell you next.

The knowledge we have learned before is all at the basic operation level, and the content to be learned next is complete systematization, for example: your WeChat avatar has been modified, and the avatar is still modified after changing your phone, then Where is your avatar stored? This is the database-related knowledge we are going to learn. By now you should understand that the original avatar is stored in the database. Whether you log in to WeChat on a mobile phone or a computer, your avatar will be fetched from the database, so all 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, query).

So, common databases ?

  • SQL Server
  • MySQL: a typical relational database, commonly used in Java development
  • NoSQL
  • DB2
  • Postgre SQL
  • Oracle

process

As shown in the figure above, a complete JDBC process (principle) is divided into four steps

  1. Load the driver
  2. Establish a link with the database
  3. Execute SQL
  4. Release resources

In actual development, these low-level steps are hardly our turn to write by ourselves. On the one hand, a world-class large company open source framework (database connection pool) has done this work; on the other hand, your company has great talents. , This work has been done a long time ago. But we still need to understand, because the interview may need to ask you (because only if you answer, the interviewer can rest assured that you have really learned Java, haha).

For each of the above processes, there are corresponding APIs, and the exposed APIs may be different after different frameworks are encapsulated. All these require us to adapt to changes and continue to learn.

database connection pool is widely used. One of the most widely used is DRUID (download address: https://github.com/alibaba/druid ), which is open sourced by the large domestic manufacturer Ali. For specific usage tutorials, please refer to the official documents.

Read the official documents to learn the usage of the framework, look at the source code of the framework to learn programming ideas, we will continue this road!

Install MySQL

Download: https://dev.mysql.com/downloads/installer/

Installation: basically all the way to next, if you encounter execute, click execute first

Test whether the installation is successful: open MySQL 8.0 Command Line Client , enter the password you set during installation, and press Enter to see a message similar to the following, indicating that the installation is successful.

MySQL安装成功

SQL is a particularly important content. There is no Java backend that does not know SQL. In fact, it is relatively simple. You can understand it as a small and unique language. Here are some basic content.

Regarding databases, there are many types and different usage scenarios. Most small and medium-sized Internet companies use MySQL.

View MySql version

mysql -uroot -proot command line. If the following prompt appears, the installation is successful. ( -u is followed by the user name, -p is 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 will be much less than the operation of the table in the database. In actual development, if you are not responsible for the creation of the library and the table, then it is rarely used. Generally, you can create it only by the administrator. Of course, many people like it. Use the graphical interface to create, the following are commonly used commands, tools, generally Navicat use more.

1. Create a database

create database 数据库名字;

2. Create a database and specify the encoding method

create database 数据库名字 character set utf8;

3. View all databases

show databases;

4. View the creation of a database

show create database 数据库名字;

5. Modify the database

alter database 数据库名字 character set 字符集;

6, delete the database

drop database 数据库名字;

7, select a database

use 数据库名字;

8. View the database currently in use

select database();

Summarize

The content of this section has entered the Java back-end development. Database and table related operations are essential skills. The next section will focus on learning about the operation of tables in the database. It is a very important content. Hurry up and keep up with the rhythm and start the Java journey. !

The editor specially created a public : 1618361d9a93e5 recommended to learn java, will share java , and focus on originality, wechat search attention (if you follow, you will send the fine video tutorial selected by the editor), and learn Java together!

code小生
165 声望18 粉丝