CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies
JDBC Interview Questions & Answers - Learning Mode
COOLINTERVIEW.COM J2EE INTERVIEW QUESTIONS JDBC INTERVIEW QUESTIONS QUESTIONS & ANSWERS - LEARNING MODE

JDBC Interview Questions & Answers - Learning Mode

Java Database Connectivity (JDBC) is an API for the Java programming language that defines how a client may access a database. It provides methods for querying and updating data in a database. JDBC is oriented towards relational databases.

Try JDBC Interview Questions & Answers - Exam Mode

1 2 3 4 5 6 7 8 9 10 11 Next

Sort By : Latest First | Oldest First | By Rating

JDBC Interview Questions & Answers - Learning Mode
Try JDBC Interview Questions & Answers - Exam Mode
Question: What is Connection Pooling?

Answer: With servlets, opening a database connection is a major bottleneck because we are creating and tearing down a new connection for every page request and the time taken to create connection will be more.

Creating a connection pool is an ideal approach for a complicated servlet. With a connection pool, we can duplicate only the resources we need to duplicate rather than the entire servlet. A connection pool can also intelligently manage the size of the pool and make sure each conne Source: CoolInterview.com
Question: How can I protect my database password ? I'm writing a client-side java application that will access a database over the internet. I have concerns about the security of the database passwords. The client will have access in one way or another to the class files, where the connection string to the database, including user and password, is stored in as plain text. What can I do to protect my passwords?

Answer: This is a very common question.
Conclusion: JAD decompiles things easily and obfuscation would not help you. But you'd have the same problem with C/C++ because the connect string would still be visible in the executable.
SSL JDBC network drivers fix the password sniffing problem (in MySQL 4.0), but not the decompile problem. If you have a servlet container on the web server, I would go that route (see other discussion above) then you could at least keep people from reading/destroying y Source: CoolInterview.com
Question: Which of the following allows non repeatable read in JDBC, connection class?

Answer: TRANSACTION_READ_UNCOMMITTED Source: CoolInterview.com
Question: What is hybernate and spring? can u suggest any books or documents so that i can go through?


Answer: Hibernate offers persistence and OR(Objet-Relational) mapping for Java/J2EE applications helping them improve performance and scalability.

Spring is a light-weight Java framework which paves the way to write faster applications without App Server (or EJB etc.)

There are a plenty of good books on these subjects. Following the most notable amongst them:

Hibernate in Action by Christian Bauer, Gavin King (Hanning)

Better, Faster, Lighter Java by Justin Gehtland, Bruce A. Source: CoolInterview.com
Question: Is the JDBC-ODBC bridge multithreaded ?


Answer: True

Explanation: The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge, but they won't get the advantages of multi-threading Source: CoolInterview.com
Question: The full form of ODBC is ___________

Answer: (ODBC)---->OPEN DATABASE CONNECTIVITY Source: CoolInterview.com
Question: How do you determine the sensitivity of the ResultSet object?

Answer: Sensitivity of ResultSet object is determined in three ways they are: -
1) TYPE_FORWARD_ONLY: -It contains rows which satisfied the query. These rows are satisfied either at the time of execution or as the rows are retrieved.
2) TYPE_SCROLL_INSENSITIVE: - Here the cursor can move forward backward or to an absolute position.
3) TYPE_SCROLL_SENSITIVE: - This works in the same way as the Scroll insensitive. Source: CoolInterview.com
Question: Explain about Join?

Answer: Join is very important in JDBC. It joins two or more tables in the database by the commonly shared values present in them. Tables should be created and they should have a common value present in them for joining. You can precede the column name with the table name which gets you your desired table. Source: CoolInterview.com
Question: How to update a resultset programmatically?

Answer: a. create a scrollable and updatable ResultSet object.
Statement stmt = con.createStatement
(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet uprs = stmt.executeQuery("SELECT COLUMN_1,
COLUMN_2 FROM TABLE_NAME");

b. move the cursor to the specific position and use related method to update data and then, call updateRow() method.
uprs.last();
uprs.updateFloat("COLUMN_2", 25.55);//update last row's data
uprs.updateRow();//don't miss this me Source: CoolInterview.com
Question: How can I tell if my JDBC driver normalizes java.sql.Date and java.sql.Time objects?

Answer: To actually determine the values, the objects must be converted to a java.util.Date and examined. See What does normalization mean for java.sql.Date and java.sql.Time? for the definition of normalization. Notice that even a debugger will not show whether these objects have been normalized, since the getXXX methods in java.sql.Date for time elements and in java.sql.Time for date elements throw an exception.
So, while a java.sql.Date may show 2001-07-26, it's normalized only if the java.uti Source: CoolInterview.com
Question: State true or false :- ResultSet.CONCUR_UPDATABLE used with the result set is used to update the rows directly in the database.


Answer: True

Explanation: This is the new feature in the JDBC 2.0 API usage is Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
Source: CoolInterview.com
Question: What are the two major components of JDBC?

Answer: One implementation interface for database manufacturers, the other implementation interface for application and applet writers. Source: CoolInterview.com
Question: What is JDO?

Answer: JDO provides for the transparent persistence of data in a data store agnostic manner, supporting object, hierarchical, as well as relational stores. Source: CoolInterview.com
Question: What are the common tasks of JDBC?

Answer: import java.sql.*;
class Type1
{
public static void main(String[] args)throws Exception
{
Connection c=null;
try
{
Driver d=new Driver("sun.jdbc.odbc.JdbcOdbc");
//or Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c=DriverManager.getConnection("jdbc:odbc:emp1","scott","tiger");
Statement s=c.createStatement();
s.executeUpdate("insert into dept(deptno,loc)values(60,'hyd')");
}
catch(Exception e)
{
e.pr Source: CoolInterview.com
Question: How can you load the drivers?

Answer: Loading the driver or drivers you want to use is very simple and involves just one line of code.

If, for example, you want to use the JDBC-ODBC Bridge driver, the following code will load it:

Eg.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Your driver documentation will give you the class name to use. For instance, if the class name is jdbc.DriverXYZ , you would load the driver with the following line of code:

Eg.

Class.forName("jdbc.DriverXYZ");
Source: CoolInterview.com
Question: What is the advantage of using a PreparedStatement?

Answer: For SQL statements that are executed repeatedly, using a PreparedStatement object would almost always be faster than using a Statement object. This is because creating a PreparedStatement object by explicitly giving the SQL statement causes the statement to be precompiled within the database immediately. Thus, when the PreparedStatement is later executed, the DBMS does not have to recompile the SQL statement and prepared an execution plan - it simply runs the statement.
Typically, PreparedSta Source: CoolInterview.com
Question: How to Make Updates to Updatable Result Sets?

Answer: Another new feature in the JDBC 2.0 API is the ability to update rows in a result set using methods in the Java programming language rather than having to send an SQL command. But before you can take advantage of this capability, you need to create a ResultSet object that is updatable.

In order to do this, you supply the ResultSet constant CONCUR_UPDATABLE to the createStatement method.

E.g.

Connection con = DriverManager.getConnection("jdbc:mySubprotocol:mySubName");
Sta Source: CoolInterview.com
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 repo Source: CoolInterview.com
Question: How can I get information about foreign keys used in a table?

Answer: DatabaseMetaData.getImportedKeys() returns a ResultSet with data about foreign key columns, tables, sequence and update and delete rules. Source: CoolInterview.com
Question: Are all the required JDBC drivers to establish connectivity to my database part of the JDK?

Answer: No. There aren't any JDBC technology-enabled drivers bundled with the JDK 1.1.x or Java 2 Platform releases other than the JDBC-ODBC Bridge. So, developers need to get a driver and install it before they can connect to a database. We are considering bundling JDBC technology- enabled drivers in the future. Source: CoolInterview.com

1 2 3 4 5 6 7 8 9 10 11 Next



India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.03125 Seconds