Update
This commit is contained in:
1 parent
34f68b1fe9
commit
ba46ad52f6
6 files changed
+18
-43
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,22 +4,20 @@ import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class PasswordChange {
|
||||
static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";
|
||||
private static final String DBDRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
private static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
Connection conn = null;
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class.forName(DBDRIVER);
|
||||
Connection conn = DriverManager.getConnection(DBURL);
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
conn = DriverManager.getConnection(DBURL);
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
System.out.print("请输入用户名:");
|
||||
String username = scanner.nextLine();
|
||||
String checkUserSql = "SELECT xingming FROM t_yong WHERE yonghuming=?";
|
||||
@@ -65,20 +63,9 @@ public class PasswordChange {
|
||||
System.out.println("您已成功修改密码,请谨记");
|
||||
else
|
||||
System.out.println("密码修改失败,请重试");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null)
|
||||
rs.close();
|
||||
if (pstmt != null)
|
||||
pstmt.close();
|
||||
if (conn != null)
|
||||
conn.close();
|
||||
} catch (SQLException se) {
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPasswordComplex(String password) {
|
||||
|
||||
@@ -9,12 +9,15 @@ import java.sql.SQLException;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class ProductAdditionAndInquiry {
|
||||
private static final String DBDRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
private static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class.forName(DBDRIVER);
|
||||
Connection conn = DriverManager.getConnection(DBURL);
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int choice;
|
||||
try (Connection conn = DriverManager.getConnection(DBURL)) {
|
||||
|
||||
do {
|
||||
System.out.println("===超市商品管理维护====");
|
||||
System.out.println("1、输入商品");
|
||||
@@ -37,9 +40,7 @@ public class ProductAdditionAndInquiry {
|
||||
System.out.println("无效选择,请重新选择(1-3):");
|
||||
}
|
||||
} while (choice != 3);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
conn.close();
|
||||
}
|
||||
|
||||
private static void addProduct(Scanner scanner, Connection conn) throws SQLException {
|
||||
|
||||
@@ -4,22 +4,20 @@ import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class UserLogin {
|
||||
static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";
|
||||
private static final String DBDRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
private static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
Connection conn = null;
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class.forName(DBDRIVER);
|
||||
Connection conn = DriverManager.getConnection(DBURL);
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
conn = DriverManager.getConnection(DBURL);
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int attempts = 0;
|
||||
boolean loginSuccess = false;
|
||||
while (attempts < 3 && !loginSuccess) {
|
||||
@@ -48,19 +46,8 @@ public class UserLogin {
|
||||
}
|
||||
if (!loginSuccess)
|
||||
System.out.println("最多只能尝试3次");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null)
|
||||
rs.close();
|
||||
if (pstmt != null)
|
||||
pstmt.close();
|
||||
if (conn != null)
|
||||
conn.close();
|
||||
} catch (SQLException se) {
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user