can we reuse the only one existing Connection and one Resultset Obj to run more than one sql queries? or every time when we need to get new connction object n rs object and run different the queries and close connection and resultset?
The connection can be reused as much as you want, just don't close it. Do keep in mind that if every client has an idle connection it may decrease performance on the database server. There is an increase in performance on the client though since you don't have to reconnect all the time. Whether or not you want to have idle connections is up to you.
As for result sets, these may be shared by the SQL driver, but you shouldn't reuse the objects yourself - always close result sets and statements as soon as you no longer need them. This doesn't mean you can't reuse the reference variables though.
I wonder how to keep the connection when external program will request to connect several time. for example, A.class calls b.class(where JDBC connection to DB2 database) many times per day. In this case, if I don't keep the connection from B.class, i must be connected for every transaction from A.class's request.
Thus, the performance should be slower down.
please recommand what the best way is.
subject: can resuse the Connection and Resultset Obj