Java Reference
In-Depth Information
}
}
The
WebRowSet
has several uses that involve converting database results to or from XML. I
populated state before testing the SQL formatting code in
Program: SQLRunner
.
Because it
writes data in a known format (public DTD), it could also be used with web services to ex-
change data across different vendors' systems.
See Also
The documentation for JDBC that accompanies the JDK provides more details on the various
RowSet
implementations and their usages. The changes for JDBC 4.1 are documented by
Changing Data Using SQL
Problem
You wish to insert or update data, create a new table, delete a table, or otherwise change the
database.
Solution
Instead of using the
Statement
method
executeQuery()
, use
executeUpdate()
with SQL
commands to make the change.
Discussion
The
executeUpdate()
method is used when you want to make a change to the database as
opposed to getting a list of rows with a query. You can implement either data changes like
insert
or
update
, data structure changes like
create table
, or almost anything that you
can do by sending SQL directly to the database through its own update command interface or
GUI.