Efficient Method for using Multiple Database connection in java -
is efficient method open database connection every database operation , accordingly close or open connection @ starting , keep calling same opened connection multiple operation , close when activities done. ?
i creating java swing application have main frame , using card layout selecting different panel , each of panel have different database operation perform. presently having individual connection opened each panel , when open main application multiple connection gets opened , closed.
as want sure doing right thing , avoid bad practice , bottleneck in performance asking question java experts.
please suggest .thanks .
no, isn't recommended "create" new connection each database transaction. creating connections typically expensive. try using connection pool abstracts connection open , close semantics. way, application can call connection#close etc. , behind scenes pool grab , return connections connection poll accordingly. there many solutions out there; dbcp, c3p0 or bonecp.
Comments
Post a Comment