DEVFYI - Developer Resource - FYI

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

JDBC Interview Questions and Answers


(Continued from previous question...)

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

Use DatabaseMetaData.getMaxConnections() and compare to the number of connections currently open. Note that a return value of zero can mean unlimited or, unfortunately, unknown. Of course, driverManager.getConnection() will throw an exception if a Connection can not be obtained.


Why do I get UnsatisfiedLinkError when I try to use my JDBC driver?

The first thing is to be sure that this does not occur when running non-JDBC apps. If so, there is a faulty JDK/JRE installation. If it happens only when using JDBC, then it's time to check the documentation that came with the driver or the driver/DBMS support. JDBC driver types 1 through 3 have some native code aspect and typically require some sort of client install. Along with the install, various environment variables and path or classpath settings must be in place. Because the requirements and installation procedures vary with the provider, there is no reasonable way to provide details here. A type 4 driver, on the other hand, is pure Java and should never exhibit this problem. The trade off is that a type 4 driver is usually slower.

(Continued on next question...)

Other Interview Questions