File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes  jdbc connection in main method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark " jdbc connection in main method" Watch " jdbc connection in main method" New topic

jdbc connection in main method

shivam aggarwal

Joined: Oct 15, 2009
Posts: 8
is it mandatory to make jdbc connection in main method;i tried to use it in event handling method of a button and it gives no response and no errors
samir singha

Joined: Mar 17, 2008
Posts: 23
Not at all. You should make a separate Connection class for JDBC. Did your code in event handling method includes any output statement??
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46397
You ought not to have a connection in the main method. Use the main method to start the application and nothing else.
I agree. Here's the link:
subject: jdbc connection in main method
It's not a secret anymore!