t(1,9999);//往第一列(第一个字段),添加值为9999
? ? ? ? 或者是 :?
? ? ? ? ? ? rs.updateInt("ID",9999);//或者是通过指定的列,添加值
?
? ? updateString :?
?
? ? ? ? updateString();//添加 (或更改)列(varchar2类型) 值
? ? ? ? rs.updateString(2, "youname");//第二列(第二个字段),添加值为"youname"
? ? ? ? 或者是 :?
? ? ? ? ? ? rs.updateString("ENAME", "youname");//通过指定的列,添加值
? ? insertRow :?
?
? ? ? ? insertRow();//把以上添加的新行和里面的内容,添加到结果集中,也添加到
数据库中
? ? ? ? rs.insertRow();//把上面设置的这一个新行,添加到结果集和
数据库中
?
? ? moveToCurrentRow :?
?
? ? ? ? moveToCurrentRow();//把光标移动到新建的行
? ? ? ? rs.moveToCurrentRow();//在rs结果集中,把光标移动到新建的行
?
? ? deleteRow :?
?
? ? ? ? deleteRow();//删除当前光标指向的行,结果集和数据库都删
? ? ? ? rs.deleteRow();//删除rs结果集中和数据库中,当前光标指向的行
?
//改 :?
?
? ? updateString :?
?
? ? ? ? updateString();////更改内存中数据集中的数据
? ? ? ? rs.updateString("hello", "hellonimei");//更改内存中数据集中的数据(列为hello,值为hellonimei)
?
? ? updateRow :?
?
? ? ? ? updateRow();//把更改的数据更新到数据库中
? ? ? ? rs.updateRow();//把更改更新到数据库中,是数据库哦
?
close :?
?
? ? close();//关闭资源 一般都是从下往上关闭
? ? ? ? 如 : 打开资源的时候,先打开conn然后是stmt然后是rs
? ? ? ? ? ? 关闭的时候就是先关闭rs在关闭stmt,在关闭conn
? ? ? ? // 1 驱动对象
? ? ? ? new oracle.jdbc.driver.
OracleDriver();
? ? ? ? // 2 连接对象
? ? ? ? Connection conn = DriverManager.getConnection(
? ? ? ? ? ? ? ? "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "c##scott", "root");
? ? ? ? // 3 传输对象
? ? ? ? Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);//并发可更新,和前面对比
? ? ? ? // 4 结果集对象
? ? ? ? ResultSet rs = stmt.executeQuery("select * from emp");
? ? ? ? rs.close();
? ? ? ? stmt.close();
? ? ? ? conn.close();