Java Reference
In-Depth Information
System.out.println(movie.toString());
}
results.close();
selectAll.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
The following ShowMovies program calls the showAllMovies() method to
test the program and make sure that it is successful. Study the ShowMovies
and MovieDatabase classes to determine the output of running the Show-
Movies program, which is shown in Figure 18.4.
import java.sql.*;
public class ShowMovies
{
public static void main(String [] args)
{
String url = “jdbc:odbc:” + args[0];
try
{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connection connection =
DriverManager.getConnection(url);
MovieDatabase db = new MovieDatabase(connection);
db.showAllMovies();
connection.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Figure 18.4
Output of the ShowMovies program.
Search WWH ::




Custom Search