Mysql
MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently part of Oracle's product portfolio. MySQL is one of the most popular relational database management systems, and MySQL is the best RDBMS (relational database Management system) application software for WEB applications.
MySQL is a relational database management system, where relational databases store data in different tables rather than putting all of the data in a large warehouse, which increases speed and increases flexibility.
The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software has adopted a dual licensing policy, divided into community and commercial version, due to its small size, fast, low total cost of ownership, especially the open source, the development of the general small and medium-sized web site to choose MySQL as the site database.
Show Command 1. Displays the list of databases. Show Databases;2. Display the data table in the library: use MySQL;//Open Library 3. Display the structure of the data table: describe table name; 4. Build Library: Create database name; 5. Build table: Use library name, create table table name (field settings list);
(column_name column_type);
6. Delete Library and delete table: drop database name; drop table name; 7. Empty the records in the table: Delete from table name; 8. Show Records in table: SELECT * from table name;
MySQL installation is used
Personal comparison recommended 5.7 version of the database, this is more suitable for a variety of computer problems, can not install MySQL, more to the online search installation tutorial
Working with MySQL database in Java
- First, install the database.
- Import the MySQL jar package-->mysql-connector-java-5.1.13-bin.jar
- First create a folder, the jar package into which, generally named Lib;
- Right-click the jar package that appears click Build path--> click Add to build path, so the jar package import is completed
Code Demo:
Public classMysql {StaticString dbdoriver= "Com.mysql.jdbc.Driver"; //is the local MySQL database: localhost:3306, installation is generally 3306, the changed is not, Myta is the database name, the others are almost the same StaticString dburl= "Jdbc:mysql://localhost:3306/myta?useunicode=true&characterencoding=utf-8"; StaticString dbname= "root";//Log In User name StaticString dbpwd= "123456";//Log in Password StaticConnection conn=NULL; Public voidgetconnection () {Try{class.forname (dbdoriver);//load driver, connect MySQL jdbcConn=drivermanager.getconnection (DBURL,DBNAME,DBPWD);//connecting to a databaseSystem.out.println ("Link succeeded"); Statement stmt=conn.createstatement ();//Create an Statement object, which is an interface to the databaseString sql= "Select*from mytable"; ResultSet RSet=stmt.executequery (SQL);//put the results of the search into the result set while(Rset.next ()) {//Traverse this result setSystem.out.println (rset.getstring (1) + "\ T" +rset.getstring (2));//output each data at once } }Catch(Exception e) {//Todo:handle ExceptionSystem.out.println (E.getmessage ()); } } Public Static voidMain (string[] args)throwsSQLException {mysql MySQL=NewMysql ();//Creating ObjectsMysql.getconnection ();//calling the Getconnection method }}
Database--mysql-->java article