|
INTERVIEW QUESTIONS
J2EE
JDBC
DETAILS
Question: How to Retrieve Warnings?
Answer: SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or a ResultSet object. Each of these classes has a getWarnings method, which you must invoke in order to see the first warning reported on the calling object.
E.g. SQLWarning warning = stmt.getWarnings(); if (warning != null) { while (warning != null) { System.out.println("Message: " + warning.getMessage()); System.out.println("SQLState: " + warning.getSQLState()); System.out.print("Vendor error code: "); System.out.println(warning.getErrorCode()); warning = warning.getNextWarning(); } }
|
|
|
Category |
JDBC Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8604 users |
Added on |
7/14/2011 |
Views |
69971 |
Rate it! |
|
|
Question:
How to Retrieve Warnings?
Answer:
SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or a ResultSet object. Each of these classes has a getWarnings method, which you must invoke in order to see the first warning reported on the calling object.
E.g. SQLWarning warning = stmt.getWarnings(); if (warning != null) { while (warning != null) { System.out.println("Message: " + warning.getMessage()); System.out.println("SQLState: " + warning.getSQLState()); System.out.print("Vendor error code: "); System.out.println(warning.getErrorCode()); warning = warning.getNextWarning(); } } 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 |
|
What are the two major components of JDBC?
|
View Answer
|
|
What are batch updates
|
View Answer
|
|
How can you retrieve data from the ResultSet?
|
View Answer
|
|
How do you implement Connection Pooling
|
View Answer
|
|
What are the steps for connecting to the database using JDBC
|
View Answer
|
|
While in CallableStatament using in the oracle my procedure is return no.of columns so in java
|
View Answer
|
|
How to call a Stored Procedure from JDBC?
|
View Answer
|
|
What Class.forName will do while loading drivers?
|
View Answer
|
|
What packages are used by JDBC?
|
View Answer
|
|
What are the common tasks of JDBC?
|
View Answer
|
|
What Class.forName( ) method will do?
|
View Answer
|
|
How to get the resultset of stroedProcedure
|
View Answer
|
|
How can store images in a data base?
|
View Answer
|
|
Why do we use prepared statement when already statement is present
|
View Answer
|
|
Which is the best driver among the 4 jdbc drivers?how can we load that driver?
|
View Answer
|
|
How many statements can be created with one connection
|
View Answer
|
|
If 4 different drivers are loaded, & created 4 different statements calling diffener tables from same database, how driver is recognized for each statement?
|
View Answer
|
|
What is metadata?
|
View Answer
|
|
Where to use which driver in JAVA?
|
View Answer
|
|
what is savepoint?
|
View Answer
|