Java Reference
In-Depth Information
Figure 18.2
Part of the output of the AddMovies program.
The first few times I ran the AddMovies program, the last movie wasn't
showing up in the database. What was the problem? I forgot to close the
database connection when I was done with it. The SQL statement that
inserted the movie executed, but it did not commit to the database
because I left the connection open. After adding the statement
connection.close();
at the end of the AddMovies program, I saw all six movies added to the
database successfully. Keep in mind I had this problem using Microsoft
Access. Other databases may behave differently, but closing the
connection when you are finished with it is still an important step.
After running the AddMovies program, the six entries appear in the movies
database, as shown in Figure 18.3.
Figure 18.3
Six movies now appear in the Movies table of the movies.mdb database.
Search WWH ::




Custom Search