oracle 不支持 CONCUR_UPDATABLED 可更新ResultSet?

tempone 2005-11-10 10:54:57
oracle 不支持 CONCUR_UPDATABLED 可更新ResultSet?
我试过了,不论 Connection.createStatement() 怎么传参数
返回的 ResultSet 始终是 CONCUR_READONLY
清教有什么办法可以解决
...全文
134 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
liu_you 2005-11-11
  • 打赏
  • 举报
回复
楼上的代码可以检验是不是支持楼主所说的东西.
liu_you 2005-11-11
  • 打赏
  • 举报
回复
/**
* A simple sample to check the availability of scrollable result sets.
* Please compare to ResultSet2.java ~ ResultSet6.java
*
* Please use jdk1.2 or later version
*/

import java.sql.*;

public class ResultSet1
{
public static void main(String[] args) throws SQLException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());

String url = "jdbc:oracle:oci8:@";
try {
String url1 = System.getProperty("JDBC_URL");
if (url1 != null)
url = url1;
} catch (Exception e) {
// If there is any security exception, ignore it
// and use the default
}

// Connect to the database
// You can put a database name after the @ sign in the connection URL.
Connection conn =
DriverManager.getConnection (url, "hr", "hr");

// Get the metadata regarding this connection's database
DatabaseMetaData dbmd = conn.getMetaData();

// List all the possible result set types
int resultset_types[] =
{
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.TYPE_SCROLL_SENSITIVE
};

// List all the possible result set concurrency types
int concurrency_types[] =
{
ResultSet.CONCUR_READ_ONLY,
ResultSet.CONCUR_UPDATABLE
};

// List the result set type names
String resultset_types_msg [] =
{
"Forward only",
"Scroll insensitive",
"Scroll sensitive"
};

// List the concurrency type names
String concurrency_types_msg[] =
{
"Read only",
"Updatable"
};

// Check the availability of the result type and concurrency type
for (int i=0; i<resultset_types.length; i++)
{
for (int j=0; j<concurrency_types.length; j++)
{
int type = resultset_types[i];
int concurrency = concurrency_types[j];

System.out.println ("Type: "+resultset_types_msg[i]+" "+
"Concurrency: "+concurrency_types_msg[j]);
System.out.println
("----------------------------------------------------");

// Return true if the result set type is supported
System.out.println ("supportResultSetType: "+
dbmd.supportsResultSetType(type));

// Return true if the result set type and concurrency type is supported
System.out.println ("supportsResultSetConcurrency: "+
dbmd.supportsResultSetConcurrency(type, concurrency));

// Return true if the result set's updates are visible
System.out.println ("ownUpdatesAreVisible: "+
dbmd.ownUpdatesAreVisible(type));

// Return true if the result set's deletions are visible
System.out.println ("ownDeletesAreVisible: "+
dbmd.ownDeletesAreVisible(type));

// Return true if the result set's insertions are visible
System.out.println ("ownInsertAreVisible: "+
dbmd.ownInsertsAreVisible(type));

// Return true if other's changes are visible
System.out.println ("othersUpdatesAreVisible: "+
dbmd.othersUpdatesAreVisible(type));

// Return true if other's deletions are visible
System.out.println ("othersDeletesAreVisible: "+
dbmd.othersDeletesAreVisible(type));

// Return true if other's insertions are visible
System.out.println ("othersInsertsAreVisible: "+
dbmd.othersInsertsAreVisible(type));

// Return true if ResultSet.rowUpdated() is supported
System.out.println ("updatesAreDetected: "+
dbmd.updatesAreDetected(type));

// Return true if ResultSet.rowDeleted() is supported
System.out.println ("deletesAreDetected: "+
dbmd.deletesAreDetected(type));

// Return true if ResultSet.rowInserted() is supported
System.out.println ("insertsAreDetected: "+
dbmd.insertsAreDetected(type));

System.out.println ();
}
}

// Close the connection
conn.close();
}
}
King_Style 2005-11-11
  • 打赏
  • 举报
回复
代码贴来..........

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧