Database -- MySQL --> Java, database mysqljava
MySQL
MySQL is a relational database management system developed by MySQL AB in Sweden. It is currently a product of Oracle. MySQL is one of the most popular Relational Database Management systems. In terms of WEB applications, MySQL is the best RDBMS (Relational Database Management System) application software.
MySQL is a relational database management system. Relational databases store data in different tables, rather than placing all data in a large warehouse. This increases the speed and flexibility.
The SQL language used by MySQL is the most common standard language for accessing databases. MySQL adopts the dual Authorization Policy, which is divided into community edition and commercial edition. because of its small size, fast speed, and low total cost of ownership, especially open source code, generally, MySQL is used as the website database for the development of small and medium websites.
Show command 1. display the Database List. Show databases; 2. display the data table in the database: use mysql; // open the database 3. display the data table structure: describe table name; 4. database creation: create database name; 5. table creation: use Database Name; create table Name (field setting list );
CREATE TABLE table_name (column_name column_type);
6. database deletion and table deletion: drop database name; drop table name; 7. clear records in the Table: delete from table name; 8. displays the records in the Table: select * from table name;
Install and use MySQL
I personally recommend a database of version 5.7, which is suitable for various computer problems. MySQL cannot be installed and I will search for installation tutorials online.
Demo of using Java to operate MySQL database code:
Public class Mysql {static String DBDORIVER = "com. mysql. jdbc. driver "; // It is the local MySQL database: localhost: 3306. The installation is generally 3306. If it is changed, it is not. myta is the database name, others are almost the same static String DBURL = "jdbc: mysql: // localhost: 3306/myta? UseUnicode = true & characterEncoding = UTF-8 "; static String DBName =" root "; // login username static String DBPwd =" 123456 "; // login password static Connection conn = null; public void getConnection () {try {Class. forName (DBDORIVER); // load the driver and connect to the jdbc conn of MySQL = DriverManager. getConnection (DBURL, DBName, DBPwd); // connect to the database System. out. println ("Link succeeded"); Statement stmt = conn. createStatement (); // create a Statement object, which is a database interface String SQL = "select * from mytable"; ResultSet rset1_stmt.exe cuteQuery (SQL ); // put the search result into the result set while (rSet. next () {// traverse the result set System. out. println (rSet. getString (1) + "\ t" + rSet. getString (2); // output each data at a time} catch (Exception e) {// TODO: handle exception System. out. println (e. getMessage () ;}} public static void main (String [] args) throws SQLException {Mysql mysql = new Mysql (); // create an object mysql. getConnection (); // call the getConnection method }}