morgand 2003/01/25 23:21:00 Modified: jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql DataSourceUtil.java DateParamTag.java DriverTag.java ParamTag.java QueryTag.java ResultSetTag.java RowTag.java SetDataSourceTag.java SqlTagSupport.java TransactionTag.java UpdateTag.java Log: converted sql taglib from Exception to JellyTagException Revision Changes Path 1.2 +6 -6 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/DataSourceUtil.java Index: DataSourceUtil.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/DataSourceUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DataSourceUtil.java 7 Jan 2003 13:47:05 -0000 1.1 +++ DataSourceUtil.java 26 Jan 2003 07:20:59 -0000 1.2 @@ -61,7 +61,7 @@ import javax.naming.NamingException; import org.apache.commons.jelly.JellyContext; -import org.apache.commons.jelly.JellyException; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.tags.Resources; import org.apache.commons.logging.Log; @@ -90,7 +90,7 @@ * is */ static DataSource getDataSource(Object rawDataSource, JellyContext pc) - throws JellyException { + throws JellyTagException { DataSource dataSource = null; if (rawDataSource == null) { @@ -121,7 +121,7 @@ dataSource = (DataSource) rawDataSource; } else { - throw new JellyException(Resources.getMessage("SQL_DATASOURCE_INVALID_TYPE")); + throw new JellyTagException(Resources.getMessage("SQL_DATASOURCE_INVALID_TYPE")); } return dataSource; @@ -130,7 +130,7 @@ /** * Parse JDBC parameters and setup dataSource appropriately */ - private static DataSource getDataSource(String params) throws JellyException { + private static DataSource getDataSource(String params) throws JellyTagException { DataSourceWrapper dataSource = new DataSourceWrapper(); String[] paramString = new String[4]; @@ -145,7 +145,7 @@ paramString[aryCount] = params.substring(begin, index); begin = index + 1; if (++aryCount > 4) { - throw new JellyException(Resources.getMessage("JDBC_PARAM_COUNT")); + throw new JellyTagException(Resources.getMessage("JDBC_PARAM_COUNT")); } } } @@ -167,7 +167,7 @@ dataSource.setDriverClassName(paramString[1]); } catch (Exception ex) { - throw new JellyException( + throw new JellyTagException( Resources.getMessage("DRIVER_INVALID_CLASS", ex.getMessage())); } } 1.2 +5 -5 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/DateParamTag.java Index: DateParamTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/DateParamTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DateParamTag.java 7 Jan 2003 13:47:05 -0000 1.1 +++ DateParamTag.java 26 Jan 2003 07:21:00 -0000 1.2 @@ -58,7 +58,7 @@ import javax.servlet.jsp.jstl.sql.SQLExecutionTag; -import org.apache.commons.jelly.JellyException; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; @@ -105,11 +105,11 @@ //********************************************************************* // Tag logic - public void doTag(XMLOutput output) throws Exception { + public void doTag(XMLOutput output) throws JellyTagException { SQLExecutionTag parent = (SQLExecutionTag) findAncestorWithClass(this, SQLExecutionTag.class); if (parent == null) { - throw new JellyException(Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT")); + throw new JellyTagException(Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT")); } if (value != null) { @@ -122,7 +122,7 @@ //********************************************************************* // Private utility methods - private void convertValue() throws JellyException { + private void convertValue() throws JellyTagException { if ((type == null) || (type.equalsIgnoreCase(TIMESTAMP_TYPE))) { if (!(value instanceof java.sql.Timestamp)) { @@ -140,7 +140,7 @@ } } else { - throw new JellyException( + throw new JellyTagException( Resources.getMessage("SQL_DATE_PARAM_INVALID_TYPE", type)); } } 1.2 +3 -3 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/DriverTag.java Index: DriverTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/DriverTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DriverTag.java 7 Jan 2003 13:47:05 -0000 1.1 +++ DriverTag.java 26 Jan 2003 07:21:00 -0000 1.2 @@ -55,7 +55,7 @@ package org.apache.commons.jelly.tags.sql; -import org.apache.commons.jelly.JellyException; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; @@ -109,13 +109,13 @@ //********************************************************************* // Tag logic - public void doTag(XMLOutput output) throws Exception { + public void doTag(XMLOutput output) throws JellyTagException { DataSourceWrapper ds = new DataSourceWrapper(); try { ds.setDriverClassName(getDriverClassName()); } catch (Exception e) { - throw new JellyException("Invalid driver class name: " + e.getMessage()); + throw new JellyTagException("Invalid driver class name: " + e.getMessage()); } ds.setJdbcURL(getJdbcURL()); ds.setUserName(getUserName()); 1.2 +3 -3 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/ParamTag.java Index: ParamTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/ParamTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ParamTag.java 7 Jan 2003 13:47:05 -0000 1.1 +++ ParamTag.java 26 Jan 2003 07:21:00 -0000 1.2 @@ -56,7 +56,7 @@ import javax.servlet.jsp.jstl.sql.SQLExecutionTag; -import org.apache.commons.jelly.JellyException; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; @@ -79,11 +79,11 @@ //********************************************************************* // Tag logic - public void doTag(XMLOutput output) throws Exception { + public void doTag(XMLOutput output) throws JellyTagException { SQLExecutionTag parent = (SQLExecutionTag) findAncestorWithClass(this, SQLExecutionTag.class); if (parent == null) { - throw new JellyException(Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT")); + throw new JellyTagException(Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT")); } Object paramValue = value; 1.2 +7 -7 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/QueryTag.java Index: QueryTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/QueryTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- QueryTag.java 7 Jan 2003 13:47:05 -0000 1.1 +++ QueryTag.java 26 Jan 2003 07:21:00 -0000 1.2 @@ -63,7 +63,7 @@ import javax.servlet.jsp.jstl.sql.Result; -import org.apache.commons.jelly.JellyException; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; import org.apache.commons.logging.Log; @@ -138,7 +138,7 @@ * element, or is retrieved from a JSP scope attribute * named <code>javax.servlet.jstl.sql.dataSource</code>. */ - public void doTag(XMLOutput output) throws Exception { + public void doTag(XMLOutput output) throws JellyTagException { if (!maxRowsSpecified) { Object obj = context.getVariable("org.apache.commons.jelly.sql.maxRows"); @@ -151,13 +151,13 @@ maxRows = Integer.parseInt((String) obj); } catch (NumberFormatException nfe) { - throw new JellyException( + throw new JellyTagException( Resources.getMessage("SQL_MAXROWS_PARSE_ERROR", (String) obj), nfe); } } else { - throw new JellyException(Resources.getMessage("SQL_MAXROWS_INVALID")); + throw new JellyTagException(Resources.getMessage("SQL_MAXROWS_INVALID")); } } } @@ -183,13 +183,13 @@ sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { - throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); + throw new JellyTagException(Resources.getMessage("SQL_NO_STATEMENT")); } /* * We shouldn't have a negative startRow or illegal maxrows */ if ((startRow < 0) || (maxRows < -1)) { - throw new JellyException(Resources.getMessage("PARAM_BAD_VALUE")); + throw new JellyTagException(Resources.getMessage("PARAM_BAD_VALUE")); } /* @@ -230,7 +230,7 @@ tempStatement.close(); } catch (SQLException e) { - throw new JellyException(sqlStatement + ": " + e.getMessage(), e); + throw new JellyTagException(sqlStatement + ": " + e.getMessage(), e); } finally { if (rs != null) { 1.2 +2 -1 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/ResultSetTag.java Index: ResultSetTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/ResultSetTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ResultSetTag.java 7 Jan 2003 13:47:05 -0000 1.1 +++ ResultSetTag.java 26 Jan 2003 07:21:00 -0000 1.2 @@ -58,6 +58,7 @@ import java.util.List; import java.util.Map; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; @@ -81,7 +82,7 @@ // Tag interface //------------------------------------------------------------------------- - public void doTag(XMLOutput output) throws Exception { + public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (var == null) { throw new MissingAttributeException( "var" ); } 1.2 +3 -3 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/RowTag.java Index: RowTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/RowTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RowTag.java 7 Jan 2003 13:47:05 -0000 1.1 +++ RowTag.java 26 Jan 2003 07:21:00 -0000 1.2 @@ -54,7 +54,7 @@ */ package org.apache.commons.jelly.tags.sql; -import org.apache.commons.jelly.JellyException; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MapTagSupport; import org.apache.commons.jelly.XMLOutput; @@ -67,10 +67,10 @@ // Tag interface //------------------------------------------------------------------------- - public void doTag(XMLOutput output) throws Exception { + public void doTag(XMLOutput output) throws JellyTagException { ResultSetTag tag = (ResultSetTag) findAncestorWithClass( ResultSetTag.class ); if ( tag == null ) { - throw new JellyException( "This tag must be nested with in a <resultSet> tag" ); + throw new JellyTagException( "This tag must be nested with in a <resultSet> tag" ); } tag.addRow( getAttributes() ); } 1.2 +4 -4 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/SetDataSourceTag.java Index: SetDataSourceTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/SetDataSourceTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SetDataSourceTag.java 7 Jan 2003 13:47:05 -0000 1.1 +++ SetDataSourceTag.java 26 Jan 2003 07:21:00 -0000 1.2 @@ -57,7 +57,7 @@ import javax.sql.DataSource; -import org.apache.commons.jelly.JellyException; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; @@ -132,7 +132,7 @@ //********************************************************************* // Tag logic - public void doTag(XMLOutput output) throws Exception { + public void doTag(XMLOutput output) throws JellyTagException { DataSource ds = null; if (dataSource != null) { @@ -140,7 +140,7 @@ } else { if (dataSourceSpecified) { - throw new JellyException(Resources.getMessage("SQL_DATASOURCE_NULL")); + throw new JellyTagException(Resources.getMessage("SQL_DATASOURCE_NULL")); } DataSourceWrapper dsw = new DataSourceWrapper(); @@ -152,7 +152,7 @@ } catch (Exception e) { log.error( "Could not load driver class: " + e, e ); - throw new JellyException( + throw new JellyTagException( Resources.getMessage("DRIVER_INVALID_CLASS", e.getMessage())); } dsw.setJdbcURL(jdbcURL); 1.2 +5 -5 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/SqlTagSupport.java Index: SqlTagSupport.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/SqlTagSupport.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SqlTagSupport.java 7 Jan 2003 13:47:05 -0000 1.1 +++ SqlTagSupport.java 26 Jan 2003 07:21:00 -0000 1.2 @@ -64,7 +64,7 @@ import javax.servlet.jsp.jstl.sql.SQLExecutionTag; import javax.sql.DataSource; -import org.apache.commons.jelly.JellyException; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.tags.Resources; @@ -169,7 +169,7 @@ parameters = null; } - protected Connection getConnection() throws JellyException, SQLException { + protected Connection getConnection() throws JellyTagException, SQLException { // Fix: Add all other mechanisms Connection conn = null; isPartOfTransaction = false; @@ -178,21 +178,21 @@ (TransactionTag) findAncestorWithClass(TransactionTag.class); if (parent != null) { if (dataSourceSpecified) { - throw new JellyException(Resources.getMessage("ERROR_NESTED_DATASOURCE")); + throw new JellyTagException(Resources.getMessage("ERROR_NESTED_DATASOURCE")); } conn = parent.getSharedConnection(); isPartOfTransaction = true; } else { if ((rawDataSource == null) && dataSourceSpecified) { - throw new JellyException(Resources.getMessage("SQL_DATASOURCE_NULL")); + throw new JellyTagException(Resources.getMessage("SQL_DATASOURCE_NULL")); } DataSource dataSource = DataSourceUtil.getDataSource(rawDataSource, context); try { conn = dataSource.getConnection(); } catch (Exception ex) { - throw new JellyException( + throw new JellyTagException( Resources.getMessage("DATASOURCE_INVALID", ex.getMessage())); } } 1.2 +9 -9 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/TransactionTag.java Index: TransactionTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/TransactionTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TransactionTag.java 7 Jan 2003 13:47:05 -0000 1.1 +++ TransactionTag.java 26 Jan 2003 07:21:00 -0000 1.2 @@ -60,7 +60,7 @@ import javax.sql.DataSource; -import org.apache.commons.jelly.JellyException; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; @@ -118,10 +118,10 @@ * getting the <code>Connection</code> and preparing it for * the transaction. */ - public void doTag(XMLOutput output) throws Exception { + public void doTag(XMLOutput output) throws JellyTagException { if ((rawDataSource == null) && dataSourceSpecified) { - throw new JellyException(Resources.getMessage("SQL_DATASOURCE_NULL")); + throw new JellyTagException(Resources.getMessage("SQL_DATASOURCE_NULL")); } DataSource dataSource = DataSourceUtil.getDataSource(rawDataSource, context); @@ -130,7 +130,7 @@ conn = dataSource.getConnection(); origIsolation = conn.getTransactionIsolation(); if (origIsolation == Connection.TRANSACTION_NONE) { - throw new JellyException(Resources.getMessage("TRANSACTION_NO_SUPPORT")); + throw new JellyTagException(Resources.getMessage("TRANSACTION_NO_SUPPORT")); } if ((isolation != Connection.TRANSACTION_NONE) && (isolation != origIsolation)) { @@ -139,7 +139,7 @@ conn.setAutoCommit(false); } catch (SQLException e) { - throw new JellyException( + throw new JellyTagException( Resources.getMessage("ERROR_GET_CONNECTION", e.getMessage())); } @@ -158,7 +158,7 @@ } doFinally(); } - throw e; + throw new JellyTagException(e); } // lets commit @@ -166,7 +166,7 @@ conn.commit(); } catch (SQLException e) { - throw new JellyException( + throw new JellyTagException( Resources.getMessage("TRANSACTION_COMMIT_ERROR", e.getMessage())); } finally { @@ -180,7 +180,7 @@ /** * Sets the transaction isolation level. */ - public void setIsolation(String iso) throws JellyException { + public void setIsolation(String iso) throws JellyTagException { if (TRANSACTION_READ_COMMITTED.equals(iso)) { isolation = Connection.TRANSACTION_READ_COMMITTED; @@ -195,7 +195,7 @@ isolation = Connection.TRANSACTION_SERIALIZABLE; } else { - throw new JellyException(Resources.getMessage("TRANSACTION_INVALID_ISOLATION")); + throw new JellyTagException(Resources.getMessage("TRANSACTION_INVALID_ISOLATION")); } } 1.2 +5 -5 jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/UpdateTag.java Index: UpdateTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/UpdateTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- UpdateTag.java 7 Jan 2003 13:47:05 -0000 1.1 +++ UpdateTag.java 26 Jan 2003 07:21:00 -0000 1.2 @@ -60,7 +60,7 @@ import java.sql.SQLException; import java.sql.Statement; -import org.apache.commons.jelly.JellyException; +import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; import org.apache.commons.logging.Log; @@ -105,12 +105,12 @@ * element, or is retrieved from a JSP scope attribute * named <code>javax.servlet.jsp.jstl.sql.dataSource</code>. */ - public void doTag(XMLOutput output) throws Exception { + public void doTag(XMLOutput output) throws JellyTagException { try { conn = getConnection(); } catch (SQLException e) { - throw new JellyException(sql + ": " + e.getMessage(), e); + throw new JellyTagException(sql + ": " + e.getMessage(), e); } /* @@ -125,7 +125,7 @@ sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { - throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); + throw new JellyTagException(Resources.getMessage("SQL_NO_STATEMENT")); } Statement statement = null; @@ -152,7 +152,7 @@ tempStatement.close(); } catch (SQLException e) { - throw new JellyException(sqlStatement + ": " + e.getMessage(), e); + throw new JellyTagException(sqlStatement + ": " + e.getMessage(), e); } finally { if (statement != null) {
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>