JDBC and JSP Interview Questions
- What is the query used to display all tables names in SQL Server (Query analyzer)?
2.select * from information_schema.tables
- How many types of JDBC Drivers are present and what are they?- There are 4 types of JDBC Drivers
- JDBC-ODBC Bridge Driver
- Native API Partly Java Driver
- Network protocol Driver
- JDBC Net pure Java Driver
12.Cookie mycook = new Cookie(\"name\",\"value\");
14.Cookie killmycook = new Cookie(\"mycook\",\"value\");
- How do I mix JSP and SSI #include?- If you’re just including raw HTML, use the #include directive as usual inside your .jsp file.
But it’s a little trickier if you want the server to evaluate any JSP code that’s inside the included file. If your data.inc file contains jsp code you will have to use
<%@ vinclude="data.inc" %>
The <!–#include file="data.inc"–> is used for including non-JSP files.
- I made my class Cloneable but I still get Can’t access protected method clone. Why?- Some of the Java books imply that all you have to do in order to have your class support clone() is implement the Cloneable interface. Not so. Perhaps that was the intent at some point, but that’s not the way it works currently. As it stands, you have to implement your own public clone() method, even if it doesn’t do anything special and just calls super.clone().
- Why is XML such an important development?- It removes two constraints which were holding back Web developments: dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for; the complexity of full SGML, whose syntax allows many powerful but hard-to-program options. XML allows the flexible development of user-defined document types. It provides a robust, non-proprietary, persistent, and verifiable file format for the storage and transmission of text and data both on and off the Web; and it removes the more complex options of SGML, making it easier to program for.
- What is the fastest type of JDBC driver?- JDBC driver performance will depend on a number of issues:
- the quality of the driver code,
- the size of the driver code,
- the database server and its load,
- network topology,
- the number of times your request is translated to a different API.
In general, all things being equal, you can assume that the more your request and response change hands, the slower it will be. This means that Type 1 and Type 3 drivers will be slower than Type 2 drivers (the database calls are make at least three translations versus two), and Type 4 drivers are the fastest (only one translation).
- How do I find whether a parameter exists in the request object?
boolean hasFoo = !(request.getParameter(\"foo\") == null
boolean hasParameter =
request.getParameterMap().contains(theParameter); //(which works in Servlet 2.3+)
- How can I send user authentication information while makingURLConnection?- You’ll want to use HttpURLConnection.setRequestProperty and set all the appropriate headers to HTTP authorization.