提供微网站建设营销方式和手段
驱动forName,创建连接对象getConnection要三个参数,执行String sql = "INSERT INTO等",创建执行SQL语句的PreparedStatement对象进行setString,然后执行preStmt.executeUpdate();
为什么要preStmt = conn.prepareStatement(sql);conn = DriverManager.getConnection(url, username, password);
因为getConnection是静态字段,prepareStatement是一个创建一个对象的方法,相当于以下Statement stmt = new Statement(conn);
带有参数我们就要给参数进行赋值
example03
肯定不能每一个都next,我们可以设置可以滚动和只读
rs.absolute(2); 获取具体行号数据
因为我们的ResultSet可以滚动
其他测试
用到user,JDBCutil,usersDao
user映射的用户
JDBCutil连接数据库的工具类初始化,释放的资源,不需要声明因为在userDao里面每次都会调用JDBCUtils.getConnection();
usersDao对数据库的增删改查,connection一下,Statement对象,进行赋值]查询所有数据同样connection,Statement,查询,滚动每一行,find()查询指定where id=" ",delete(int id)一样,要有返回影响的条数
JdbcInsertTest.java首先声明一个我们zsgc的userdao对象,声明一个User对象