1 Reply Latest reply on Dec 28, 2006 11:35 AM by 807607

    Java SQL calls...

      Hi all,

      My appologies in advance I am still very new to java.

      I have a simple (ish) question, more of a general discussion than anything else, but anway.

      I am dabbling in creating applications that connect (using jdbc) to a MYSQL database, eventually I intend on using some kind of vector/array to store the objects that I map. My question is this. When or (more importantly) where would you put your SQL update statements.

      For example, say I have a table called Person which stored a persons details, and a class with get/set methods which is also similar to the person table (in terms of variables). Would I be best putting the SQL calls in the:

      Person Class
      a separate Class
      a collection class

      What are the ramifications of this? I am really more interested in what other people think, and what the advantages/disadvantages are of this. Personally I think a separte class would be better in the long run, as it would be easier to maintain...

      Thanks for reading,

        • 1. Re: Java SQL calls...
          Hard to say. Basically I prefer to keep knowledge about the database (and the handle to it) as secret as possible and bundle selection, update and deletion in a single class (e.g. a factory class) for maintenance reasons. Depends on the frameworks / 3rd party libraries you use, if any.