地铁计费器
作者:互联网
1.设计一个简易的地铁计费系统
乘坐地铁需要记录乘坐时间,离开时间,费用扣款,并且显示详细的信息
2.(乘坐编号,kaishi乘坐时间,Onuse是否使用)
数据库连接代码:`
package wbsys.entity;
import java.sql.*;
public class Lianjie {
private String DBDriver;
private String DBURL;
private String DBUser;
private String DBPass;
private Connection conn = null;
private Statement stmt = null;
public Lianjie() {
DBDriver = “com.mysql.cj.jdbc.Driver”;
DBURL = “jdbc:mysql://localhost:3306/rj2018?serverTimezone=UTC&characterEncoding=utf-8”;
DBUser = “root”;//用户名
DBPass = “1234”;
try {
Class.forName(DBDriver);
} catch (Exception e) {
e.printStackTrace();
}
try {
conn = DriverManager.getConnection(DBURL, DBUser, DBPass);//取得连接对象
stmt = conn.createStatement();//取得SQL语句对象
} catch (Exception e) {
e.printStackTrace();
}
}
public Connection getMyConnection() {
return conn;
}
public Statement getMyStatement() {
return stmt;
}
public void closeMyConnection() {//关闭数据库连接
try {
stmt.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public String toString() {
return “数据库驱动程序” + DBDriver + “,链接地址” + DBURL + “,用户名” + DBUser + “,密码” + DBPass;
}
public Connection con() {
Connection con = null;
try {
con = DriverManager.getConnection(DBURL, DBUser, DBPass);
} catch (SQLException e) {
e.printStackTrace();
}
return con;
}
}
计应192(西)
7组
程腾飞
标签:DBURL,String,private,地铁,DBUser,public,conn,计费器 来源: https://www.cnblogs.com/7930li/p/14632790.html