mysql and jdbc

Y

yasaswi

In the mysql database I have, after I get some values from 3 tables, I
have to get few more values from other tables, based on the values I
obtained in the first run. In a case like this, can I pass the
java.sql.Connection as a variable, between my methods.
In other words, can I dedicate each method to go and fetch some
specific data from the mysql database. I am using a DBCP connection
pool, but still, instead of using a new Connection in each method, can
a pass a java.sql.Connection to the methods?
Thanks,
Yasaswi
 
L

Lee Fesperman

yasaswi said:
In the mysql database I have, after I get some values from 3 tables, I
have to get few more values from other tables, based on the values I
obtained in the first run. In a case like this, can I pass the
java.sql.Connection as a variable, between my methods.
In other words, can I dedicate each method to go and fetch some
specific data from the mysql database. I am using a DBCP connection
pool, but still, instead of using a new Connection in each method, can
a pass a java.sql.Connection to the methods?

Sure, it's just an object. BTW, be sure and close any statements/resultsets you create
in the methods, in a finally clause.
 
Y

yasaswi

Hi Lee:
Thanks for your answer. Also from a design and performance standpoint,
is there a limitation on the number of arguments one should pass to
methods. In other words, if 5 different arguments are being passed to
methods, will there be a hit on performance etc. Please comment on best
practices.
Thanks,
Yasaswi

Lee said:
Sure, it's just an object. BTW, be sure and close any
statements/resultsets you create
 
L

Lee Fesperman

yasaswi said:
Hi Lee:
Thanks for your answer. Also from a design and performance standpoint,
is there a limitation on the number of arguments one should pass to
methods. In other words, if 5 different arguments are being passed to
methods, will there be a hit on performance etc. Please comment on best
practices.
Thanks,
Yasaswi

Please don't top-post.

Within reasonable numbers (say under 16), there is not much performance consideration.
However, heavy use of methods with over 8 arguments might begin to affect performance.

From a design viewpoint, methods taking over 5 arguments can cause difficulties in
understanding (and potential bugs) and should be avoided where possible. Best practices
are somewhat fluid in this area in general.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top