-
1. Re: How to handle TeiidSQLException in jsp page
shawkins Jan 25, 2018 9:21 AM (in response to m.ardito)That looks odd. It probably means there is a class loading issue - if this is using embedded Teiid in WildFly it should be referencing the client module, not including another copy of the client jar. Otherwise you can also switch to just catching SQLException.
-
2. Re: How to handle TeiidSQLException in jsp page
m.ardito Jan 25, 2018 9:32 AM (in response to shawkins)I get the same error even with SQLException or Exception...
it's not Teiid embedded, it's the wildfly/teiid bundle...
I get the above error, if I import org.teiid.jdbc.*
If I don't add org.teiid.jdbc.*, I get
13:42:26,898 ERROR [io.undertow.request] (default task-7) UT005023: Exception handling request to /jsptest4/test.jsp: org.apache.jasper.JasperException: JBWEB0 04062: Unable to compile class for JSP: JBWEB004060: An error occurred at line: 72 in the jsp file: /test.jsp TeiidSQLException cannot be resolved to a type 69: try { 70: rs.first(); 71: out.println("record found"); 72: } catch (TeiidSQLException e) { 73: out.println("record not found"); 74: } 75: Stacktrace: at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:95)
...?
-
3. Re: How to handle TeiidSQLException in jsp page
shawkins Jan 25, 2018 9:37 AM (in response to m.ardito)> I get the same error even with SQLException or Exception...
That seems almost impossible. Are you sure the exception is being emitted from where you think?
> it's not Teiid embedded, it's the wildfly/teiid bundle...
Sorry, I wasn't using proper terminology - if it's using a local, non-socket connection, then it should be using the same module as wildfly and not include a separate dependency.
-
4. Re: How to handle TeiidSQLException in jsp page
m.ardito Jan 25, 2018 10:20 AM (in response to shawkins)Ok, I found the error (mine), you were right, is thrown by a later point...
reading better,
ResultSet (Java Platform SE 8 ) says:
Throws: SQLException - if a database access error occurs; this method is called on a closed result set or the result set type is TYPE_FORWARD_ONLY
...of course if I have "no record found" it doesn't throw an exception... for that I have to try to fetch a field value, as
try { String fv = rs.getString("request"); out.println("record found -"); } catch (java.lang.Throwable t) { if (!(t instanceof org.teiid.jdbc.TeiidSQLException)){ out.println("record not found - TeiidSQLException"); } else { out.println("record not found - Generic"); } }
which throws (and catches) TeiidSQLException
or, better just check if there are records with something like
try { rs.last(); size = rs.getRow(); rs.beforeFirst(); out.println("record found -" + size); }
and then manage the case where size == 0
Thanks...
-
5. Re: How to handle TeiidSQLException in jsp page
shawkins Jan 25, 2018 10:27 AM (in response to m.ardito)> and then manage the case where size == 0
It seems like this logic will require you to have a scrollable result set which will add overhead. If all you need to do is check for having a result, you would just check the boolean result of ResultSet.next().
-
6. Re: How to handle TeiidSQLException in jsp page
m.ardito Jan 26, 2018 3:40 AM (in response to shawkins)...yes, right... I'm just digging into java again after years, to create in wildfly/teiid server a jasper reports report "lan distribution point" (just the library used by a jsp) to bring all the teiid power into paper , still have to grasp all the methods details... a bit confused... thanks...