|
INTERVIEW QUESTIONS
J2EE
JDBC
DETAILS
Question: How do I create an updatable ResultSet?
Answer: Just as is required with a scrollable ResultSet, the Statement must be capable of returning an updatable ResultSet. This is accomplished by asking the Connection to return the appropriate type of Statement using Connection.createStatement(int resultSetType, int resultSetConcurrency). The resultSetConcurrency parameter must be ResultSet.CONCUR_UPDATABLE. The actual code would look like this:
Statement stmt = con.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
Note that the spec allows a driver to return a different type of Statement/ResultSet than that requested, depending on capabilities and circumstances, so the actual type returned should be checked with ResultSet.getConcurrency().
|
|
|
Category |
JDBC Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9441 users |
Added on |
9/12/2014 |
Views |
67824 |
Rate it! |
|
|
Question:
How do I create an updatable ResultSet?
Answer:
Just as is required with a scrollable ResultSet, the Statement must be capable of returning an updatable ResultSet. This is accomplished by asking the Connection to return the appropriate type of Statement using Connection.createStatement(int resultSetType, int resultSetConcurrency). The resultSetConcurrency parameter must be ResultSet.CONCUR_UPDATABLE. The actual code would look like this:
Statement stmt = con.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
Note that the spec allows a driver to return a different type of Statement/ResultSet than that requested, depending on capabilities and circumstances, so the actual type returned should be checked with ResultSet.getConcurrency(). Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How do I create an updatable ResultSet?
|
View Answer
|
|
How can I determine whether a Statement and its ResultSet will be closed on a commit or rollback?
|
View Answer
|
|
Is there a practical limit for the number of SQL statements that can be added to an instance of a Statement object
|
View Answer
|
|
What does setFetchSize() really do?
|
View Answer
|
|
What scalar functions can I expect to be supported by JDBC?
|
View Answer
|
|
What does normalization mean for java.sql.Date and java.sql.Time?
|
View Answer
|
|
What JDBC objects generate SQLWarnings?
|
View Answer
|
|
Why doesn't JDBC accept URLs instead of a URL string?
|
View Answer
|
|
What are the components of the JDBC URL for Oracle's "thin" driver and how do I use them?
|
View Answer
|
|
How to do result set on a page where the user can sort on the column headers?
|
View Answer
|
|
What's the best way, in terms of performance, to do multiple insert/update statements, a PreparedStatement or Batch Updates?
|
View Answer
|
|
When I intersperse table creation or other DDL statements with DML statements, I have a problem with a transaction being commited before I want it to be. Everything ( commit and rollback ) works fine as long as I don't create another table. How can I resolve the issue?
|
View Answer
|
|
What is JDO?
|
View Answer
|
|
What is the difference between setMaxRows(int) and SetFetchSize(int)? Can either reduce processing time?
|
View Answer
|
|
How can I tell if my JDBC driver normalizes java.sql.Date and java.sql.Time objects?
|
View Answer
|
|
What is pessimistic concurrency?
|
View Answer
|
|
What is optimistic concurrency?
|
View Answer
|
|
Which Java and java.sql data types map to my specific database types?
|
View Answer
|
|
Does the database server have to be running Java or have Java support in order for my remote JDBC client app to access the database?
|
View Answer
|
|
What is a JDBC 2.0 DataSource?
|
View Answer
|