This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Transfer Learning for Natural Language Processing (MEAP) and have Paul Azunre on-line!
See this thread for details.
Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

BLOB data type

 
Ranch Hand
Posts: 644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have a Db table that has a column which is of type BLOB.
I am using oracle and java for development.
Does anyone know how to insert the BLOB object into DB. BLOB matches to what data type in java?

Thanks,
Trupti
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use setblob method of java.sql.preparedstatement

hope this helps.
 
trupti nigam
Ranch Hand
Posts: 644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shailesh,

I am trying to insert String into BLOB type column.
Do i need to process it before inserting to DB,i mean need to chnge it to different data type?

Thanks,
Trupti
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think its obvious. haven't tried to insert string into blob type, though. did with bytes and it went fine.
 
trupti nigam
Ranch Hand
Posts: 644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to insert String into CLOB type column like below.
pstmt.setObject(10, msg,java.sql.Types.VARCHAR);

where msg is String.
I am getting SQLException which says inserted value too large.
I tried to insert in different way like below .


byte[] bytes = msg.getBytes();
ByteArrayInputStream byteStream = new ByteArrayInputStream (bytes);
pstmt.setAsciiStream(10, byteStream, bytes.length);

but still getting the same exception.
Can someone please help me.
Thanks,
Trupti
 
author & internet detective
Posts: 39957
804
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trupti,
How big is the BLOB?

Also, why are you using an ASCII stream rather than a Binary one? A BLOB is for binary data. A CLOB is for character data.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of doing setObject trying setting the stream right away in case of Blobs.I have been able to set them this way for both Oracle and SQL Server.
 
I was born with webbed fish toes. This tiny ad is my only friend:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic