问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bt2) {
new register();
this.dispose();
}
if (e.getSource() == bt1) {
{
String str1 = tf1.getText().trim();// 获取用户名文本框的文本信息
username = tf1.getText().trim();
String str2 = pwf1.getText();// 获取密码文本框的文本信息
if (!str1.matches(Regex.strRegex1)) {
JOptionPane.showMessageDialog(null, "用户名格式不正确,请重新输入(2-4个汉字)!");
this.dispose();
new Login();
} else if (!str2.matches(Regex.strRegex2)) {
JOptionPane.showMessageDialog(null, "密码格式不正确,请重新输入(6个数字)!");
this.dispose();
new Login();
} else {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
// String url="jdbc:mysql://localhost:3308/node";
String url = "jdbc:mysql://localhost:3308/node?useUnicode=true&characterEncoding=utf8";
Connection conn = DriverManager.getConnection(url, "root", "1234");
Statement stmt = conn.createStatement();////
ResultSet rs = stmt.executeQuery(
"select * from test where username='" + str1 + "' and password='" + str2 + "'");
运行结果及报错内容
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is
com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary