当前位置: 技术问答>java相关
有关结果数据集的修改-java和ORACLE数据库
来源: 互联网 发布时间:2015-09-19
本文导语: 我下载并安装了CLASS12.ZIP到CLASSPATH下,可还是不能进行数据集的更新,到底还差在哪里,请指教.下面程序运行到 results.updateString("first_name",firstName.toUpperCase()); 就抛出例外说数据集已被占用. Class.forName("oracle.jdbc.driver.OracleD...
我下载并安装了CLASS12.ZIP到CLASSPATH下,可还是不能进行数据集的更新,到底还差在哪里,请指教.下面程序运行到
results.updateString("first_name",firstName.toUpperCase());
就抛出例外说数据集已被占用.
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@sanjing:1521:yxdba",
"j2eeuser", "j2eepass");
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
stmt.executeQuery("select * from Person");
ResultSet results = stmt.getResultSet();
while (results.next())
{
String firstName = results.getString("first_name");
String lastName = results.getString("last_name");
results.updateString("first_name", firstName.toUpperCase());
results.updateString("last_name", lastName.toUpperCase());
results.updateRow();
}
conn.close();
results.updateString("first_name",firstName.toUpperCase());
就抛出例外说数据集已被占用.
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@sanjing:1521:yxdba",
"j2eeuser", "j2eepass");
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
stmt.executeQuery("select * from Person");
ResultSet results = stmt.getResultSet();
while (results.next())
{
String firstName = results.getString("first_name");
String lastName = results.getString("last_name");
results.updateString("first_name", firstName.toUpperCase());
results.updateString("last_name", lastName.toUpperCase());
results.updateRow();
}
conn.close();
|
stmt.executeQuery("select * from Person");
-------查询表在oracle中应该在表名前加用户名
sample: select * from scott.Person
我想你知道scott的意思把。与你的程序相应的改一下
-------查询表在oracle中应该在表名前加用户名
sample: select * from scott.Person
我想你知道scott的意思把。与你的程序相应的改一下
|
在最后,记录集和stmt要关闭。