feat:统一数据库信息

pull/5/head
you 4 years ago
parent 39f9a17500
commit a365d03097

@ -93,9 +93,9 @@
下载压缩包,或者使用`git clone`下载(使用`git checkout maven`可以更换为分支maven其使用maven进行依赖管理更便于运行部署
将**library.sql文件导入mysql数据库**,并需要修改以下两个数据库连接相关属性(数据库账号密码、数据库表名)
将**library.sql文件导入mysql数据库**,并修改以下文件的数据库连接相关属性(数据库账号密码、数据库表名)
![](https://ming-edu.oss-cn-beijing.aliyuncs.com/image-20201117122227215.png)
![](https://ming-edu.oss-cn-beijing.aliyuncs.com/1630034271536.png)
# 三、项目演示

@ -7,10 +7,10 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class Base {
private static String driver = "com.mysql.cj.jdbc.Driver";
private static String url = "jdbc:mysql://localhost:3306/library?&useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8";
private static String username = "root";
private static String password = "root";
private static final String driver = DBConstants.driver;
private static final String url = DBConstants.url;
private static final String username = DBConstants.username;
private static final String password = DBConstants.password;
/**
*

@ -0,0 +1,8 @@
package javabean;
public class DBConstants {
public static final String driver = "com.mysql.cj.jdbc.Driver";
public static final String url = "jdbc:mysql://localhost:3306/library?&useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8";
public static final String username = "root";
public static final String password = "root";
}

@ -6,10 +6,10 @@ import java.sql.ResultSet;
import java.sql.Statement;
public class JDBCBean {
private static String driver = "com.mysql.cj.jdbc.Driver";
private static String url = "jdbc:mysql://localhost:3306/library?&useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8";
private static String username = "root";
private static String password = "root";
private static final String driver = DBConstants.driver;
private static final String url = DBConstants.url;
private static final String username = DBConstants.username;
private static final String password = DBConstants.password;
private Connection conn = null;
private Statement stmt = null;

Loading…
Cancel
Save