Showing posts with label JDBC interview question and answers. Show all posts
Showing posts with label JDBC interview question and answers. Show all posts

JDBC Faqs

JDBC Interview Faqs
# How do I check what table-like database objects (table, view, temporary table,

# How do I create a database connection?

# How do I create a java.sql.Date object?

# How do I create a java.sql.Time object?

# How do I create an updatable ResultSet?

# How do I disallow NULL values in a table?

# How do I display and parse a date?

# How do I execute stored procedures?

# How do I extract SQL table column type information?

# How do I extract a BLOB from a database?

# How do I extract the SQL statements required to move all tables and views from an existing database to another database?

# How do I find all database stored procedures in a database?

# How do I get runtime information about the JDBC Driver?

# How do I implement a RowSetReader? I want to populate a CachedRowSet myself and the documents specify that a RowSetReader should be used.The single method accepts a RowSetInternal caller and returns void. What can I do in the readData method?

# How do I insert a .jpg into a mySQL data base?

# How do I insert an image file (or other raw data) into a database?

# How do I receive a ResultSet from a stored procedure?

# How do I retrieve a whole row of data at once, instead of calling an individual ResultSet.getX.X.X method for each column?

# How do I set properties for a JDBC driver and where are the properties stored?

# How do I start debugging problems related to the JDBC API?

# How do I write Greek ( or other non-ASCII/8859-1 ) characters to a database?

# How do you handle your own transaction ?

# How does a custom RowSetReader get called from a CachedRowSet?

# How does one get column names for rows returned in a ResultSet?

# How does the Java Database Connectivity (JDBC) work?

# How many types of JDBC Drivers are present and what are they?

# How to insert and delete a row programmatically? (new feature in JDBC 2.0)

# How to move the cursor in scrollable resultsets?(new feature in JDBC 2.0)

# How to update a resultset programmatically? (new feature in JDBC 2.0)

# I have an application that queries a database and retreives the results into a

# I need to have result set on a page where the user can sort on the column headers. Any ideas?

# I would like to download the JDBC-ODBC Bridge for the Java 2 SDK, Standard Edition (formerly JDK 1.2). I'm a beginner with the JDBC API, and I would like to start with the Bridge. How do I do it?

# If I use the JDBC API, do I have to use ODBC underneath?

# Is is possible to open a connection to a database with exclusive mode with JDBC?

# Is the JDBC-ODBC Bridge multi-threaded?

# Is there a practical limit for the number of SQL statements that can be added to an instance of a Statement object
# JTable ...

# Many connections from an Oracle8i pooled connection returns statement closed. I am using import oracle.jdbc.pool.* with thin driver. If I test with many simultaneous connections, I get an SQLException that the statement is closed. How can I overwrite blob data in an Oracle database? ...

# Once I have the Java 2 SDK, Standard Edition, from Sun, what else do I need to connect to a database?

# The java.sql package contains mostly interfaces. When and how are these

# There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set?

# Update fails without blank padding. Alhough a particular row is present in the database for a given key, executeUpdate() shows 0 rows updated and, in fact, the table is not updated. If I pad the Key with spaces for the column length (eg if the key column is 20 characters long, and key is msgID, length 6, I pad it with 14 spaces), the update then works!!! Is there any solution to this problem without padding?What isolation level is used by the DBMS when inserting, updating and

# Whan happens when I close a Connection application obtained from a connection Pool? How does a connection pool maintain the Connections that I had closed through the application?

# What JDBC objects generate SQLWarnings?

# What are four types of JDBC driver?

# What are stored procedures?

# What are the common tasks of JDBC?

# What are the components of the JDBC URL for Oracle's "thin" driver and how do I use them?

# What are the considerations for deciding on transaction boundaries?

# What are the different JDB drivers available?

# What are the standard isolation levels defined by JDBC?

# What are the steps required to execute a query in JDBC?

# What are the two major components of JDBC?

# What causes the "No suitable driver" error?

# What does Class.forName return?

# What does it mean to "materialize" data?

# What does normalization mean for java.sql.Date and java.sql.Time?

# What does setFetchSize() really do?

# What driver should I use for scalable Oracle JDBC applications?

# What is Connection pooling?

# What is Connection?

# What is DML?

# What is DriverManager ?

# What is JDBC Driver ?

# What is JDBC Driver interface?

# What is JDBC?

# What is JDO?

# What is Metadata and why should I use it?

# What is a JDBC 2.0 DataSource?

# What is a ResultSet ?

# What is an SQL Locator?

# What is cold backup, hot backup, warm backup recovery?

# What is new in JDBC 2.0?

# What is optimistic concurrency?

# What is pessimistic concurrency?

# What is the JDBC syntax for using a date literal or variable in a standard Statement?

# What is the JDBC syntax for using a literal or variable in a standard Statement?

# What is the advantage of denormalization?

# What is the advantage of using a PreparedStatement?

# What is the best way to generate a universally unique object ID? Do I need to

# What is the difference between client and server database cursors?

# What is the difference between setMaxRows(int) and SetFetchSize(int)? Can either reduce processing time?

# What is the fastest type of JDBC driver?

# What is the most efficient method of replicating data betwen databases using JDBC?

# What is the query used to display all tables names in SQL Server (Query analyzer)?

# What is the significance of DataBaseMetaData.tableIndexStatistics? How to

# What scalar functions can I expect to be supported by JDBC?

# What types of DataSource objects are specified in the Optional Package?

# What's the JDBC 3.0 API?

# What's the best way, in terms of performance, to do multiple insert/update statements, a PreparedStatement or Batch Updates?

# What's the fastest way to normalize a Time object?

# When I intersperse table creation or other DDL statements with DML statements ....

# When an SQL select statement doesn't return any rows, is an SQLException thrown?

# Where can I find info, frameworks and example source for writing a JDBC driver?

# Which Java and java.sql data types map to my specific database types?

# Which is the preferred collection class to use for storing database result sets?

# Which type of JDBC driver is the fastest one?

# Why can't I invoke the ResultSet methods afterLast and beforeFirst when the method next works?

# Why can't Tomcat find my Oracle JDBC drivers in classes111.zip?

# Why do I have to reaccess the database for Array, Blob, and Clob data?

# Why does the ODBC driver manager return 'Data source name not found and no default driver specified Vendor: 0' How to use JDBC to connect Microsoft Access?

# Why doesn't JDBC accept URLs instead of a URL string?

# Why isn't the java.sql.DriverManager class being found?

# Why should I consider optimistic versus pessimistic approaches to database

# alias) are present in a particular database?

Why isn't the java.sql.DriverManager class being found? -JDBC

This problem can be caused by running a JDBC applet in a browser that supports the JDK 1.0.2, such as Netscape Navigator 3.0. The JDK 1.0.2 does not contain the JDBC API, so the DriverManager class typically isn't found by the Java virtual machine running in the browser.
Here's a solution that doesn't require any additional configuration of your web clients. Remember that classes in the java.* packages cannot be downloaded by most browsers for security reasons. Because of this, many vendors of all-Java JDBC drivers supply versions of the java.sql.* classes that have been renamed to jdbc.sql.*, along with a version of their driver that uses these modified classes. If you import jdbc.sql.* in your applet code instead of java.sql.*, and add the jdbc.sql.* classes provided by your JDBC driver vendor to your applet's codebase, then all of the JDBC classes needed by the applet can be downloaded by the browser at run time, including the DriverManager class.
This solution will allow your applet to work in any client browser that supports the JDK 1.0.2. Your applet will also work in browsers that support the JDK 1.1, although you may want to switch to the JDK 1.1 classes for performance reasons. Also, keep in mind that the solution outlined here is just an example and that other solutions are possible.

JDBC Interview faqs

JDBC Interview faqs
What is JDBC?
JDBC may stand for Java Database Connectivity. It is also a trade mark. JDBC is a layer of abstraction that allows users to choose between databases. It allows you to change to a different database engine and to write to a single API. JDBC allows you to write database applications in Java without having to concern yourself with the underlying details of a particular database.
What's the JDBC 3.0 API?
The JDBC 3.0 API is the latest update of the JDBC API. It contains many features, including scrollable result sets and the SQL:1999 data types.
JDBC (Java Database Connectivity) is the standard for communication between a Java application and a relational database. The JDBC API is released in two versions; JDBC version 1.22 (released with JDK 1.1.X in package java.sql) and version 2.0 (released with Java platform 2 in packages java.sql and javax.sql). It is a simple and powerful largely database-independent way of extracting and inserting data to or from any database.
Does the JDBC-ODBC Bridge support the new features in the JDBC 3.0 API?
The JDBC-ODBC Bridge provides a limited subset of the JDBC 3.0 API.
Can the JDBC-ODBC Bridge be used with applets?
Use of the JDBC-ODBC bridge from an untrusted applet running in a browser, such as Netscape Navigator, isn't allowed. The JDBC-ODBC bridge doesn't allow untrusted code to call it for security reasons. This is good because it means that an untrusted applet that is downloaded by the browser can't circumvent Java security by calling ODBC. Remember that ODBC is native code, so once ODBC is called the Java programming language can't guarantee that a security violation won't occur. On the other hand, Pure Java JDBC drivers work well with applets. They are fully downloadable and do not require any client-side configuration.
Finally, we would like to note that it is possible to use the JDBC-ODBC bridge with applets that will be run in appletviewer since appletviewer assumes that applets are trusted. In general, it is dangerous to turn applet security off, but it may be appropriate in certain controlled situations, such as for applets that will only be used in a secure intranet environment. Remember to exercise caution if you choose this option, and use an all-Java JDBC driver whenever possible to avoid security problems.
How do I start debugging problems related to the JDBC API?
A good way to find out what JDBC calls are doing is to enable JDBC tracing. The JDBC trace contains a detailed listing of the activity occurring in the system that is related to JDBC operations.
If you use the DriverManager facility to establish your database connection, you use the DriverManager.setLogWriter method to enable tracing of JDBC operations. If you use a DataSource object to get a connection, you use the DataSource.setLogWriter method to enable tracing. (For pooled connections, you use the ConnectionPoolDataSource.setLogWriter method, and for connections that can participate in distributed transactions, you use the XADataSource.setLogWriter method.)
What is new in JDBC 2.0?
With the JDBC 2.0 API, you will be able to do the following:
Scroll forward and backward in a result set or move to a specific row (TYPE_SCROLL_SENSITIVE,previous(), last(), absolute(), relative(), etc.)
Make updates to database tables using methods in the Java programming language instead of using SQL commands.(updateRow(), insertRow(), deleteRow(), etc.)
Send multiple SQL statements to the database as a unit, or batch (addBatch(), executeBatch())
Use the new SQL3 datatypes as column values like Blob, Clob, Array, Struct, Ref.
How can I use the JDBC API to access a desktop database like Microsoft Access over the network?
Most desktop databases currently require a JDBC solution that uses ODBC underneath. This is because the vendors of these database products haven't implemented all-Java JDBC drivers.
The best approach is to use a commercial JDBC driver that supports ODBC and the database you want to use. See the JDBC drivers page for a list of available JDBC drivers.
The JDBC-ODBC bridge from Sun's Java Software does not provide network access to desktop databases by itself. The JDBC-ODBC bridge loads ODBC as a local DLL, and typical ODBC drivers for desktop databases like Access aren't networked. The JDBC-ODBC bridge can be used together with the RMI-JDBC bridge, however, to access a desktop database like Access over the net. This RMI-JDBC-ODBC solution is free.
Are there any ODBC drivers that do not work with the JDBC-ODBC Bridge?
Most ODBC 2.0 drivers should work with the Bridge. Since there is some variation in functionality between ODBC drivers, the functionality of the bridge may be affected. The bridge works with popular PC databases, such as Microsoft Access and FoxPro.
What causes the "No suitable driver" error?
"No suitable driver" is an error that usually occurs during a call to the DriverManager.getConnection method. The cause can be failing to load the appropriate JDBC drivers before calling the getConnection method, or it can be specifying an invalid JDBC URL--one that isn't recognized by your JDBC driver. Your best bet is to check the documentation for your JDBC driver or contact your JDBC driver vendor if you suspect that the URL you are specifying is not being recognized by your JDBC driver.
In addition, when you are using the JDBC-ODBC Bridge, this error can occur if one or more the the shared libraries needed by the Bridge cannot be loaded. If you think this is the cause, check your configuration to be sure that the shared libraries are accessible to the Bridge.