|
INTERVIEW QUESTIONS
J2EE
JSP
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
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 |
JSP Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9697 users |
Added on |
9/16/2014 |
Views |
70794 |
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
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 Class.forName will do while loading drivers?
|
View Answer
|
|
How can my application get to know when a HttpSession is removed?
|
View Answer
|
|
How does JSP handle runtime exceptions?
|
View Answer
|
|
What is the difference between RequestDispatcher and sendRedirect?
|
View Answer
|
|
What is the difference between directive include and jsp include?
|
View Answer
|
|
Can you override jspInit() method? If yes, In which cases?
|
View Answer
|
|
A JSP page, include.jsp, has a instance variable "int a", now this page is statically included in another JSP page, index.jsp, which has a instance variable "int a" declared. What happens when the index.jsp page is requested by the client?
|
View Answer
|
|
What happens when a page is statically included in another JSP page?
|
View Answer
|
|
Why is _jspService() method starting with an '_' while other life cycle methods do not?
|
View Answer
|
|
Can we override the jspInit(), _jspService() and jspDestroy() methods?
|
View Answer
|
|
How is JSP include directive different from JSP include action. ?
|
View Answer
|
|
How to pass information from JSP to included JSP?
|
View Answer
|
|
What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?
|
View Answer
|
|
What is the difference between ServletContext and PageContext?
|
View Answer
|
|
Can we implement an interface in a JSP?
|
View Answer
|
|
How do you delete a Cookie within a JSP?
|
View Answer
|
|
What is the page directive is used to prevent a JSP page from automatically creating a session?
|
View Answer
|
|
How do you connect to the database from JSP?
|
View Answer
|
|
How can I set a cookie and delete a cookie from within a JSP page?
|
View Answer
|
|
How do I use a scriptlet to initialize a newly instantiated bean?
|
View Answer
|