summaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/src/main/java/java/sql/DriverManager.java49
-rw-r--r--sql/src/main/java/java/sql/SQLWarning.java4
-rw-r--r--sql/src/main/java/java/sql/Timestamp.java46
-rw-r--r--sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java146
-rw-r--r--sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties61
5 files changed, 42 insertions, 264 deletions
diff --git a/sql/src/main/java/java/sql/DriverManager.java b/sql/src/main/java/java/sql/DriverManager.java
index 1c41a46..8d3adde 100644
--- a/sql/src/main/java/java/sql/DriverManager.java
+++ b/sql/src/main/java/java/sql/DriverManager.java
@@ -17,20 +17,17 @@
package java.sql;
+import dalvik.system.VMStack;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.security.AccessController;
import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
import java.util.Enumeration;
import java.util.Iterator;
-import java.io.PrintStream;
-import java.io.PrintWriter;
+import java.util.List;
+import java.util.Properties;
import java.util.Vector;
-import java.security.AccessController;
import org.apache.harmony.luni.util.PriviAction;
-import org.apache.harmony.sql.internal.nls.Messages;
-// BEGIN android-changed
-import dalvik.system.VMStack;
-// END android-changed
/**
* Provides facilities for managing JDBC drivers.
@@ -59,8 +56,7 @@ public class DriverManager {
private static final List<Driver> theDrivers = new ArrayList<Driver>(10);
// Permission for setting log
- private static final SQLPermission logPermission = new SQLPermission(
- "setLog"); //$NON-NLS-1$
+ private static final SQLPermission logPermission = new SQLPermission("setLog");
/*
* Load drivers on initialization
@@ -75,7 +71,7 @@ public class DriverManager {
*/
private static void loadInitialDrivers() {
String theDriverList = AccessController
- .doPrivileged(new PriviAction<String>("jdbc.drivers", null)); //$NON-NLS-1$
+ .doPrivileged(new PriviAction<String>("jdbc.drivers", null));
if (theDriverList == null) {
return;
@@ -85,7 +81,7 @@ public class DriverManager {
* Get the names of the drivers as an array of Strings from the system
* property by splitting the property at the separator character ':'
*/
- String[] theDriverNames = theDriverList.split(":"); //$NON-NLS-1$
+ String[] theDriverNames = theDriverList.split(":");
for (String element : theDriverNames) {
try {
@@ -125,15 +121,10 @@ public class DriverManager {
if (driver == null) {
return;
}
- // BEGIN android-changed
ClassLoader callerClassLoader = VMStack.getCallingClassLoader();
- // END android-changed
-
if (!DriverManager.isClassFromClassLoader(driver, callerClassLoader)) {
- // sql.1=DriverManager: calling class not authorized to deregister
- // JDBC driver
- throw new SecurityException(Messages.getString("sql.1")); //$NON-NLS-1$
- } // end if
+ throw new SecurityException("calling class not authorized to deregister JDBC driver");
+ }
synchronized (theDrivers) {
theDrivers.remove(driver);
}
@@ -172,14 +163,12 @@ public class DriverManager {
* if there is an error while attempting to connect to the
* database identified by the URL.
*/
- public static Connection getConnection(String url, Properties info)
- throws SQLException {
+ public static Connection getConnection(String url, Properties info) throws SQLException {
// 08 - connection exception
// 001 - SQL-client unable to establish SQL-connection
- String sqlState = "08001"; //$NON-NLS-1$
+ String sqlState = "08001";
if (url == null) {
- // sql.5=The url cannot be null
- throw new SQLException(Messages.getString("sql.5"), sqlState); //$NON-NLS-1$
+ throw new SQLException("The url cannot be null", sqlState);
}
synchronized (theDrivers) {
/*
@@ -195,8 +184,7 @@ public class DriverManager {
}
}
// If we get here, none of the drivers are able to resolve the URL
- // sql.6=No suitable driver
- throw new SQLException(Messages.getString("sql.6"), sqlState); //$NON-NLS-1$
+ throw new SQLException("No suitable driver", sqlState);
}
/**
@@ -218,10 +206,10 @@ public class DriverManager {
String password) throws SQLException {
Properties theProperties = new Properties();
if (null != user) {
- theProperties.setProperty("user", user); //$NON-NLS-1$
+ theProperties.setProperty("user", user);
}
if (null != password) {
- theProperties.setProperty("password", password); //$NON-NLS-1$
+ theProperties.setProperty("password", password);
}
return getConnection(url, theProperties);
}
@@ -258,10 +246,9 @@ public class DriverManager {
}
}
// If no drivers understand the URL, throw an SQLException
- // sql.6=No suitable driver
// SQLState: 08 - connection exception
// 001 - SQL-client unable to establish SQL-connection
- throw new SQLException(Messages.getString("sql.6"), "08001"); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new SQLException("No suitable driver", "08001");
}
/**
diff --git a/sql/src/main/java/java/sql/SQLWarning.java b/sql/src/main/java/java/sql/SQLWarning.java
index 3ef67f5..9089984 100644
--- a/sql/src/main/java/java/sql/SQLWarning.java
+++ b/sql/src/main/java/java/sql/SQLWarning.java
@@ -19,8 +19,6 @@ package java.sql;
import java.io.Serializable;
-import org.apache.harmony.sql.internal.nls.Messages;
-
/**
* An exception class that holds information about Database access warnings.
*/
@@ -95,7 +93,7 @@ public class SQLWarning extends SQLException implements Serializable {
if (next instanceof SQLWarning) {
return (SQLWarning) next;
}
- throw new Error(Messages.getString("sql.8")); //$NON-NLS-1$
+ throw new Error("SQLWarning chain holds value that is not a SQLWarning");
}
/**
diff --git a/sql/src/main/java/java/sql/Timestamp.java b/sql/src/main/java/java/sql/Timestamp.java
index f16d93a..9f5ef31 100644
--- a/sql/src/main/java/java/sql/Timestamp.java
+++ b/sql/src/main/java/java/sql/Timestamp.java
@@ -22,8 +22,6 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;
-import org.apache.harmony.sql.internal.nls.Messages;
-
/**
* A Java representation of the SQL {@code TIMESTAMP} type. It provides the
* capability of representing the SQL {@code TIMESTAMP} nanosecond value, in
@@ -51,7 +49,7 @@ public class Timestamp extends Date {
private int nanos;
// The regex pattern of yyyy-mm-dd hh:mm:ss
- private static final String TIME_FORMAT_REGEX = "[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.*"; //$NON-NLS-1$
+ private static final String TIME_FORMAT_REGEX = "[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.*";
/**
* Returns a {@code Timestamp} corresponding to the time specified by the
@@ -302,8 +300,7 @@ public class Timestamp extends Date {
*/
public void setNanos(int n) throws IllegalArgumentException {
if ((n < 0) || (n > 999999999)) {
- // sql.0=Value out of range
- throw new IllegalArgumentException(Messages.getString("sql.0")); //$NON-NLS-1$
+ throw new IllegalArgumentException("Value out of range");
}
nanos = n;
}
@@ -379,7 +376,7 @@ public class Timestamp extends Date {
return sb.toString();
}
- private static final String PADDING = "000000000"; //$NON-NLS-1$
+ private static final String PADDING = "000000000";
/*
* Private method to format the time
@@ -407,17 +404,16 @@ public class Timestamp extends Date {
*/
public static Timestamp valueOf(String s) throws IllegalArgumentException {
if (s == null) {
- // sql.3=Argument cannot be null
- throw new IllegalArgumentException(Messages.getString("sql.3")); //$NON-NLS-1$
+ throw new IllegalArgumentException("Argument cannot be null");
}
- // omit trailing whitespaces
+ // omit trailing whitespace
s = s.trim();
if (!Pattern.matches(TIME_FORMAT_REGEX, s)) {
- throw new IllegalArgumentException(Messages.getString("sql.2")); //$NON-NLS-1$
+ throw badTimestampString(s);
}
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pp = new ParsePosition(0);
/*
@@ -431,11 +427,11 @@ public class Timestamp extends Date {
try {
theDate = df.parse(s, pp);
} catch (Exception e) {
- throw new IllegalArgumentException(Messages.getString("sql.2")); //$NON-NLS-1$
+ throw badTimestampString(s);
}
if (theDate == null) {
- throw new IllegalArgumentException(Messages.getString("sql.2")); //$NON-NLS-1$
+ throw badTimestampString(s);
}
/*
@@ -458,23 +454,22 @@ public class Timestamp extends Date {
* Case where fraction of a second is specified: Require 1 character
* plus the "." in the remaining part of the string...
*/
- if ((s.length() - position) < ".n".length()) { //$NON-NLS-1$
- throw new IllegalArgumentException(Messages.getString("sql.2")); //$NON-NLS-1$
+ if ((s.length() - position) < ".n".length()) {
+ throw badTimestampString(s);
}
/*
* If we're strict, we should not allow any EXTRA characters after
* the 9 digits
*/
- if ((s.length() - position) > ".nnnnnnnnn".length()) { //$NON-NLS-1$
- throw new IllegalArgumentException(Messages.getString("sql.2")); //$NON-NLS-1$
+ if ((s.length() - position) > ".nnnnnnnnn".length()) {
+ throw badTimestampString(s);
}
// Require the next character to be a "."
if (s.charAt(position) != '.') {
- // sql.4=Bad input string format: expected '.' not {0}
- throw new NumberFormatException(Messages.getString(
- "sql.4", s.charAt(position))); //$NON-NLS-1$
+ throw new NumberFormatException("Bad input string format: expected '.' not '" +
+ s.charAt(position) + "'");
}
// Get the length of the number string - need to account for the '.'
int nanoLength = s.length() - position - 1;
@@ -486,19 +481,19 @@ public class Timestamp extends Date {
* We must adjust for the cases where the nanos String was not 9
* characters long by padding out with zeros
*/
- theNanoString = theNanoString + "000000000"; //$NON-NLS-1$
+ theNanoString = theNanoString + "000000000";
theNanoString = theNanoString.substring(0, 9);
try {
theNanos = Integer.parseInt(theNanoString);
} catch (Exception e) {
// If we get here, the string was not a number
- throw new IllegalArgumentException(Messages.getString("sql.2")); //$NON-NLS-1$
+ throw badTimestampString(s);
}
}
if (theNanos < 0 || theNanos > 999999999) {
- throw new IllegalArgumentException(Messages.getString("sql.2")); //$NON-NLS-1$
+ throw badTimestampString(s);
}
Timestamp theTimestamp = new Timestamp(theDate.getTime());
@@ -506,4 +501,9 @@ public class Timestamp extends Date {
return theTimestamp;
}
+
+ private static IllegalArgumentException badTimestampString(String s) {
+ throw new IllegalArgumentException("Timestamp format must be " +
+ "yyyy-mm-dd hh:mm:ss.fffffffff; was '" + s + "'");
+ }
}
diff --git a/sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java b/sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java
deleted file mode 100644
index 234bdc9..0000000
--- a/sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
- * All changes made to this file manually will be overwritten
- * if this tool runs again. Better make changes in the template file.
- */
-
-// BEGIN android-note
-// Redundant code has been removed and is now called from MsgHelp.
-// END android-note
-
-package org.apache.harmony.sql.internal.nls;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-// BEGIN android-changed
-import org.apache.harmony.luni.util.MsgHelp;
-// END android-changed
-
-/**
- * This class retrieves strings from a resource bundle and returns them,
- * formatting them with MessageFormat when required.
- * <p>
- * It is used by the system classes to provide national language support, by
- * looking up messages in the <code>
- * org.apache.harmony.sql.internal.nls.messages
- * </code>
- * resource bundle. Note that if this file is not available, or an invalid key
- * is looked up, or resource bundle support is not available, the key itself
- * will be returned as the associated message. This means that the <em>KEY</em>
- * should a reasonable human-readable (english) string.
- *
- */
-public class Messages {
-
- // BEGIN android-changed
- private static final String sResource =
- "org.apache.harmony.sql.internal.nls.messages"; //$NON-NLS-1$
- // END android-changed
-
- /**
- * Retrieves a message which has no arguments.
- *
- * @param msg
- * String the key to look up.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg) {
- // BEGIN android-changed
- return MsgHelp.getString(sResource, msg);
- // END android-changed
- }
-
- /**
- * Retrieves a message which takes 1 argument.
- *
- * @param msg
- * String the key to look up.
- * @param arg
- * Object the object to insert in the formatted output.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg, Object arg) {
- return getString(msg, new Object[] { arg });
- }
-
- /**
- * Retrieves a message which takes 1 integer argument.
- *
- * @param msg
- * String the key to look up.
- * @param arg
- * int the integer to insert in the formatted output.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg, int arg) {
- return getString(msg, new Object[] { Integer.toString(arg) });
- }
-
- /**
- * Retrieves a message which takes 1 character argument.
- *
- * @param msg
- * String the key to look up.
- * @param arg
- * char the character to insert in the formatted output.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg, char arg) {
- return getString(msg, new Object[] { String.valueOf(arg) });
- }
-
- /**
- * Retrieves a message which takes 2 arguments.
- *
- * @param msg
- * String the key to look up.
- * @param arg1
- * Object an object to insert in the formatted output.
- * @param arg2
- * Object another object to insert in the formatted output.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg, Object arg1, Object arg2) {
- return getString(msg, new Object[] { arg1, arg2 });
- }
-
- /**
- * Retrieves a message which takes several arguments.
- *
- * @param msg
- * String the key to look up.
- * @param args
- * Object[] the objects to insert in the formatted output.
- * @return String the message for that key in the system message bundle.
- */
- static public String getString(String msg, Object[] args) {
- // BEGIN android-changed
- return MsgHelp.getString(sResource, msg, args);
- // END android-changed
- }
-
- // BEGIN android-note
- // Duplicate code was dropped in favor of using MsgHelp.
- // END android-note
-}
diff --git a/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties b/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
deleted file mode 100644
index 6927cf2..0000000
--- a/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
+++ /dev/null
@@ -1,61 +0,0 @@
-# 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.
-#
-
-# messages for EN locale
-sql.0=Value out of range
-sql.1=DriverManager: calling class not authorized to deregister JDBC driver
-sql.2=Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
-sql.3=Argument cannot be null
-sql.4=Bad input string format: expected '.' not {0}
-sql.5=The url cannot be null
-sql.6=No suitable driver
-sql.8=SQLWarning chain holds value that is not a SQLWarning
-sql.9=Cannot instantiate a SerialRef object with a null Ref object
-sql.10=Cannot instantiate a SerialRef object that returns a null base type name
-sql.11=SQLException: {0}
-sql.12=Cannot serialize empty URL instance
-sql.13=Cannot instantiate a SerialBlob object with a null Blob object
-sql.14=Invalid starting position or length
-sql.15=Invalid position in BLOB object set
-sql.16=Invalid offset in byte array set
-sql.17=javax.sql.rowset.serial.SerialException: Length more than what can be truncated
-sql.18=Unsupported operation. SerialBlob cannot return a writable binary stream, unless instantiated with a Blob object that provides a setBinaryStream() implementation
-sql.19=Cannot instantiate a SerialClob object with a null Clob object
-sql.20=Invalid Clob object. Calls to getCharacterStream or getAsciiStream return null which cannot be serialized.
-sql.21=Invalid position in CLOB object set
-sql.22=Invalid position and substring length
-sql.23=Buffer is not sufficient to hold the value
-sql.24=Invalid length for truncate
-sql.25=Unsupported operation. SerialClob is not instantiated with a fully implemented Clob object.
-sql.26=Invalid column count. Cannot be less or equal to zero
-sql.27=Invalid column index :{0}
-sql.28=Invalid SQL type for column
-sql.29=Invalid nullable constant set. Must be either columnNoNulls, columnNullable or columnNullableUnknown
-sql.30=Invalid column display size. Cannot be less than zero
-sql.31=Invalid precision value. Cannot be less than zero
-sql.32=Invalid scale size. Cannot be less than zero
-sql.33=Cannot instantiate a SQLOutputImpl instance with null parameters
-sql.34=Cannot instantiate a SQLInputImpl instance with null parameters
-sql.35=SQLInputImpl exception: Invalid read position
-sql.36=No more attributes
-sql.37=Operation not supported
-sql.38=Object is invalid
-sql.39=Cannot instantiate a SerialArray object with a null Array object
-sql.40=ClassNotFoundException: {0}
-sql.41=Invalid JNDI context supplied
-sql.42=Illegal Argument
-sql.43=The object is not serializable
-sql.44=No logger has been set