You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by Ryan Lubke <Ry...@Sun.COM> on 2002/04/30 14:37:29 UTC

[Fwd: [PATCH][Standard] Improved error reporting for Query and Update support classes]

Not sure what happened to the Resources.properties patch.  A new one has
been attached to this message.

-----Forwarded Message-----

From: Ryan Lubke <Ry...@sun.com>
To: taglibs-dev@jakarta.apache.org
Subject: [PATCH][Standard] Improved error reporting for Query and Update support classes
Date: 30 Apr 2002 05:32:31 -0700

Hi,

Currently, if there is a problem obtaining a connection via a datasource
(invalid URL, the server isn't up, etc) an error in the form of "Unable
to get connection, DataSource invalid".

It's very difficult, based on the current error message, to determine
what exactly the problem is.

I've attached a patch that adds a parameter to the Resource.properties
for this particular error message to input the message of the exception.

With the patch, if there is a problem, an error similar to this is
generated:

Unable to get connection, DataSource invalid: "Connection refused to
host: rivendell; nested exception is: 
	java.net.ConnectException: Connection refused"



----


Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties,v
retrieving revision 1.31
diff -u -r1.31 Resources.properties
--- Resources.properties	29 Apr 2002 19:39:43 -0000	1.31
+++ Resources.properties	30 Apr 2002 11:26:51 -0000
@@ -1,295 +0,0 @@
-#########################################################################
-# Conventions:
-# - For error messages from particular tags, the resource should
-#     - (a) have a name beginning with TAGNAME_
-#     - (b) contain the name of the tag within the message
-# - Generic tag messages -- i.e., those used in more than one tag --
-#   should begin with TAG_
-# - Errors for TagLibraryValidators should begin with TLV_
-#########################################################################
-
-
-#########################################################################
-# Generic tag error messages
-#########################################################################
-
-TAG_NULL_ATTRIBUTE=\
-    The "{0}" attribute illegally evaluated to "null" or "" in &lt;{1}&gt;
-
-#########################################################################
-# Specific tag error messages
-#########################################################################
-
-# CORE
-
-CHOOSE_EXCLUSIVITY=\
-    Only one &lt;choose&gt; subtag may evaluate its body
-
-EXPR_BAD_VALUE=\
-    In &lt;expr&gt;, attribute value="{0}" didn't evaluate successfully, \
-    but there was no "default" attribute and no non-whitespace content \
-    for the tag.
-
-FOREACH_STEP_NO_RESULTSET=\
-    Step cannot be > 1 when iterating over a ResultSet with &lt;forEach&gt;
-
-FOREACH_BAD_ITEMS=\
-    Don't know how to iterate over supplied "items" in &lt;forEach&gt;
-
-IMPORT_BAD_RELATIVE=\
-    In URL tags, when the "context" attribute is specified, \
-    values of both "context" and "url" must start with "/".
-
-IMPORT_REL_WITHOUT_HTTP=\
-    Relative &lt;import&gt; from non-HTTP request not allowed
-    
-IMPORT_REL_WITHOUT_DISPATCHER=\
-    Unable to get RequestDispatcher for Context: "{0}" and URL: "{1}". \
-    Verify values and/or enable cross context access.
-
-IMPORT_IO=\
-    I/O error in &lt;import&gt; occurred reading "{0}"
-
-IMPORT_ILLEGAL_STREAM=\
-    Unexpected internal error during &lt;import&gt: \
-    Target servlet called getWriter(), then getOutputStream()
-
-IMPORT_ILLEGAL_WRITER=\
-    Unexpected internal error during &lt;import&gt: \
-    Target servlet called getOutputStream(), then getWriter()
-
-#IMPORT_ILLEGAL_GETSTRING=\
-#    Unexpected internal error during &lt;import&gt: \
-#    Target servlet called neither getOutputStream() nor getWriter()
-
-PARAM_OUTSIDE_PARENT=\
-    &lt;param&gt; outside &lt;import&gt; or &lt;urlEncode&gt;
-
-PARAM_ENCODE_BOOLEAN=\
-    In &lt;param&gt;, "encode" must be "true" or "false".  Got "{0}" instead.
-
-SET_BAD_SCOPE=\
-    Invalid "scope" attribute for &lt;set&gt;:  "{0}"
-
-SET_INVALID_PROPERTY=\
-    Invalid property in &lt;set&gt;:  "{0}"
-
-SET_INVALID_TARGET=\
-    Attempt to set the property of an invalid object in &lt;set&gt;.
-
-SET_NO_VALUE=\
-    Need either non-whitespace body or "value" attribute in &lt;set&gt;
-
-URLENCODE_NO_VALUE=\
-    Need either non-whitespace body or "value" attribute in &lt;urlEncode&gt;
-
-WHEN_OUTSIDE_CHOOSE=\
-    Illegal use of &lt;when&gt;-style tag without &lt;choose&gt; as its \
-    direct parent
-
-# I18N
-
-LOCALE_NO_LANGUAGE=\
-    Missing language component in 'value' attribute in &lt;setLocale&gt; 
-
-LOCALE_EMPTY_COUNTRY=\
-    Empty country component in 'value' attribute in &lt;setLocale&gt;
-
-PARAM_OUTSIDE_MESSAGE=\
-    &lt;param&gt; outside &lt;message&gt;
-
-MESSAGE_NO_KEY=\
-    &lt;message&gt; needs 'key' attribute or non-whitespace body
-
-FORMAT_NUMBER_INVALID_TYPE=\
-    In &lt;formatNumber&gt;, invalid 'type' attribute: "{0}"
-
-FORMAT_NUMBER_NO_VALUE=\
-    &lt;formatNumber&gt; needs 'value' attribute or non-whitespace body
-
-FORMAT_NUMBER_PARSE_ERROR=\
-    In &lt;formatNumber&gt;, 'value' attribute can not be parsed into java.lang.Number: "{0}"
-
-PARSE_NUMBER_INVALID_TYPE=\
-    In &lt;parseNumber&gt;, invalid 'type' attribute: "{0}"
-
-PARSE_NUMBER_NO_VALUE=\
-    &lt;parseNumber&gt; needs 'value' attribute or non-whitespace body
-
-PARSE_NUMBER_NO_PARSE_LOCALE=\
-    In &lt;parseNumber&gt;, a parse locale can not be established
-
-PARSE_NUMBER_PARSE_ERROR=\
-    In &lt;parseNumber&gt;, 'value' attribute can not be parsed: "{0}"
-
-FORMAT_DATE_INVALID_TYPE=\
-    In &lt;formatDate&gt;, invalid 'type' attribute: "{0}"
-
-FORMAT_DATE_BAD_TIMEZONE=\
-    In &lt;formatDate&gt;, 'timeZone' must be an instance of java.lang.String or java.util.TimeZone
-
-FORMAT_DATE_INVALID_DATE_STYLE=\
-    In &lt;formatDate&gt;, invalid 'dateStyle' attribute: "{0}"
-
-FORMAT_DATE_INVALID_TIME_STYLE=\
-    In &lt;formatDate&gt;, invalid 'timeStyle' attribute: "{0}"
-
-PARSE_DATE_INVALID_TYPE=\
-    In &lt;parseDate&gt;, invalid 'type' attribute: "{0}"
-
-PARSE_DATE_BAD_TIMEZONE=\
-    In &lt;parseDate&gt;, 'timeZone' must be an instance of java.lang.String or java.util.TimeZone
-
-PARSE_DATE_INVALID_DATE_STYLE=\
-    In &lt;parseDate&gt;, invalid 'dateStyle' attribute: "{0}"
-
-PARSE_DATE_INVALID_TIME_STYLE=\
-    In &lt;parseDate&gt;, invalid 'timeStyle' attribute: "{0}"
-
-PARSE_DATE_NO_VALUE=\
-    &lt;parseDate&gt; needs 'value' attribute or non-whitespace body
-
-PARSE_DATE_PARSE_ERROR=\
-    In &lt;parseDate&gt;, 'value' attribute can not be parsed: "{0}"
-
-PARSE_DATE_NO_PARSE_LOCALE=\
-    In &lt;parseDate&gt;, a parse locale can not be established
-
-UNDEFINED_KEY=\
-    Undefined key "{0}" in resource bundle "{1}"
-
-MISSING_RESOURCE_BUNDLE=\
-    Resource bundle with base name "{0}" not found
-
-# SQL
-
-DRIVER_INVALID_CLASS=\
-    In &lt;driver&gt;, invalid driver class name: "{0}"
-
-DATASOURCE_INVALID=\
-    Unable to get connection, DataSource invalid
- 
-JDBC_PARAM_COUNT=\
-    Invalid number of JDBC parameters specified.
-
-PARAM_BAD_VALUE=\
-    Invalid or out of bounds value specified in parameter.
- 
-TRANSACTION_NO_SUPPORT=\
-    In &lt;transaction&gt;, datasource does not support transactions
-
-TRANSACTION_COMMIT_ERROR=\
-    In &lt;transaction&gt;, error committing transaction: "{0}"
-
-TRANSACTION_INVALID_ISOLATION=\
-    In &lt;transaction&gt;, invalid transaction isolation
-
-NOT_SUPPORTED=\
-    Not supported
-
-ERROR_GET_CONNECTION=\
-    Error getting connection: "{0}"
-
-ERROR_NESTED_DATASOURCE=\
-    It is illegal to specify a DataSource when nested within a &lt;transaction&gt;
-
-SQL_PARAM_OUTSIDE_PARENT=\
-    &lt;param&gt; or &lt;dateParam&gt; must be subtag of SQLExecutionTag actions like &lt;query&gt; or &lt;update&gt;
-
-SQL_NO_STATEMENT=\
-    No SQL statement specified
-
-SQL_PROCESS_ERROR=\
-    Error processing SQL: "{0}"
-
-SQL_DATASOURCE_INVALID_TYPE=\
-    'dataSource' is neither a String nor a javax.sql.DataSource
-
-SQL_DATASOURCE_NULL=\
-    'dataSource' is null
-
-SQL_MAXROWS_PARSE_ERROR=\
-    Error parsing 'javax.servlet.jsp.jstl.sql.maxRows' configuration setting: "{0}"
-
-SQL_MAXROWS_INVALID=\
-    'javax.servlet.jsp.jstl.sql.maxRows' configuration setting neither an Integer nor a String
-
-SQL_DATE_PARAM_INVALID_TYPE=\
-    In &lt;dateParam&gt;, invalid 'type' attribute: "{0}"
-
-# XML
-
-FOREACH_NOT_NODESET=\
-    &lt;forEach&gt; can't iterate over XPath expressions that don't return a node-set
-
-PARAM_NO_VALUE=\
-    &lt;param&gt; needs 'value' attribute or non-whitespace body
-
-PARAM_OUTSIDE_TRANSFORM=\
-    &lt;param&gt; outside &lt;transform&gt;
-
-PARSE_INVALID_SOURCE=\
-    Unrecognized object supplied as 'xmlText' attribute to &lt;parse&gt;
-
-PARSE_NO_SAXTRANSFORMER=\
-    Filter supplied to &lt;parse&gt;, but default TransformerFactory \
-    does not support SAX.
-
-TRANSFORM_NO_TRANSFORMER=\
-    &lt;transform&gt; needs either an 'xslt' attribute or a \
-    'transformer' attribute
-
-TRANSFORM_SOURCE_INVALID_LIST=\
-    &lt;transform&gt; encountered an invalid java.util.List while processing 'xmlText' attribute.  This error is typically caused if you pass a node-set with more than one node to &lt;transform&gt;'s 'xmlText' attribute.
-
-TRANSFORM_SOURCE_UNRECOGNIZED=\
-    &lt;transform&gt; encountered an unknown type while processing 'xmlText' attribute
-
-UNABLE_TO_RESOLVE_ENTITY=\
-    Could not resolve entity reference: "{0}"
-
-#########################################################################
-# JSTL core TLV messages
-#########################################################################
-
-# Parameters 
-
-TLV_PARAMETER_ERROR=\
-    Invalid value for "{0}" validator parameter in TLD
-
-# Generic errors
-
-TLV_ILLEGAL_BODY=\
-    Encountered illegal body of tag "{0}" tag, given its attributes.
-
-TLV_MISSING_BODY=\
-    A body is necessary inside the "{0}" tag, given its attributes.
-
-TLV_ILLEGAL_CHILD_TAG=\
-    Illegal child tag in "{0}:{1}" tag: "{2}" tag
-
-TLV_ILLEGAL_TEXT_BODY=\
-    Illegal text inside "{0}:{1}" tag: "{2}...".
-
-TLV_INVALID_ATTRIBUTE=\
-    Invalid "{0}" attribute in "{1}" tag: "{2}"
-
-TLV_ILLEGAL_ORPHAN=\
-    Invalid use of "{0}" tag outside legitimate parent tag
-
-TLV_PARENT_WITHOUT_SUBTAG=\
-    Illegal "{0}" without child "{1}" tag
-
-# Errors customized to particular tags (sort of)  :-)
-
-TLV_ILLEGAL_ORDER=\
-    Illegal "{0}" after "{1}:{2}" tag in "{1}:{3}" tag.
-
-TLV_ILLEGAL_PARAM=\
-    Illegal "{0}:{1}" tag within "{0}:{2} {3}='...'" tag
-
-TLV_DANGLING_SCOPE=\
-    Illegal 'scope' attribute without 'var' in "{0}" tag.
-
-TLV_EMPTY_VAR=\
-    Empty 'var' attribute in "{0}" tag.
----


Index: QueryTagSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/QueryTagSupport.java,v
retrieving revision 1.30
diff -u -r1.30 QueryTagSupport.java
--- QueryTagSupport.java	29 Apr 2002 16:35:04 -0000	1.30
+++ QueryTagSupport.java	30 Apr 2002 11:27:24 -0000
@@ -306,7 +306,8 @@
 	        conn = dataSource.getConnection();
             } catch (Exception ex) {
                 throw new JspException(
-                    Resources.getMessage("DATASOURCE_INVALID"));
+                    Resources.getMessage("DATASOURCE_INVALID", 
+                                         ex.getMessage()));
             }
 	}
 
----


Index: UpdateTagSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/UpdateTagSupport.java,v
retrieving revision 1.20
diff -u -r1.20 UpdateTagSupport.java
--- UpdateTagSupport.java	25 Apr 2002 00:25:16 -0000	1.20
+++ UpdateTagSupport.java	30 Apr 2002 11:27:43 -0000
@@ -268,7 +268,8 @@
                 conn = dataSource.getConnection();
             } catch (Exception ex) {
                 throw new JspException(
-                    Resources.getMessage("DATASOURCE_INVALID"));
+                    Resources.getMessage("DATASOURCE_INVALID",
+                                         ex.getMessage()));
             }
 	}
 

----


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>