Hi

Ouch maybe you can in the SQL somehow tell Oracle to return the data
as not blob.

If not then you must fetch the data from the database yourself from Java code.
Maybe with the help of Spring's JdbcTemplate. I am sure if you google
a bit you can find examples to do this with Oracle Blob and JDBC.


On Thu, Mar 11, 2010 at 10:04 PM, schivukula
<[email protected]> wrote:
>
> Thanks Claus for the quick reply
> I tried the following
>
>        .to("jdbc:testdb?readSize=100")
>        .process(new Processor() {
>            public void process(Exchange exchange) throws Exception {
>                ArrayList<HashMap<String, Object>> body =
> (ArrayList<HashMap<String, Object>>) exchange.getIn().getBody();
>                HashMap<String, Object> t = (HashMap) body.get(0);
>                BLOB blob = (BLOB) t.get("FILECONTENT");
>                        long len = blob.length();
>                        byte [] data = blob.getBytes(1, (int) len);
>                        String s = "";
>                        String charsetName = 
> exchange.getProperty(Exchange.CHARSET_NAME,
> String.class);
>                   if (charsetName != null) {
>                       try {
>                         s =  new String(data, charsetName);
>                       } catch (UnsupportedEncodingException e) {
>                           System.out.println("Can't convert the byte to
> String with the charset =" + charsetName+","+e);
>                       }
>                   }
>                // do something with the payload and/or exchange here
>               exchange.getIn().setBody(s);
>           }
>        }).split(body())
> and I get the following error
>
> ERROR 2010-Mar-11 16:01:27,292 TimerConsumer   Error processing exchange.
> Exchange[Message: [{filecontent=oracle.sql.b...@11ea3fc, FILEID=7216}]].
> Caused by: [java.sql.SQLException - Closed Connection]
> java.sql.SQLException: Closed Connection
>        at
> oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
>
> Please help
>
>
>
>
>
>
> schivukula wrote:
>>
>> I have a requirement to get a value from the database and convert write
>> individual values to file, the fileid is a string and filecontent is a
>> oracle.sql.blob. I am getting the following error, please help I am new to
>> camel
>>
>> from("timer://kickoff?period=30000")
>>        .setBody(constant("select fileid,filecontent from ftsmailbox where
>> display_status= 'SHOW' and mimetype = 'text/xml' and fileid = 7216"))
>>          .to("jdbc:testdb?readSize=100")
>>          .split(body())
>>          .to("file:target/messages/others");
>>
>>
>> Error
>> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
>> converter available to convert from type: java.util.HashMap to the
>> required type: java.io.InputStream with value
>> {filecontent=oracle.sql.b...@16ea15f, FILEID=7216}
>>       at
>> org.apache.camel.impl.converter.DefaultTypeConverter.mandatoryConvertTo(DefaultTypeConverter.java:123)
>>       at
>> org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
>>
>>
>
> --
> View this message in context: 
> http://old.nabble.com/java.util.HashMap-to-the-required-type%3A-java.io.InputStream-tp27868505p27869842.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to