Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


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




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers