Announcement Announcement Module
Collapse
No announcement yet.
SimpleJdbcCall thread safety clarification needed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleJdbcCall thread safety clarification needed

    I have read many forums and Spring documentation over the past 1 month reg thread safety of SimpleJdbc classes. There are a lot of examples on the Internet for SimpleJdbcCall where the standard way seems to be to initiate the SimpleJdbcCall in the setDataSource method itself and then reuse it. But all these examples seem to be standalone or simple example application using Student or Employee table (where the SimpleJdbcCall is used just once). I am not able to find a web application example like Struts or Spring MVC (so that I can confirm that SimpleJdbcCall can be indeed reused).

    Question:Basically, when 2 or more threads access a particular SimpleJdbcCall initiated during application startup due to setDataSource being called, can we be sure that there won't be an issue for the 2 different web users (i.e. one does not see another's account/profile etc.) or should we make that sure ourselves by using threads/synchronization etc. in the Java DAO layer?

    Also Spring doc states this:

    RDBMS Objects including MappingSqlQuery, SqlUpdate and StoredProcedure requires you to create reusable and thread-safe objects during initialization of your data access layer. This approach is modeled after JDO Query wherein you define your query string, declare parameters, and compile the query. Once you do that, execute methods can be called multiple times with various parameter values passed in.


    Immediately, it says:
    The org.springframework.jdbc.object package contains classes that represent RDBMS queries, updates, and stored procedures as thread safe, reusable objects.

    Is it only me that does not understand this or is it indeed confusing to many people..i.e. should we make sure ourselves by using threads/synchronization etc. in the Java DAO layer?

    I have already coded my web application that threadsafety is taken care of already internally..please reply so that I do not have to recode these classes.

    Also note that all my objects are of default scope i.e. singleton.

    Thanks in advance!

  • #2
    Kindly request someone to reply and clarify my question give above...Thanks.

    Comment


    • #3
      Hi..I am still not sure about this..someone please reply...thanks.

      Comment

      Working...
      X