You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian Munroe <br...@gmail.com> on 2008/04/17 19:37:54 UTC

CLOBs, Connection Pooling, Help!

Ok, I've searched and searched, but I cannot figure out the answer.  I
am using Tomcat container provided connection pooling; connecting to
an Oracle XE server and I need to insert a CLOB.  It would appear that
doing this task is dependent upon which RDBMS vendor you're working
with?

Can anyone help me understand what I need to do?  I've gotten this far:

import javax.naming.*;
import java.sql.*;
import javax.sql.*;
import oracle.jdbc.*;

// try/catch stuff omitted for example.

Context initContext = new InitialContext();
Context envContext  = (Context) initContext.lookup("java:/env/");
DataSource ds = (DataSource) envContext.lookup("jdbc/isms_messaging");
Connection conn = ds.getConnection();

sqlString = "insert into message_body (message_id,message_body) values (?,?)";

PreparedStatement insertMsgBodyRecord = conn.prepareStatement(sqlString);
insertMsgBodyRecord.setString(1,message.getMessageId());

// This is where things fall apart (setStringForClob
// is a Oracle PreparedStatement method) - which
// is wrong, but still

insertMsgBodyRecord.setStringForClob(2,message.toXML());

insertMsgBodyRecord.executeUpdate();
insertMsgBodyRecord.close();
conn.close();

thanks

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] CLOBs, Connection Pooling, Help!

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Brian,

(Marking off-topic as this is a JDBC thang, not a Tomcat one).

Brian Munroe wrote:
| I
| am using Tomcat container provided connection pooling; connecting to
| an Oracle XE server and I need to insert a CLOB.  It would appear that
| doing this task is dependent upon which RDBMS vendor you're working
| with?

It shouldn't.

| // This is where things fall apart (setStringForClob
| // is a Oracle PreparedStatement method) - which
| // is wrong, but still
|
| insertMsgBodyRecord.setStringForClob(2,message.toXML());

What's wrong with

insertMsgBodyRecord.setString(2, message.toXML());

??

If your "message" is too long to fit into a String object, how about:

insertMsgBodyRecord.setCharacterStream(2, reader, length);

??

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgHuQYACgkQ9CaO5/Lv0PBWkwCgmi0PjBhML2qVCIDl6hedjO99
ChEAnirZOMIVXoJ3RJ148NCFWxoEQdqQ
=Aags
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org