By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,017 Members | 951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,017 IT Pros & Developers. It's quick & easy.

inserting clob data in db2 database

P: 1
hi,
I am faceing one problem, while inserting the data in db2 using clob. actually i am writing this type code:
Expand|Select|Wrap|Line Numbers
  1. public class DBParam
  2. {
  3. private InputStream inputstream;
  4. private static int htmLength=0;
  5. public  DBParam(String c,String k) //k has the data of html
  6. {
  7. this.inputStream=getStreams(k);
  8. this.htmlLength=k.length();
  9. }
  10.  
  11. public InputStream getStreams(String html);
  12.  
  13. {
  14.  byte array[]=html.getBytes();
  15. InputStream is=new ByteArrayInputStream(array);
  16. return is;
  17. }
  18. protected InputStream getStreamData()
  19. {
  20. return inputStream;
  21.  
  22. }
  23. protected static int getLength()
  24. {
  25. return htmllength;
  26. }
  27. }//it is the DBParam class.
  28.  
  29. we are calling this method to dao class that is BillingDAO
  30.  
  31. public class BillingDAO
  32. {
  33. public static void insertBillingDetails(String html,String accountnumber,String billDate) 
  34. {
  35. DBSql dbsql=DBSql.createDBsql("billing","billing_insert");
  36. dbsql.setInputParam(new DBParam(Types.VARCHAR,Accountnumber);
  37. dbsql.setInputParam(new DBParam(Types.DATE,billdate);
  38. dbsql.setInputParam(new DBParam(Types.CLOB,html);
  39.  
  40. dbAccessor.execute(dbsql);
  41. }
  42.  
  43.  
  44.  
  45. DBSql.java
  46. ---------------
  47.  
  48.  
  49. in this i am writing this code for CLOB
  50. public void setInputParam(preparedStatement kk)
  51. {
  52. case Types.CLOB:
  53. InputStream inputstream=DBParam.getStream();
  54. int length=DBParam.getLength();
  55. preparedStatement.setBinaryStream(index,inputStream,length);
  56.  
  57. }
in configaration file i am writing one insert query
Expand|Select|Wrap|Line Numbers
  1. <billing>
  2. <billing_insert>
  3. insert into view_imagehistory values(?,?,?);
  4. </billing_insert>
  5. </billing>
the above code, we face the problem like Indexoutofbound exception.
The hole date placed in html String. in that string total characters around 12000

we got the problem in this statement i.e dbsql.setInputParam(new DBParam(Types.CLOB,html);


please help me for this problem


Advanced Thanks
Srinu
Nov 27 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.