سه‌شنبه، آبان ۱۹، ۱۳۸۸

Polite Exceptions

As you already know Java has two kinds of exceptions. Checked and unchecked. In the former version compiler complains about the possibility of something going wrong and forces you to handle the doomsday scenario! but unchecked exceptions are happening at runtime and .... Read the rest in a Java text book.

Last week I was working on JBoss, trying to get a DB2 connection from JBoss's connection pool and it threw an exception. It was really a very polite exception:
18:56:50,238 INFO [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.jdk5.WrappedConnectionJDK5@1e120da
java.lang.Throwable: STACKTRACE
at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:290)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:423)
at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
....
It was the best exception of my life! It closed the connection for me and told me PLEASE close it yourself! :)

This post does not intend to be technical but if you encountered the same problem leave a comment here and I will tell you how I managed to solve it.

هیچ نظری موجود نیست:

ارسال یک نظر