这是我的java代码。 我使用的是wildfly 10.0.0和java 1.8以及oracle 12c。
'https://svn.mycompany.com/rcs-sh/trunk/src/source_code_1.pl'
当我调用函数getCellValue时,我得到了这样的错误。
public void getCellValue(){ PreparedStatement pstat = getConnection().prepareStatement("select empty_clob() from dual"); resultSet = pstat.executeQuery(); resultSet.next(); DatumWithConnection datum = (DatumWithConnection) resultSet.getClob(1); OracleConnection oconn = datum.getOracleConnection(); } public Connection getConnection() { InitialContext ic = new InitialContext(); this.mDataSource = ((DataSource)ic.lookup(lookupName)); this.mConnection = this.mDataSource.getConnection(); return this.mConnection; }
oracle.sql.DatumWithConnection
如何修复此错误? 感谢您的观看。
答案 0 :(得分:0)
以下代码可以使用
public class MyTest
{
public static void main(String[] args) throws SQLException {
MyTest test1 = new MyTest();
oracle.jdbc.internal.OracleConnection conn = test1.getConnection();
test1. getCellvalue(conn);
}
private void getCellvalue(Connection dbConnection) throws SQLException {
PreparedStatement pstat = dbConnection.prepareStatement("select empty_clob() from dual");
ResultSet resultSet = pstat.executeQuery();
resultSet.next();
DatumWithConnection datum = (DatumWithConnection) resultSet.getClob(1);
OracleConnection oconn = datum.getOracleConnection()
}
private oracle.jdbc.internal.OracleConnection getConnection() throws SQLException {
String url = "jdbc:oracle:thin:@host:port/service_name”;
OracleDataSource ds = new OracleDataSource();
Properties prop = new Properties();
prop.setProperty("user","scott");
prop.setProperty("password","tiger");
ds.setConnectionProperties(prop);
ds.setURL(url);
oracle.jdbc.internal.OracleConnection conn =
(oracle.jdbc.internal.OracleConnection)ds.getConnection();
return conn;
}
}
也许使用resultSet.getCLOB而不是resultSet.getClob。