1. Connect to database 1.1 download install driver
Java accesses the MySQL database through JDBC (Java database Connectivity,java connection). The JDBC programming interface provides interfaces and classes to connect to the MySQL database, and then processes the results of the SQL statement execution.
1) Download MySQL connector/j driver
http://dev.mysql.com/downloads/file/?id=460363
2) myeclipse import JDBC Driver
window| Perference path| User Libraries New library file: Mysql-jdbc Add JARs
Right-click the project name Build Path, ADD Library, User Library, Next, select Mysql-jdbc
1.2 Connecting to MySQL Database
There are drivermanager classes, connection interfaces, statement interfaces in the java.sql package, ResultSet interface DriverManager class: Managing Drivers and connecting databases connection interfaces: Managing established database connections statement interfaces: Executing SQL statements resultset interfaces: Storing records returned by the database
1) Specify the type of JDBC driver using forname () in the Java.lang.Class class
2) Connect to the database using the DriverManager class and the connection interface
2. Manipulating the database
1) Create statement object
2) Querying data using the SELECT statement
3) Insert Update or delete data
4) Execute arbitrary SQL statements
5) Close the created object
3. Backing up and restoring Databases
1) Backup
MySQL Getting started is simple: Java accesses MySQL database