Java Reference
In-Depth Information
L ISTING 7.1
Continued
con = DriverManager.getConnection(“jdbc:odbc:Movie Catalog”,
“”, “”);
// Create the statement
Statement statement = con.createStatement();
// Use the created statement to CREATE the database table
// Create Titles Table
statement.executeUpdate(“CREATE TABLE Titles “ +
“(title_id INTEGER, title_name VARCHAR(50), “ +
“rating VARCHAR(5), price FLOAT, quantity INTEGER, “ +
“type_id INTEGER, category_id INTEGER)”);
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
catch (ClassNotFoundException cnfe) {
System.err.println(cnfe.getMessage());
}
catch (Exception e) {
System.err.println(e.getMessage());
}
finally {
try {
if ( con != null ) {
// Close the connection no matter what
con.close();
}
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
}
}
public static void main(String[] args) {
Search WWH ::




Custom Search