The main method is only required as an access point for the JVM. If you are writing a class as a stand alone app, then you need a main method to run it. If your class is part of an application however, it would be called by another class. And course if you are using JSP there is no main method there either.
This is pretty basic stuff - if you are unsure about how this works I'd spend a little time reading up on the basics before trying any
JDBC.