zoukankan      html  css  js  c++  java
  • 更新数据

    package cn.fly;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    
    import org.apache.log4j.Logger;
    
    /**
     * 更新数据
     * 
     * @author ASUS
     * 
     */
    public class uptate {
        private static Logger logger = Logger.getLogger(Test1.class.getName());
    
        public static void main(String[] args) {
            Connection conn = null;
            Statement stat = null;
            // 1.加载驱动
            try {
                Class.forName("com.mysql.jdbc.Driver");
            } catch (ClassNotFoundException e) {
                logger.error(e);
            }
            // 2.建立连接
            try {
                conn = DriverManager.getConnection(
                        "jdbc:mysql://localhost:3306/epet", "root", "root");
                // 更新狗狗信息到数据库
                stat = conn.createStatement();
                stat.executeUpdate("update dog set health=100,love=100 where id =1");
                logger.info("成功更新数据~~~");
            } catch (SQLException e) {
                logger.error(e);
            } finally {
                // 3.关闭连接
                if (stat != null) {
                    try {
                        stat.close();
                    } catch (SQLException e) {
                        logger.error(e);
                    }
                }
                if (conn != null) {
                    try {
                        conn.close();
                    } catch (SQLException e) {
                        logger.error(e);
                    }
                }
            }
        }
    }
  • 相关阅读:
    查看object信息
    Google C++单元测试框架之宏
    Google C++单元测试框架
    通过iscsi协议使用ceph rbd
    OpenStack+Ceph存储空间回收《转》
    IO
    golang之interface
    mysql 初始化
    ceph之ceph osd tree下的weight, reweight
    c++单元测试框架googletest
  • 原文地址:https://www.cnblogs.com/zwy0709/p/7920115.html
Copyright © 2011-2022 走看看