Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PreparedStatement.setString() cannot update "text" datatype

121 views
Skip to first unread message

Ray

unread,
Jan 21, 2010, 1:26:30 PM1/21/10
to
Hi,

I use Sybase ASE 12.5.3 and a table with text data field, "email_body".

However, when I use JConnect to add data to this field, I use
PreparedStatement.setString(2, content)
to add string data into this field. But I found only NULL is found in this
field.

Actually, I tried this before and it should work. I do not know why it
becomes not working now...

I am really confused now...what should I do to fix this? Can anyone help me?

Thanks,
Raymond


Ray

unread,
Jan 21, 2010, 11:16:30 PM1/21/10
to
Hi,

I found that when saving a "simple" long string with
PreparedStatement.setString(2, content)
into a "text data type. Then the JDBC method should be fine without any
problem found.

But when I need to save a long HTML which contains chinese characters in it,
then it seems
PreparedStatement.setString(2, content) works in the 1st time, then I try
2nd time,
it produces :

Attempt to insert NULL value into column 'email_body', table
t_doc_template'; column does not allow nulls.

Does anyone encounter such situration?

I am using thie JConnect version:

JDBC(TM)/6.05(Build 25828)/P/EBF13044/JDK14/Fri Sep 30 1:05:16 2005

Please kindly help,
Thanks,
Raymond

"Ray" <l...@hotmail.com> wrote in message news:4b589c56@forums-1-dub...

Ray

unread,
Jan 21, 2010, 11:37:20 PM1/21/10
to
All SQL statements are insert statment.

"Ray" <l...@hotmail.com> wrote in message news:4b59269e@forums-1-dub...

Ray

unread,
Jan 21, 2010, 11:41:40 PM1/21/10
to
After the exception "Attempt to insert NULL value into column 'email_body',
table
't_doc_template'; column does not allow nulls." occurred, then when
triggering
any statement, the JConnect will throws this exception:

Caught IOException: com.sybase.jdbc3.jdbc.SybConnectionDeadException: JZ0C0:
Connection is already closed.

It seems the connection is already dead.

"Ray" <l...@hotmail.com> wrote in message news:4b59269e@forums-1-dub...

Ray

unread,
Jan 22, 2010, 2:06:33 AM1/22/10
to
I already tried another latest JConnect 6.05 driver:

Database product version : Adaptive Server Enterprise/12.5.3/EBF 13325
ESD#7/P/Sun_svr4/OS 5.8/ase1253/1951/64-bit/FBO/Fri Mar 24 11:00:22 2006
[1/22/10 14:59:48:453 CST] 00000027 InternalSybas I DSRA8205I: JDBC driver
name : jConnect (TM) for JDBC (TM)
[1/22/10 14:59:48:453 CST] 00000027 InternalSybas I DSRA8206I: JDBC driver
version : jConnect (TM) for JDBC(TM)/6.05(Build 26573)/P/EBF17377/JDK14/Mon
Nov 16 6:40:09 2009

But it produces the same exception.

"Ray" <l...@hotmail.com> wrote in message news:4b592c84@forums-1-dub...

Ray

unread,
Jan 22, 2010, 2:08:01 AM1/22/10
to
I switch to use another update method but it does not fix the problem...

//stmt.setString(7, emailbody);
StringReader reader1 = new StringReader(emailbody);
stmt.setCharacterStream(7, reader1, emailbody.length());

Is it the limitation of JConnect 6.05 driver?

"Ray" <l...@hotmail.com> wrote in message news:4b594e79@forums-1-dub...

Paul Vero [Sybase]

unread,
Jan 25, 2010, 5:55:55 PM1/25/10
to
Hi Ray,

Check the jConnect samples - there should be a way
to do this. There are samples using AsciiStream and BinaryStream
as well as using the ASE text pointers (a good way to do it - but this has
potential to change or become antiquated
in the future).

If that doesn't help you should open a Tech Support case.

Thank you,

-Paul

"Ray" <l...@hotmail.com> wrote in message news:4b594ed1@forums-1-dub...

0 new messages