The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

icey (1) [Avatar] Offline
#1
My pain point right now is how to lock a database with a scheduled consuming poller!! All my selects and updates are fine but for some reason I cannot Lock a table!

properties file:
cmd.jdbc = LOCK TABLE MYTABLE IN EXCLUSIVE MODE NOWAIT
cmd2.jdbc = COMMIT
__
camel.xml file: (where myDS is my datasource defined else in the xml)
<endpoint id="timerEndpoint" uri="timer://kickoff?period=30000" />
<endpoint id="jdbcEndpoint" uri="jdbc:${cmd.jdbc}?dataSourceRef=myDS" />
...
<routeContext id="timerToJdbc" >
<route startupOrder="1" autoStartup="true">
<!-- scheduled polling consumer -->
<from ref="timerEndpoint" />
<to ref="jdbcEndpoint" />
...

You would think this would be simple but no it does not lock the database (which I check by trying a second lock through a cmd window and can!) but I know it does summat as it will happily return the expected error, when I lock the database in a command prompt window and then run it against the already locked table.

I have now tried the uri's jdbc and sql and currently working out ibatis to see if that can help. Failing that I will go to hibernate and try to process a bean. But if anyone out there knows why this will not work please speak up.

I am in a world of pain with this lock in oracle and a newbie to spring and camel so the book is a lifesaver. As a newbie, I would like to see more examples and best practices for working with databases, not to mention spring and hibernate (why choose a jdbc endpoint over a sql endpoint or ibatis ect.)

Cheers.
janstey (72) [Avatar] Offline
#2
Re: Understanding Components jdbc, sql and iBATIS: LOCK TABLE
Hi,

I've personally never used a lock with the JDBC component, though it should be possible. What kind of error message are you seeing in the logs when this happens?

Cheers,
Jon