• 如何使用JBDC修改数据


    1.JDBC取得数据库Connection连接对象conn,

    Connection conn=null;   //数据库连接对象

    String strSql=null;    //sql语句对象

    //更新学生数据操作
        public void update(Student student) {
            PreparedStatement pstm=null;    //预编译接口对象
            try {
                strSql="update student set name=?,phone=?,stuNo=?,brithday=? where id=? ";    //根据更新需求SQL语句
                pstm=conn.prepareStatement(strSql);        //连接数据库活动,提交SQL语句

        //设置参数
                pstm.setString(1, student.getName());
                pstm.setString(2, student.getPhone());
                pstm.setString(3, student.getStuNo());
                pstm.setString(4, student.getBirthday());
                pstm.setInt(5, student.getId());

        //执行SQL语句
                pstm.executeUpdate();


                System.out.println("更新数据成功。。。。。。。。。"+strSql);

            } catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
            
        }

  • 相关阅读:
    JS的IE和FF兼容性问题汇总
    解决flash挡住层的问题
    javascript 代码优化工具 UglifyJS
    理解面向对象
    js中的等号与非等号
    js 的数据类型转换
    js优化 ----js的有序加载
    各浏览器对页面外部资源加载的策略
    js 执行效率
    脚本的加载,解析,与执行
  • 原文地址:https://www.cnblogs.com/TangGe520/p/8939969.html
Copyright © 2020-2023  润新知