db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r633290 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/error/SQLWarningFactory.java iapi/jdbc/BrokeredConnection.java impl/jdbc/EmbedConnection.java impl/jdbc/EmbedSQLWarning.java impl/sql/execute/GenericAggregateResultSet.java
Date Mon, 03 Mar 2008 21:57:53 GMT
Author: djd
Date: Mon Mar  3 13:57:49 2008
New Revision: 633290

URL: http://svn.apache.org/viewvc?rev=633290&view=rev
Log:
DERBY-3461 The class EmbedSQLWarning is really an SQLWarning factory class. Therefore, it
has been renamed to SQLWarningFactory.
The unused method generateCsSQLWarning() has been removed.
The remaining methods have been renamed to remove the reference to 'Embed'.
Since the re-factored class is generic, it has been moved to org.apache.derby.iapi.error package.

Contributed by Dibyendu Majumdar Email: dibyendu at mazumdar dot demon dot co dot uk

Added:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java   (with
props)
Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLWarning.java
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java

Added: db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java?rev=633290&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java Mon
Mar  3 13:57:49 2008
@@ -0,0 +1,69 @@
+/*
+
+   Derby - Class org.apache.derby.iapi.error.SQLWarningFactory
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.iapi.error;
+
+import java.sql.SQLWarning;
+
+import org.apache.derby.iapi.services.i18n.MessageService;
+
+/**
+ * This class generates SQLWarning instances. It has an understanding of Derby's
+ * internal error/warning message Ids, and transforms these to localised error
+ * messages and appropriate SQLState.
+ */
+public class SQLWarningFactory {
+
+	/**
+	 * Generates a SQLWarning instance based on the supplied messageId. It looks
+	 * up the messageId to generate a localised warning message. Also, SQLState
+	 * is set correctly based on the messageId.
+	 * 
+	 * @param messageId
+	 *            A Derby messageId as defined in
+	 *            {@link SQLState org.apache.derby.shared.common.reference.SQLState}.
+	 * @return Properly initialized SQLWarning instance.
+	 * @see org.apache.derby.shared.common.reference.SQLState
+	 */
+	public static SQLWarning newSQLWarning(String messageId) {
+		return newSQLWarning(messageId, null);
+	}
+
+	/**
+	 * Generates a SQLWarning instance based on the supplied messageId and
+	 * argument. It looks up the messageId to generate a localised warning
+	 * message. Also, SQLState is set correctly based on the messageId.
+	 * 
+	 * @param messageId
+	 *            A Derby messageId as defined in
+	 *            {@link SQLState org.apache.derby.shared.common.reference.SQLState}.
+	 * @param arg
+	 *            An argument for the warning message
+	 * @return Properly initialized SQLWarning instance.
+	 * @see org.apache.derby.shared.common.reference.SQLState
+	 */
+	public static SQLWarning newSQLWarning(String messageId, Object arg) {
+		return new SQLWarning(MessageService.getCompleteMessage(messageId,
+				new Object[] { arg }), StandardException
+				.getSQLStateFromIdentifier(messageId), ExceptionSeverity.WARNING_SEVERITY);
+	}
+
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java?rev=633290&r1=633289&r2=633290&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java Mon
Mar  3 13:57:49 2008
@@ -30,7 +30,6 @@
 import java.sql.SQLException;
 import java.sql.SQLWarning;
 
-import org.apache.derby.impl.jdbc.EmbedSQLWarning;
 import org.apache.derby.impl.jdbc.Util;
 
 import java.io.ObjectOutput;
@@ -39,6 +38,7 @@
 import java.lang.reflect.*;
 
 import org.apache.derby.iapi.error.PublicAPI;
+import org.apache.derby.iapi.error.SQLWarningFactory;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.shared.common.reference.SQLState;
 
@@ -607,7 +607,7 @@
         int holdability = control.checkHoldCursors(resultSetHoldability, true);
         if (holdability != resultSetHoldability) {
             SQLWarning w =
-                 EmbedSQLWarning.newEmbedSQLWarning(SQLState.HOLDABLE_RESULT_SET_NOT_AVAILABLE);
+                 SQLWarningFactory.newSQLWarning(SQLState.HOLDABLE_RESULT_SET_NOT_AVAILABLE);
             
             addWarning(w);
         }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=633290&r1=633289&r2=633290&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Mon Mar
 3 13:57:49 2008
@@ -40,6 +40,7 @@
 import org.apache.derby.iapi.db.Database;
 import org.apache.derby.impl.db.SlaveDatabase;
 import org.apache.derby.iapi.error.ExceptionSeverity;
+import org.apache.derby.iapi.error.SQLWarningFactory;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
@@ -346,7 +347,7 @@
 				// database
 
 				if (tr.getDatabase() != null) {
-					addWarning(EmbedSQLWarning.newEmbedSQLWarning(SQLState.DATABASE_EXISTS, getDBName()));
+					addWarning(SQLWarningFactory.newSQLWarning(SQLState.DATABASE_EXISTS, getDBName()));
 				} else {
 
 					// check for user's credential and authenticate the user
@@ -499,7 +500,7 @@
 
 			// Raise a warning in sqlAuthorization mode if authentication is not ON
 			if (usingNoneAuth && getLanguageConnection().usesSqlAuthorization())
-				addWarning(EmbedSQLWarning.newEmbedSQLWarning(SQLState.SQL_AUTHORIZATION_WITH_NO_AUTHENTICATION));
+				addWarning(SQLWarningFactory.newSQLWarning(SQLState.SQL_AUTHORIZATION_WITH_NO_AUTHENTICATION));
 		}
         catch (OutOfMemoryError noMemory)
 		{
@@ -2318,7 +2319,7 @@
 			if (Monitor.createPersistentService(Property.DATABASE_MODULE, dbname, info) == null) 
 			{
 				// service already exists, create a warning
-				addWarning(EmbedSQLWarning.newEmbedSQLWarning(SQLState.DATABASE_EXISTS, dbname));
+				addWarning(SQLWarningFactory.newSQLWarning(SQLState.DATABASE_EXISTS, dbname));
 			}
 		} catch (StandardException mse) {
             throw Util.seeNextException(SQLState.CREATE_DATABASE_FAILED,
@@ -2669,7 +2670,7 @@
 		 */
 		if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE)
 		{
-			addWarning(EmbedSQLWarning.newEmbedSQLWarning(SQLState.NO_SCROLL_SENSITIVE_CURSORS));
+			addWarning(SQLWarningFactory.newSQLWarning(SQLState.NO_SCROLL_SENSITIVE_CURSORS));
 			resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE;
 		}
 		return resultSetType;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java?rev=633290&r1=633289&r2=633290&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java
Mon Mar  3 13:57:49 2008
@@ -23,6 +23,7 @@
 
 import java.util.Vector;
 
+import org.apache.derby.iapi.error.SQLWarningFactory;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.loader.ClassFactory;
@@ -32,7 +33,6 @@
 import org.apache.derby.iapi.sql.execute.ExecIndexRow;
 import org.apache.derby.iapi.sql.execute.ExecRow;
 import org.apache.derby.iapi.sql.execute.NoPutResultSet;
-import org.apache.derby.impl.jdbc.EmbedSQLWarning;
 
 /**
  * Generic aggregation utilities.
@@ -174,7 +174,7 @@
 		}
 
 		if (eliminatedNulls)
-			addWarning(EmbedSQLWarning.newEmbedSQLWarning(SQLState.LANG_NULL_ELIMINATED_IN_SET_FUNCTION));
+			addWarning(SQLWarningFactory.newSQLWarning(SQLState.LANG_NULL_ELIMINATED_IN_SET_FUNCTION));
 	
 		return row;
 	}



Mime
View raw message