In a whole program of java, the JDBC, a.k.a JAVA DataBase Connectivity is a problem that cannot be avoided. So today I will integrate something about the JDBC based on the the programe hotelmanagement.
Firstly: The format in the class: JDBC
Secondly: The produce and extract of documents .sql
Section1:
The following is the codeblock about the package in the program:
package db;
import java.sql.*;
public class JDBC {
public static Connection getConnection() throws Exception {
String driverName = "com.mysql.jdbc.Driver"; //加载JDBC驱动
String dbURL = "jdbc:mysql://localhost:3306/hotel"; //链接服务器
String userName = "root"; //navicat中设置的用户名
String userPwd = "123456"; //nabicat中设置的密码
Class.forName(driverName);
return DriverManager.getConnection(dbURL, userName, userPwd);
}
public static void main(String args[]){
}
}
generally there should be a statement about “Conn get statement or prepareStatement object for sql operation”
Section2: The produce and extract of documents .sql .
produce:
step1: open the “navicat for mysql”
step2: right click the database you’d like to produce a .sql document
step3: click the " dump a SQL document"
step4: choose the path and run
extract:
step1: open the “navicat for mysql”;
step2: new a new database in the navicat
step3: open the new database
step4: right click the new one and click the button"run the sql document"
step5: choose the path of the sql document which you would like to extract
step6: right click the block and refresh the database
integration-integrate整合
extract提取