Connect and Statement objects...

Hi, I'm new to JDBC, I just have two quick questions: First, What is the difference between using the Class.forName()method, and the System.setProperty()method to register a driver. When would you use one rather than the other, as they seem to do the same thing? second, What are the advantages / disadvantages of creating one Statement object in the initialization of a JDBC connection and then using this object in all your other methods to execute queries etc, then close it in the close() method of the connection. As opposed to creating a new seperate Statement object in each method which needs one. If you know what I mean? [This message has been edited by J Carklin (edited June 13, 2001).]

Carklin, first of all, registering a driver with Class.forName() is a JDBC 1.0 practise, which is now mostly obsolete, with the introdcution of DataSource in JDBC 2.0. I've never registered a driver with System.setProperty(), so I'm not sure how it differs from Class.forName(), if it does so in the first place. Carklin, if you need more information on using the new features of JDBC 2.0, and especially the JDBC 2.0 optional packages, you can start your search in the JDBC Learning Center at Sun, at http://java.sun.com/products/jdbc/learning.html. There is also a lot of information on this topic in this week's book giveaway (I'm playing a salesman this week, so forgive me if you're shocked ), Professional Java Data. On the other subject, I don't see the (dis)advantages of using multiple Statement objects - not if they're all closed after usage in the first place - except for the obvious added garbage collection and memory usage. Regards,

Originally posted by J Carklin: First, What is the difference between using the Class.forName()method, and the System.setProperty()method to register a driver. When would you use one rather than the other, as they seem to do the same thing?

Yeah, according to me there is a one reason I know, suppose if we have a requirement of using multiple drivers which are specified in properties file, then use register driver method which registers each driver to be used. If we have only one driver then Class.forName() is enough to load the driver. HTH...Anil