You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@storm.apache.org by Manthosh Kumar T <ma...@gmail.com> on 2014/03/17 10:41:10 UTC

JDBC Connection in prepare()

Hi All,
         I'm trying add data to DB using JDBC in bolt. When I create
Connection in the execute() method and close it at the end of execute()
method, it works fine. Since it was slower, I created the Connection in
prepare() method. But this time I'm getting SQLException saying No Suitable
Driver was found. I'm sure that the necessary dependencies are in the
classpath since it works when creating connection in execute() method. Has
anyone had the same issue?. Any suggestions?


-- 
Cheers,
Manthosh Kumar. T

Re: JDBC Connection in prepare()

Posted by Alexander Yerenkow <ye...@gmail.com>.
I see sometimes something like classloaders  'Race Condition' - when I
can't get in one moment DB due to "No suitable driver", and in next
Connection create I got it just fine.
Maybe you should call Connection.create (which can fail), and add some
init-delay for a few secs, and then second one could be OK.


2014-03-17 12:03 GMT+02:00 Manthosh Kumar T <ma...@gmail.com>:

> Hi Tran,
>           I had deployed the JDBC Drivers properly. As I had said before,
> it works fine if the connection is created in the execute() method. So
> doesn't that mean Drivers are properly deployed?. Please correct me if I'm
> wrong.
>
>
> On 17 March 2014 15:25, An Tran <tr...@gmail.com> wrote:
>
>> Make sure that the JDBC drivers are deployed on all the system that Storm
>> is running.  I am not sure if this is correct or not but what i did is i
>> copy all my dependencies into storm/lib folder
>>
>>
>> On Mon, Mar 17, 2014 at 5:41 AM, Manthosh Kumar T <ma...@gmail.com>wrote:
>>
>>> Hi All,
>>>          I'm trying add data to DB using JDBC in bolt. When I create
>>> Connection in the execute() method and close it at the end of execute()
>>> method, it works fine. Since it was slower, I created the Connection in
>>> prepare() method. But this time I'm getting SQLException saying No Suitable
>>> Driver was found. I'm sure that the necessary dependencies are in the
>>> classpath since it works when creating connection in execute() method. Has
>>> anyone had the same issue?. Any suggestions?
>>>
>>>
>>> --
>>> Cheers,
>>> Manthosh Kumar. T
>>>
>>>
>>
>
>
> --
> Cheers,
> Manthosh Kumar. T
>
>


-- 
Regards,
Alexander Yerenkow

Re: JDBC Connection in prepare()

Posted by Richards Peter <hb...@gmail.com>.
That sounds weird. Are you sure that the expected database operation is
being performed when the connection is established in execute()? Please add
logs and see whether the expected results are generated.

Program should not fail in both cases ideally. Only point is that the
driver should be within the class path.

Once you resolve this issue by establishing connection in prepare(), please
try to have connection renewal mechanism(by firing query to database
periodically or using a suitable connection pool). This is to avoid
connection timeouts during times of low traffic.

Richards Peter.

Re: JDBC Connection in prepare()

Posted by Manthosh Kumar T <ma...@gmail.com>.
Hi Tran,
          I had deployed the JDBC Drivers properly. As I had said before,
it works fine if the connection is created in the execute() method. So
doesn't that mean Drivers are properly deployed?. Please correct me if I'm
wrong.


On 17 March 2014 15:25, An Tran <tr...@gmail.com> wrote:

> Make sure that the JDBC drivers are deployed on all the system that Storm
> is running.  I am not sure if this is correct or not but what i did is i
> copy all my dependencies into storm/lib folder
>
>
> On Mon, Mar 17, 2014 at 5:41 AM, Manthosh Kumar T <ma...@gmail.com>wrote:
>
>> Hi All,
>>          I'm trying add data to DB using JDBC in bolt. When I create
>> Connection in the execute() method and close it at the end of execute()
>> method, it works fine. Since it was slower, I created the Connection in
>> prepare() method. But this time I'm getting SQLException saying No Suitable
>> Driver was found. I'm sure that the necessary dependencies are in the
>> classpath since it works when creating connection in execute() method. Has
>> anyone had the same issue?. Any suggestions?
>>
>>
>> --
>> Cheers,
>> Manthosh Kumar. T
>>
>>
>


-- 
Cheers,
Manthosh Kumar. T

Re: JDBC Connection in prepare()

Posted by An Tran <tr...@gmail.com>.
Make sure that the JDBC drivers are deployed on all the system that Storm
is running.  I am not sure if this is correct or not but what i did is i
copy all my dependencies into storm/lib folder

On Mon, Mar 17, 2014 at 5:41 AM, Manthosh Kumar T <ma...@gmail.com>wrote:

> Hi All,
>          I'm trying add data to DB using JDBC in bolt. When I create
> Connection in the execute() method and close it at the end of execute()
> method, it works fine. Since it was slower, I created the Connection in
> prepare() method. But this time I'm getting SQLException saying No Suitable
> Driver was found. I'm sure that the necessary dependencies are in the
> classpath since it works when creating connection in execute() method. Has
> anyone had the same issue?. Any suggestions?
>
>
> --
> Cheers,
> Manthosh Kumar. T
>
>