Showing posts with label jdbc. Show all posts
Showing posts with label jdbc. Show all posts

JDBC Interview Questions

JDBC Interview Questions
  1. How does one use the Oracle JDBC Thin Driver?
  2. Where can I find a list of the latest JDBC drivers ?
  3. Can I connect to my database from Microsoft Access or Visual Basic via ODBC? 
  4. How do I determine the number of columns in a ResultSet?
  5. What is a database URL?
  6. How do I create a database connection?
  7. What is Metadata and why should I use it?
  8. What is the advantage of using a PreparedStatement?
  9. How do I check what table types exist in a database?
  10. How do I extract SQL table column type information?
  11. How do I find all database stored procedures in a database?
  12. What properties should I supply to a database driver in order to connect to a database?
  13. Which is the preferred collection class to use for storing database result sets?
  14. Do I need to commit after an INSERT call in JDBC or does JDBC do it automatically in the DB?
  15. How can I make batch updates using JDBC?
  16. The java.sql package contains mostly interfaces. When and how are these interfaces implemented while connecting to database?
  17. How do i insert an image file (or other raw data) into a database?
  18. How can resultset records be restricted to certain rows?
  19. In distributed architecture (typical three tier consisting of thin client, middleware & database) which type of JDBC driver should be used and why?
  20. How do I pass a Timestamp from JDBC to a database?
  21. Will a call to PreparedStatement.executeQuery() always close the ResultSet from the previous executeQuery()?
  22. How can I get data from multiple ResultSets?

JDBC Technical Interview Questions

JDBC Interview Questions
1) Are all the required JDBC drivers to establish connectivity to my database part of the JDK?

2) Are the code examples from the JDBC API Tutorial and Reference, Second Edition available online?

3)Are there any ODBC drivers that do not work with the JDBC-ODBC Bridge?

4)Can I get information about a ResultSet's associated Statement and Connection in a method without having or adding specific arguments for the Statement and Connection?

5)Can I set up a conection pool with multiple user IDs? The single ID we are forced to use causes probelems when debugging the DBMS.

6)Can I use JDBC to execute non-standard features that my DBMS provides?

7)Can I use the JDBC-ODBC bridge driver in an applet?
8) Can ResultSets be passed between methods of a class? Are there any special usage How can I convert a java array to a java.sql.Array?

9) Can the JDBC-ODBC Bridge be used with applets?

10)Can you scroll a result set returned from a stored procedure?...

11)Connecting to a database through the Proxy I want to connect to remote database using a program that is running in the local network behind the proxy. Is that possible?

12)Could we get sample code for retrieving more than one parameter from a

13)DB2 Universal claims to support JDBC 2.0, But I can only get JDBC 1.0 functionality. What can I do?

14)Detecting Duplicate Keys I have a program that inserts rows in a table ...

15)Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?

16)Does the JDBC-ODBC Bridge support the new features in the JDBC 3.0 API?

17)Does the database server have to be running Java or have Java support in order for my remote JDBC client app to access the database?

18)How can I connect from an applet to a database on the server?

19)How can I connect to an Excel spreadsheet file using jdbc?

20)How can I connect to an Oracle database not on the web server from an untrusted applet?

21)How can I create a custom RowSetMetaData object from scratch?

22)How can I determine the isolation levels supported by my DBMS?

23)How can I determine where a given table is referenced via foreign keys?

24)How can I determine whether a Statement and its ResultSet will be closed on a

25)How can I get data from multiple ResultSets?

26)How can I get information about foreign keys used in a table?

27)How can I get or redirect the log used by DriverManager and JDBC drivers?

28)How can I insert images into a Mysql database?

29)How can I insert multiple rows into a database in a single transaction?

30)How can I instantiate and load a new CachedRowSet object from a non-JDBC source?

31)How can I investigate the parameters to send into and receive from a database stored procedure?

32)How can I investigate the physical structure of a database?

33)How can I know when I reach the last record in a table, since JDBC doesn't provide an EOF method?

34)How can I make batch updates using JDBC?

35)How can I pool my database connections so I don't have to keep reconnecting to the database?

36)How can I retrieve a String or other object type without creating a new object each time?

37)How can I retrieve string data from a database in Unicode format?

38)How can I tell if my JDBC driver normalizes java.sql.Date and java.sql.Time objects?

39)How can I use the JDBC API to access a desktop database like Microsoft Access over the network?

40)How can I write to the log used by DriverManager and JDBC drivers?

41)How can resultset records be restricted to certain rows?

42)How do I check in my code whether a maximum limit of database connections have been reached?

43)How do I check what table types exist in a 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.