I am getting ORA-00911 error when inserting a value into CLOB object. Does anybody have any idea what the problem or solution is to the below code. Thanks for all the help.
-----------------------------------------------------------------------
import java.util.*;
import java.sql.*;
import java.lang.* ;
import java.io.ByteArrayInputStream ;
import oracle.jdbc.driver.*;
import oracle.jdbc.* ;
public class TestClob {
public TestClob () {
getConnection() ;
}
public void getConnection(){
java.util.Properties props = new java.util.Properties();
props.put("user", "scott");
props.put("password", "tiger");
try
{
java.sql.Driver d = (java.sql.Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
java.sql.Connection conn = d.connect("jdbcracle:thin:@server.com:1521:instance", props);
PreparedStatement stmt = conn.prepareStatement(
"insert into TESTCLOB ( col1, clobcol )" +
" values ( 'hello', ? ); "
);
int index = 1 ;
String xml = new String("Big XML Document") ;
stmt.setAsciiStream(index++, new ByteArrayInputStream( xml.getBytes() ), xml.length() );
// stmt.setBinaryStream(index++, new ByteArrayInputStream( xml.getBytes() ), xml.length() );
stmt.executeUpdate();
stmt.close();
}
catch (SQLException e) {
System.out.println ( "SQLexception " + e ) ;
}
catch ( IllegalAccessException ie ) {
System.out.println ( "IllegalAccessException " + ie ) ;
}
catch (InstantiationException iie) {
System.out.println ( "InstantiationException " + iie ) ;
}
catch (ClassNotFoundException cn) {
System.out.println ( "ClassNotFoundException " + cn ) ;
}
return ;
} // end of getConnection
public static void main ( String[] args ) {
TestClob tc = new TestClob();
} // end of main
}