oracle - Clob column java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column -



oracle - Clob column java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column -

insertsql = "insert telbp_input_log (serial_no, input_xml) values (?, ?)"; statement = connection.preparestatement(insertsql); statement.setstring(1, serialno); statement.setstring(2, inxml); //statement.setstring(2, "test"); insertcount = statement.executeupdate();

when programme run executeupdate(), error

java.sql.sqlexception: ora-01461: can bind long value insert long column

is thrown, if re-create value of serialno , inxml , run in sql developer, no error prompted, reason?

oracle version:oracle database 10g enterprise edition release 10.2.0.4.0 - 64bi column: serial_no varchar2(22) input_xml clob websphere:websphere 5.1 jdbc: both ojdbc14 , ojdbc6 tried, both has same error

you cannot write string clob column.

instead of

statement.setstring(2, inxml);

use

statement.setclob(2, xmlclob);

you first need create xmlclob:

clob xmlclob = connection.createclob(); author clobwriter = myclob.setcharacterstream(1); clobwriter.write(inxml);

java oracle sqlexception

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -