You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mevikasg <me...@gmail.com> on 2010/06/10 12:07:27 UTC

SQL Component : Error while Inserting record in db table

Hi,

I am a newbie in Grails-Camel world.

In my grails-groovy web application, i am trying to insert received messages
in mail account into db table using Camel SQL component.

So far via my Route, i can easily access my mail messages and even can
perform SELECT queries on db as well. But, i am unable to Insert  the
received messages in database.

Route:


errorHandler(deadLetterChannel("mock:error"))
from("imaps://imap.gmail.com?username=testmail@gmail.com&password=xxxx"
                +
"&deleteProcessedMessages=false&processOnlyUnseenMessages=true&consumer.delay=600")
            .process(new MyPro
http://old.nabble.com/file/p28841104/MyProcessorImpl.java
MyProcessorImpl.java cessorImpl())
            .to("sql:insert into message values
(?,'#',true,1)?dataSourceRef=myDataSource")
            .to("activemq:queue:VIKAS")
            .to("stream:out")


 Its squealing following error:

2010-06-10 14:57:37,750 [Thread: 1
org.apache.camel.component.mail.MailComponent@1894800] ERROR
processor.DeadLetterChannel  - Failed delivery for exchangeId:
ID-everest/1739-1276162039140/0-0. On delivery attempt: 0 caught:
org.springframework.jdbc.UncategorizedSQLException:
PreparedStatementCallback; uncategorized SQLException for SQL [insert into
queues values (]; SQL state [S1009]; error code [0]; Parameter index out of
range (1 > number of parameters, which is 0).; nested exception is
java.sql.SQLException: Parameter index out of range (1 > number of
parameters, which is 0).
org.springframework.jdbc.UncategorizedSQLException:
PreparedStatementCallback; uncategorized SQLException for SQL [insert into
queues values (]; SQL state [S1009]; error code [0]; Parameter index out of
range (1 > number of parameters, which is 0).; nested exception is
java.sql.SQLException: Parameter index out of range (1 > number of
parameters, which is 0).
        at
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:96)
        at
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:257)
        at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:477)
        at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:489)
        at
org.apache.camel.component.sql.SqlProducer.process(SqlProducer.java:45)
        at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
        at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:84)
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
        at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
        at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
        at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
        at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:115)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:89)
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
        at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
        at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
        at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
        at
org.apache.camel.component.mail.MailConsumer.processMessage(MailConsumer.java:174)
        at
org.apache.camel.component.mail.MailConsumer.processMessages(MailConsumer.java:156)
        at
org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:105)
        at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: Parameter index out of range (1 > number
of parameters, which is 0).
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
        at
com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2777)
        at
com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:3608)
        at
com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:3010)
        at
org.apache.camel.component.sql.SqlProducer$1.doInPreparedStatement(SqlProducer.java:52)
        at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:460)
        ... 30 more
 
-- 
View this message in context: http://old.nabble.com/SQL-Component-%3A-Error-while-Inserting-record-in-db-table-tp28841104p28841104.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: SQL Component : Error while Inserting record in db table

Posted by mevikasg <me...@gmail.com>.
Hi Roman,


Please find the stack trace attached here with.
http://old.nabble.com/file/p28851402/stacktrace.txt stacktrace.txt 



RomKal wrote:
> 
> 2010/6/10 mevikasg <me...@gmail.com>:
>>
>> Hi Roman,
>>
>> Thanks for the reply.
>>
>> I have already tried it but no luck.
>>
>> Infact, tried following too:
>>
>>   errorHandler(deadLetterChannel("mock:error"))
>>  from("imaps://imap.gmail.com?username=testmail@gmail.com&password=xxxx"
>>
>>  +"&deleteProcessedMessages=false&processOnlyUnseenMessages=true&consumer.delay=600")
>>        .process(new MyProProcessorImpl())
>>   .to("sql:insert into message values
>> (3,'#',true,1)?dataSourceRef=myDataSource")
>>   .to("activemq:queue:VIKAS")
>>   .to("stream:out")
> 
> Could you give us the stacktrace you had this time? In this case I
> believe everything should work just fine as there are no parameters we
> have to put into the statement (as # is quoted anyway).
> 
> Roman
> 
> 

-- 
View this message in context: http://old.nabble.com/SQL-Component-%3A-Error-while-Inserting-record-in-db-table-tp28841104p28851402.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: SQL Component : Error while Inserting record in db table

Posted by Roman Kalukiewicz <ro...@gmail.com>.
2010/6/10 mevikasg <me...@gmail.com>:
>
> Hi Roman,
>
> Thanks for the reply.
>
> I have already tried it but no luck.
>
> Infact, tried following too:
>
>   errorHandler(deadLetterChannel("mock:error"))
>  from("imaps://imap.gmail.com?username=testmail@gmail.com&password=xxxx"
>
>  +"&deleteProcessedMessages=false&processOnlyUnseenMessages=true&consumer.delay=600")
>        .process(new MyProProcessorImpl())
>   .to("sql:insert into message values
> (3,'#',true,1)?dataSourceRef=myDataSource")
>   .to("activemq:queue:VIKAS")
>   .to("stream:out")

Could you give us the stacktrace you had this time? In this case I
believe everything should work just fine as there are no parameters we
have to put into the statement (as # is quoted anyway).

Roman

Re: SQL Component : Error while Inserting record in db table

Posted by mevikasg <me...@gmail.com>.
Hi Roman,

Thanks for the reply.

I have already tried it but no luck.

Infact, tried following too:

   errorHandler(deadLetterChannel("mock:error"))
  from("imaps://imap.gmail.com?username=testmail@gmail.com&password=xxxx"
              
 +"&deleteProcessedMessages=false&processOnlyUnseenMessages=true&consumer.delay=600")
       .process(new MyProProcessorImpl())
  .to("sql:insert into message values
(3,'#',true,1)?dataSourceRef=myDataSource")
  .to("activemq:queue:VIKAS")
  .to("stream:out")

  


RomKal wrote:
> 
> Hello,
> 
> In camel-sql component you should use # sign instead of ? as question
> marks has its own meaning in URL notation.
> 
> Unfortunately it looks that you cannot really use # sign itself, as it
> will be converted to questionmark (so your '#' will become '?').
> 
> I'll create a a bug for this # sign problem.
> 
> Roman
> 
> 2010/6/10 mevikasg <me...@gmail.com>:
>>
>> Hi,
>>
>> I am a newbie in Grails-Camel world.
>>
>> In my grails-groovy web application, i am trying to insert received
>> messages
>> in mail account into db table using Camel SQL component.
>>
>> So far via my Route, i can easily access my mail messages and even can
>> perform SELECT queries on db as well. But, i am unable to Insert  the
>> received messages in database.
>>
>> Route:
>>
>>
>> errorHandler(deadLetterChannel("mock:error"))
>> from("imaps://imap.gmail.com?username=testmail@gmail.com&password=xxxx"
>>                +
>> "&deleteProcessedMessages=false&processOnlyUnseenMessages=true&consumer.delay=600")
>>            .process(new MyPro
>> http://old.nabble.com/file/p28841104/MyProcessorImpl.java
>> MyProcessorImpl.java cessorImpl())
>>            .to("sql:insert into message values
>> (?,'#',true,1)?dataSourceRef=myDataSource")
>>            .to("activemq:queue:VIKAS")
>>            .to("stream:out")
>>
>>
>>  Its squealing following error:
>>
>> 2010-06-10 14:57:37,750 [Thread: 1
>> org.apache.camel.component.mail.MailComponent@1894800] ERROR
>> processor.DeadLetterChannel  - Failed delivery for exchangeId:
>> ID-everest/1739-1276162039140/0-0. On delivery attempt: 0 caught:
>> org.springframework.jdbc.UncategorizedSQLException:
>> PreparedStatementCallback; uncategorized SQLException for SQL [insert
>> into
>> queues values (]; SQL state [S1009]; error code [0]; Parameter index out
>> of
>> range (1 > number of parameters, which is 0).; nested exception is
>> java.sql.SQLException: Parameter index out of range (1 > number of
>> parameters, which is 0).
>> org.springframework.jdbc.UncategorizedSQLException:
>> PreparedStatementCallback; uncategorized SQLException for SQL [insert
>> into
>> queues values (]; SQL state [S1009]; error code [0]; Parameter index out
>> of
>> range (1 > number of parameters, which is 0).; nested exception is
>> java.sql.SQLException: Parameter index out of range (1 > number of
>> parameters, which is 0).
>>        at
>> org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:96)
>>        at
>> org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:257)
>>        at
>> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:477)
>>        at
>> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:489)
>>        at
>> org.apache.camel.component.sql.SqlProducer.process(SqlProducer.java:45)
>>        at
>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
>>        at
>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:84)
>>        at
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>>        at
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
>>        at
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
>>        at
>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
>>        at
>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
>>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:115)
>>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:89)
>>        at
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>>        at
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
>>        at
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
>>        at
>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
>>        at
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>        at
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>        at
>> org.apache.camel.component.mail.MailConsumer.processMessage(MailConsumer.java:174)
>>        at
>> org.apache.camel.component.mail.MailConsumer.processMessages(MailConsumer.java:156)
>>        at
>> org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:105)
>>        at
>> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
>>        at
>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>>        at
>> java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
>>        at
>> java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
>>        at
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
>>        at
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
>>        at
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
>>        at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
>>        at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
>>        at java.lang.Thread.run(Thread.java:619)
>> Caused by: java.sql.SQLException: Parameter index out of range (1 >
>> number
>> of parameters, which is 0).
>>        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
>>        at
>> com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2777)
>>        at
>> com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:3608)
>>        at
>> com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:3010)
>>        at
>> org.apache.camel.component.sql.SqlProducer$1.doInPreparedStatement(SqlProducer.java:52)
>>        at
>> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:460)
>>        ... 30 more
>>
>> --
>> View this message in context:
>> http://old.nabble.com/SQL-Component-%3A-Error-while-Inserting-record-in-db-table-tp28841104p28841104.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/SQL-Component-%3A-Error-while-Inserting-record-in-db-table-tp28841104p28842802.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: SQL Component : Error while Inserting record in db table

Posted by Roman Kalukiewicz <ro...@gmail.com>.
Hello,

In camel-sql component you should use # sign instead of ? as question
marks has its own meaning in URL notation.

Unfortunately it looks that you cannot really use # sign itself, as it
will be converted to questionmark (so your '#' will become '?').

I'll create a a bug for this # sign problem.

Roman

2010/6/10 mevikasg <me...@gmail.com>:
>
> Hi,
>
> I am a newbie in Grails-Camel world.
>
> In my grails-groovy web application, i am trying to insert received messages
> in mail account into db table using Camel SQL component.
>
> So far via my Route, i can easily access my mail messages and even can
> perform SELECT queries on db as well. But, i am unable to Insert  the
> received messages in database.
>
> Route:
>
>
> errorHandler(deadLetterChannel("mock:error"))
> from("imaps://imap.gmail.com?username=testmail@gmail.com&password=xxxx"
>                +
> "&deleteProcessedMessages=false&processOnlyUnseenMessages=true&consumer.delay=600")
>            .process(new MyPro
> http://old.nabble.com/file/p28841104/MyProcessorImpl.java
> MyProcessorImpl.java cessorImpl())
>            .to("sql:insert into message values
> (?,'#',true,1)?dataSourceRef=myDataSource")
>            .to("activemq:queue:VIKAS")
>            .to("stream:out")
>
>
>  Its squealing following error:
>
> 2010-06-10 14:57:37,750 [Thread: 1
> org.apache.camel.component.mail.MailComponent@1894800] ERROR
> processor.DeadLetterChannel  - Failed delivery for exchangeId:
> ID-everest/1739-1276162039140/0-0. On delivery attempt: 0 caught:
> org.springframework.jdbc.UncategorizedSQLException:
> PreparedStatementCallback; uncategorized SQLException for SQL [insert into
> queues values (]; SQL state [S1009]; error code [0]; Parameter index out of
> range (1 > number of parameters, which is 0).; nested exception is
> java.sql.SQLException: Parameter index out of range (1 > number of
> parameters, which is 0).
> org.springframework.jdbc.UncategorizedSQLException:
> PreparedStatementCallback; uncategorized SQLException for SQL [insert into
> queues values (]; SQL state [S1009]; error code [0]; Parameter index out of
> range (1 > number of parameters, which is 0).; nested exception is
> java.sql.SQLException: Parameter index out of range (1 > number of
> parameters, which is 0).
>        at
> org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:96)
>        at
> org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:257)
>        at
> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:477)
>        at
> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:489)
>        at
> org.apache.camel.component.sql.SqlProducer.process(SqlProducer.java:45)
>        at
> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
>        at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:84)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>        at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
>        at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
>        at
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
>        at
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:115)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:89)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>        at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
>        at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
>        at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
>        at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>        at
> org.apache.camel.component.mail.MailConsumer.processMessage(MailConsumer.java:174)
>        at
> org.apache.camel.component.mail.MailConsumer.processMessages(MailConsumer.java:156)
>        at
> org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:105)
>        at
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
>        at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>        at
> java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
>        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: java.sql.SQLException: Parameter index out of range (1 > number
> of parameters, which is 0).
>        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
>        at
> com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2777)
>        at
> com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:3608)
>        at
> com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:3010)
>        at
> org.apache.camel.component.sql.SqlProducer$1.doInPreparedStatement(SqlProducer.java:52)
>        at
> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:460)
>        ... 30 more
>
> --
> View this message in context: http://old.nabble.com/SQL-Component-%3A-Error-while-Inserting-record-in-db-table-tp28841104p28841104.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>