可以告诉我修改用户密码的代码是怎样写的吗

解决方案 »

  1.   

    try{
            String strurl="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\SQL\\db.mdb";//你的ACCESS文件位置
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection conn=DriverManager.getConnection(strurl);
            Statement stmt = conn.createStatement(); 
            String strSQL = "Update User set password='11' where ID='1'"; //User是用户表名,password是密码字段名
            stmt.executeUpdate(strSQL); 
            conn.close();
            } 
            catch(Exception e)
            {
             System.out.println("连接失败!");
                e.printStackTrace();
            }
      

  2.   

    Class.forName("net.sourceforge.jtds.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/数据库名","user","pwd");
    con.prepareStatement("update 表名 set pwd=? where name=?");
    con.setString(1,"新的密码");
    con.setString(2,"用户名");
    con.executeUpdate();
      

  3.   

    也是做课设吧。
    做个界面,把输入框里的值拿出来。
    连上sql数据库,用个update语句就可以实现了。最好是自己想想,其实不难的。
    如果实现没办法。我可以给你发源码。