Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Inserting into XmlType large docs

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-08-02, 16:22
mcbaran mcbaran is offline
Registered User
 
Join Date: Apr 2002
Posts: 1
Exclamation Inserting into XmlType large docs

I am trying to insert a large XML doc into an XMLType column in Oracle 9i using jdbc. I am having a problem because the size of the doc is over 4k. I have not been sucessful in inserting. However, I feel a good strategy is to treat the xmltype insert as a CLOB insert. I'm not sure if it will work???? Any suggestions would be greatly appreciated!

here is the code I have working with. The table is called xmltest and has 2 columns id number and peaklist xmltype.

try
{
con.setAutoCommit(false);

String sql1="insert into XMLTest (id,peaklist) VALUES(?,sys.xmlType.createXML(empty_Clob()))";

PreparedStatementps=con.prepareStatement(sql1);
ps.setInt(1,1);

ps = con.prepareStatement("SELECT * from xmltest where id = 1 FOR UPDATE");
rs=ps.executeQuery();
if(rs.next())
{
oracle.sql.CLOB myCLOB = (oracle.sql.CLOB)rs.getObject("peaklist");

java.io.Writer CLOBout = myCLOB.getCharacterOutputStream();
String XMLDoc = SparkyToXml.SparkyToXml(peakListLoc);
out.println("XMLDOC " + XMLDoc);
CLOBout.write(XMLDoc);
}

rs.close();
ps.close();
con.commit();
con.setAutoCommit(true);
}catch(Exception e) { out.println("error in 1 " + e);}



I am recieving a nullpointer exeception. Help!!!
__________________
Michael Baran
Center for Advanced Biotechnology and Medicine
Reply With Quote
  #2 (permalink)  
Old 01-23-03, 22:15
vamsi06 vamsi06 is offline
Registered User
 
Join Date: Jan 2003
Posts: 1
Re: Inserting into XmlType large docs

Did you find any solutions for this ? I am running into the same problem


Quote:
Originally posted by mcbaran
I am trying to insert a large XML doc into an XMLType column in Oracle 9i using jdbc. I am having a problem because the size of the doc is over 4k. I have not been sucessful in inserting. However, I feel a good strategy is to treat the xmltype insert as a CLOB insert. I'm not sure if it will work???? Any suggestions would be greatly appreciated!

here is the code I have working with. The table is called xmltest and has 2 columns id number and peaklist xmltype.

try
{
con.setAutoCommit(false);

String sql1="insert into XMLTest (id,peaklist) VALUES(?,sys.xmlType.createXML(empty_Clob()))";

PreparedStatementps=con.prepareStatement(sql1);
ps.setInt(1,1);

ps = con.prepareStatement("SELECT * from xmltest where id = 1 FOR UPDATE");
rs=ps.executeQuery();
if(rs.next())
{
oracle.sql.CLOB myCLOB = (oracle.sql.CLOB)rs.getObject("peaklist");

java.io.Writer CLOBout = myCLOB.getCharacterOutputStream();
String XMLDoc = SparkyToXml.SparkyToXml(peakListLoc);
out.println("XMLDOC " + XMLDoc);
CLOBout.write(XMLDoc);
}

rs.close();
ps.close();
con.commit();
con.setAutoCommit(true);
}catch(Exception e) { out.println("error in 1 " + e);}



I am recieving a nullpointer exeception. Help!!!
Reply With Quote
  #3 (permalink)  
Old 01-24-03, 09:12
imagdalenic imagdalenic is offline
Registered User
 
Join Date: Jan 2003
Posts: 1
alternative solutions

try to use temporary table for uploading clob data:

create table clob_temp (
id varchar2(64),
content clob)

when data are in databes use trigger or sql statement like this

insert into XMLTest values
(
id,
xmltype((select content from clob_temp where id='id')),
)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On