★ wanayoo — archive 1999 http://wdvl.com/Authoring/DB/Intro/jdbc_modify.htmlNouvelle recherche | Portail wanayoo

Stock Market Analysis logo

internet.com
Join the free
WDVL newsletter!

home

Using JDBC to Modify a Database

November 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.

Using JDBC to Query a Database
Introduction to Databases for the Web | Table of Contents
More on JDBC

Up to => Home / Authoring / DB / Intro

Instantly look up a "techie" word using Webopedia!!


internet.com
e-commerce
WebDeveloper Network


The leading seminar for Affiliate Marketing on the Internet.

Copyright 1999 internet.com Corporation. Legal Notices. Privacy Policy.

www.internet.com