Updating clob column in oracle with CLOB value

i want to update a column is CLOB type, the method is below;

public boolean formVeriGuncelleSil(String sql) throws VeritabaniException {
        try {
            Session session = getSessionFactory().getCurrentSession();
            SQLQuery query = session.createSQLQuery(sql);
            query.executeUpdate();
            return true;
        } catch (RuntimeException e) {
            throw new VeritabaniException(e, VERIGUNCELLEMEEXCEPTION, "FID_01_02_01");
        }
    }

The sql string;

UPDATE K1FORM_LISTGRID3 SET TEXTAREA4=oracle.sql.CLOB@77df8d, TEXTT5='ANAFORM',ANATABLO='1', OLUSTURAN_KULLANICI='184' WHERE ID=1

i get "java.sql.SQLSyntaxErrorException: ORA-01729: database link name expected" error

How can i fix this sql. Pls help.

Answers


Oracle is interpreting this SQL

SET TEXTAREA4=oracle.sql.CLOB@77df8d

as a database link because of the @ symbol, but it does not matter anyway, because all you're doing here is trying to set the value of the column to the toString of the CLOB, which is not what you intend.

Your code sample does not really outline where the problem is because the method is just a general utility to execute the passed SQL, but I suggest 1 of 2 things:

  1. Go with GriffeyDog's suggestion and switch to using a PreparedStatement where you bind the CLOB using PreparedStatement.setClob.
  2. If you are using the Oracle 11g+ JDBC driver, you can set the value of a CLOB column using a simple Java String.

Need Your Help

How to make an Asynchronous Method return a value?

c# asynchronous

I know how to make Async methods but say I have a method that does a lot of work then returns a boolean value?

edit XML with simpleXML

php xml simplexml

How can I edit the value's in a xml file using simpleXML ?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.