Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    You could mention ORM frameworks also. Commented Sep 8, 2016 at 9:47
  • 1
    @COMEFROM OP is a beginner. He must learn to swim before driving a jet ski. ORMs are incredibly complex. Commented Sep 8, 2016 at 15:17
  • Thanks for your answer. I am referring to "just create a database connection". This would mean to create a connection in the main class with all the error handling etc.? Wouldn't this conflict with the single responsibility principle? Commented Sep 9, 2016 at 4:18
  • The main class doesn't tipically comply with the SRP because it usually prepares the preconditions, reads configuration files etc., opens the main window in the case of GUI apps, or al least calls the methods that do that, its purpose is to be an entry point for the app. You can create a function that returns aconnection and call it from main or you can ask for a connection to a connection pool manager if you are using a web container that supports connection pools, etc. Commented Sep 9, 2016 at 4:29