title: How to implement database functionality effectively?
body: <p>I am developing a Java Desktop Application which uses MySQL database. The DB has 6 tables. Every table, as usual, should allow CRUD (Create, Read, Update and Delete) operations.</p>
  
  <p>I have designed 6*4 = 24 JPanels, 4 JPanels for each tables. Each JPanel have Components to take user input and perform the CRUD operation for which it is designed. For instance, a JPanel3 is designed for Create operation for Table1.</p>
  
  <p><b>Now I want to know the following:</b></p>
  
  <p><b>Q1.</b> Would it be better to write 24 functions, each performing a specific function for a specific table?</p>
  
  <p><b>Q2.</b> This kind of situation is very normal as every application generally has many tables. So, Are all those applications use this approach of writing each function for each operation for each table?</p>
  
  <p><b>Q3.</b> As it is a Swing Application and every CRUD operation need the database connection, so Would it be better to make a connection to the database when the user starts the application?</p>
  
  <p>or</p>
  
  <p>Would it be better to make the database connection at the time when user clicks on the "save" or "edit" or "delete" or "create" button?</p>
  
  <p><b>Q4.</b> Would it be better to refer the connection from an instance variable which is shared by all the 24 functions? or Would it be better to have every function its own Connection?</p>
  
  <p>Any other suggestions are also welcomed.</p>