Advertisement

JDBC中executeQuery、executeUpdate及执行的不同作用

阅读量:

executeQuery executeUpdate execte
属于Statement接口所定义的 三种功能函数 ,换句话说,这三项功能之间具有并列关系

1) executeQuery方法
主要用于执行select类型的查询操作,其执行结果(即查询所得数据)将被封装至ResultSet对象中,最终生成单一的结果集。

复制代码
    //加载驱动
     Class.forName("com.mysql.cj.jdbc.Driver");
            //数据库名test
            String url = "jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8";
            //数据库用户名
            String user=" 用户名   ";
            //密码
            String password=" 密码  ";
            //建立好Java链接MySQL的通路
            Connection connection = DriverManager.getConnection(url,user,password);
            //在通路上建立一个车

全部评论 (0)

还没有任何评论哟~