Subject FBStatementFactory.java patch
Author Alexey Panchenko
Hi,

In the current version when exception occurs due to error in statement
the thrown exception has empty message.

This patch solves this problem.

Index: FBStatementFactory.java
===================================================================
RCS file: /cvsroot/firebird/client-java/src/main/org/firebirdsql/jdbc/FBStatementFactory.java,v
retrieving revision 1.6
diff -u -r1.6 FBStatementFactory.java
--- FBStatementFactory.java 20 Jan 2006 04:09:34 -0000 1.6
+++ FBStatementFactory.java 15 Aug 2006 05:32:42 -0000
@@ -21,6 +21,7 @@
package org.firebirdsql.jdbc;

import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;

import org.firebirdsql.gds.ClassFactory;
import org.firebirdsql.gds.impl.GDSHelper;
@@ -35,6 +36,19 @@
public class FBStatementFactory {

/**
+ * @param e
+ * @return creates a new FBSQLException or extracts wrapped one.
+ */
+ private static FBSQLException convert(InvocationTargetException e) {
+ if (e.getTargetException() instanceof FBSQLException) {
+ return (FBSQLException) e.getTargetException();
+ }
+ else {
+ return new FBSQLException(e);
+ }
+ }
+
+ /**
* @return a new instance of FBCallableStatement.
*/
public static AbstractCallableStatement createCallableStatement(GDSHelper gdsHelper,
@@ -52,8 +66,11 @@
sql, new Integer(resultSetType), new Integer(resultSetConcurrency),
new Integer(resultSetHoldability), statementListener, blobListener });

- } catch (Exception e) {
-
+ }
+ catch (InvocationTargetException e) {
+ throw convert(e);
+ }
+ catch (Exception e) {
throw new FBSQLException(e);

}
@@ -80,8 +97,11 @@
new Integer(resultSetHoldability), statementListener, blobListener,
new Boolean(metadata) });

- } catch (Exception e) {
-
+ }
+ catch (InvocationTargetException e) {
+ throw convert(e);
+ }
+ catch (Exception e) {
throw new FBSQLException(e);

}
@@ -101,8 +121,11 @@
return (AbstractSavepoint) constructor
.newInstance(new Object[] { new Integer(counter) });

- } catch (Exception e) {
-
+ }
+ catch (InvocationTargetException e) {
+ throw convert(e);
+ }
+ catch (Exception e) {
throw new FBSQLException(e);

}
@@ -121,8 +144,11 @@

return (AbstractSavepoint) constructor.newInstance(new Object[] { name });

- } catch (Exception e) {
-
+ }
+ catch (InvocationTargetException e) {
+ throw convert(e);
+ }
+ catch (Exception e) {
throw new FBSQLException(e);

}
@@ -146,8 +172,11 @@
new Integer(resultSetType), new Integer(resultSetConcurrency),
new Integer(resultSetHoldability), statementListener });

- } catch (Exception e) {
-
+ }
+ catch (InvocationTargetException e) {
+ throw convert(e);
+ }
+ catch (Exception e) {
throw new FBSQLException(e);

}


--
Best regards,
Alexey mailto:alex+news@...