| ★ wanayoo — archive 1999 http://wdvl.com/Authoring/DB/Intro/jdbc_modify.html | Nouvelle recherche | Portail wanayoo |
|
|||
Using JDBC to Modify a DatabaseNovember 23, 1998
Modifying a database is just as simple as querying a database. However, instead of using executeQuery(), you use executeUpdate() and you don't have to worry about a result set. Consider the following example:
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
Connection jdbcConnection =
DriverManager.getConnection
(jdbc:odbc:Access);
Statement sqlStatement = jdbcConnection.createStatement();
// We have seen all of the above before.
// No surprises so far. in the next line, we
// will simply create a string of SQL.
String sql = "INSERT INTO CUSTOMERS +
" (CustomerID, Firstname, LastName, Email)" +
" VALUES (004, 'Selena', 'Sol' " +
"'selena@extropia.com')";
// Now submit the SQL....
sqlStatement.executeUpdate(sql);
As you can see, there is not much to it. Add, modify and delete are all handled by the executeUpdate() method. You compose the SQL and send it through JDBC in one simple call.
Introduction to Databases for the Web | Table of Contents More on JDBC | |||
Instantly look up a "techie" word using
Webopedia!!
|
internet.com
| |
e-commerce
| |
WebDeveloper Network
|
Copyright 1999 internet.com Corporation. Legal Notices. Privacy Policy.