public static void admin_change()throws Exception //修改学生信息
{
Statement stmt = null;
ResultSet rs = null;
//声明Connection对象
Connection con;
//驱动程序名
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/sa?characterEncoding=utf-8";
String user="root";
String password="";
Class.forName(driver);
con = DriverManager.getConnection(url,user,password);
stmt = con.createStatement();
Scanner reader = new Scanner(System.in);
System.out.println("请输入您所要修改的学生的学号:");
String sno_before = reader.nextLine();
String sql = "select * from student where sno='"+sno_before+"'";
rs = stmt.executeQuery(sql);
boolean a = true;
if(rs.next())
{
while(a)
{
System.out.println("您可以有以下操作: ");
System.out.println(" 1、 修改学号");
System.out.println(" 2、 修改姓名 ");
System.out.println(" 3、 修改性别 ");
System.out.println(" 4、 修改年龄");
System.out.println(" 5、 修改班级");
System.out.println(" 6、 修改专业");
System.out.println(" 0、 返回上一步 ");
System.out.println("请输入您的选择:");
int chioce_change = Integer.parseInt(reader.nextLine());
String strsql = null;
switch(chioce_change)
{
case 1:
System.out.println("请输入您所要更改为:");
String sno_after = reader.nextLine();
strsql = "update student set sno = '"+sno_after+"' where sno = '"+sno_before+"'";
//此处不知错在何处。如何不使用异常处理。
try
{
stmt.executeQuery(strsql);
}
catch(Exception e)
{
;
}
System.out.println("修改成功!");
break;
各位帮忙看下在这段修改过后数据库里面的数据更新不了是什么问题