Java Reference
In-Depth Information
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(SQLQuery);
md = rs.getMetaData();
if(rs.getConcurrency()==ResultSet.CONCUR_UPDATABLE){
System.out.println("UPDATABLE");
}else{
System.out.println("READ_ONLY");
}
os.write(xmlHeader.getBytes());
os.write(("<"+rootTag+">").getBytes());
String xml = "";
int columns = md.getColumnCount();
rs.next();
for(int i=1;i<=columns;i++){
if(md.getColumnType(i)==Types.VARCHAR){
xml="<"+md.getColumnLabel(i)+">"+
rs.getString(i)+"</"+md.getColumnLabel(i)+">";
os.write(xml.getBytes());
}
}
os.write(("</"+rootTag+">").getBytes());
}catch(Exception e){
e.printStackTrace();
}
return os.toByteArray();
}
}
To create an updatable
ResultSet
object, you need to call the
createStatement
method with these
ResultSet
constants:
TYPE_SCROLL_SENSITIVE
CONCUR_UPDATABLE
The
Statement
object that is created produces an updatable
ResultSet
object when it executes a
query. Once you have an updatable
ResultSet
object, you can insert a new row, delete an existing
row, or modify one or more column values.
Here are several considerations to bear in mind when using updatable ResultSets:
An updatable
ResultSet
object does not necessarily have to be scrollable.
An updatable
ResultSet
must generally specify the primary key as one of the columns selected.
Requesting a ResultSet be updatable does not guarantee that the ResultSet you get will actually
be updatable. Drivers that do not support updatable ResultSets return one that is read-only.
If the driver does not support the definition of
UpdatableResultSet
, the
Statement
object
may throw a SQL "Optional feature not implemented" exception.