As I know connection is kind of very expensive operation. Which approach should I follow to handle few connections? I have seen a lots of examples where author talks about only one connection or uses connection pool(from JBoss or something). My code looks like this:
1) make new connection
2) do some logic
3) close connection
DriverManager.registerDriver(new net.sourceforge.jtds.jdbc.Driver());
con = DriverManager.getConnection(URL, username, password);
if(con!=null)
System.out.println("Connection Successful !\n");
//logic
if(con!=null)
con.close();
But I've got few similar methods based on this approach. So do I really have to make new connection or should I use the only one? If I use one connection, do I need to close it after?
PS. App is not a servlet.