Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

better declare this method, as static or not?

Status
Not open for further replies.

Jefhandle

Technical User
Mar 9, 2005
69
DE
hi,
i have a java class Myconnector.java which has a mehod giveMeConnectionToDatabase to connect with mysql database
All Other 25 servlets create an instance of this class and
becomm own connection to access database.
My method and my class arent static. Theis mehthod
is not synchronized too.
I havent yet problem with my aoolication, but iwill know
which method is better to use.
Thanks
 
Probably makes sense to make it static.
You don't need to worry about synchronization (unless you are doing something odd).

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
but if i make it static i have physicaly one connection to database!!!!??
The other Question is, what is the Goal of Java and Object philosophy in java. I mean if i have more Connection to database is better than to have some crash by usinig only
one connection, which would be invoked from f.i 50 User??
The other Questtion is,if making more connections in
java programm depends on kind of using database or not?????
regards
 
Easy with the question marks fella ...

If you make the getConnection() method static, it does NOT mean you only have one connection to the database.

This forum is not the right place to discuss Java and Object-orientated design. If you want to know more, then use google and do some reading.


--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top