Java Reference
In-Depth Information
updateCategory = connection.prepareStatement(
“UPDATE Movies SET category = ? WHERE number = ?”);
findByCategory = connection.prepareCall(
“{call SelectByCategory(?)}”);
}
public void showByCategory(String category)
{
try
{
findByCategory.setString(1, category);
System.out.println(“Calling stored procedure
SelectByCategory”);
ResultSet result = findByCategory.executeQuery();
System.out.println(“Found the following movies in “
+ category);
while(result.next())
{
System.out.println(result.getString(“title”));
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
The following CallableDemo program shows what happens when the
showByCategory() method is invoked. Study the program and MovieData-
base class and try to determine the output of the CallableDemo program,
which is shown in Figure 18.7.
Figure 18.7 CallableDemo program prints out the movies that match the given category
on the command line.
Search WWH ::




Custom Search