␡
- Derby: A Database for All Seasons
- What Is Derby?
- How to Use Derby
- Setting Up Your CLASSPATH
- Testing Your Setup
- Running Your First Derby Program
- Derby Application Components
- Derby Application Startup
- Loading the Derby Driver
- Database and Connection Creation
- Statement Creation
- Table Creation
- Table Access
- Shutdown
- Running the Code
Like this article? We recommend
Shutdown
Listing 14 illustrates the steps required to release all the resources allocated during the Derby program. I removed the exception handling code just to show the bare minimum steps. The SimpleApp.java program includes all the necessary exception handling.
Listing 14 Closing up shop with Derby
rs.close(); s.close(); System.out.println("Closed result set and statement"); conn.commit(); conn.close(); DriverManager.getConnection("jdbc:derby:;shutdown=true");
In Listing 14, the ResultSet object and the Statement object are both explicitly closed. The Connection object is committed and then explicitly closed. Finally, Derby itself is shut down after which the program exits.