Rob Prime wrote:
adi sembiring wrote:I need suggestion how to fix this problem and prevent my application being crash?
Always close resources that aren't needed anymore. Not just SQL connections but (Prepared)Statements, ResultSets, InputStreams, OutputStreams, Readers, Writers, etc. You usually do this in a finally block. You can use nested try-finally blocks if you have more than one resource. For instance:
It may look confusing, but this way ensures that all resources will always be closed, even if exceptions occur. The nesting prevents a) having to check against null, and b) because close() can also throw an exception, that failing to close one resource will lead to other resources not being closed.
Ulf Dittmer wrote:Welcome to JavaRanch.
MVC is a GUI concept; if you don't mean web apps, are you asking about Swing GUIs? Swing has the M-V-C separation to some degree built in. For example, if a JTable is a view, then its TableModel and TableComunModel constitute the model, and your event handlers -either attached to the JTable or some other Swing component- would be the controller.