summaryrefslogtreecommitdiff
path: root/java/sql
diff options
context:
space:
mode:
authorBrian Jones <cbj@gnu.org>2003-04-11 22:01:07 +0000
committerBrian Jones <cbj@gnu.org>2003-04-11 22:01:07 +0000
commita2cf7c59e7fdacd2aaa9a38d5bb1049223f40c41 (patch)
tree08c8be9ea35af1effe254fd3ce3cae6babd3e5e8 /java/sql
parent796a9d86f8f25073cc0a702921c4469fbc6791c2 (diff)
downloadclasspath-a2cf7c59e7fdacd2aaa9a38d5bb1049223f40c41.tar.gz
2003-04-11 Dalibor Topic <robilad@yahoo.com>
* java/sql/Date.java: imported java.text.ParseException. (getHours, getMinutes, getSeconds, setHours, setMinutes, setSeconds) new methods. * java/sql/Time.java: (getDate, getDay, getMonts, getYear, setDate, setMonth, setYear): new methods. * java/sql/Date.java, java/sql/Time.java, java/sql/Timestamp.java: imported java.text.ParseException. (valueOf) throw an IllegalArgumentException if argument can't be parsed. * java/sql/DriverManager.java (getDriver) throw an SQLException if no driver can be found. All reported by: Ito Kazumitsu <ito.kazumitsu@hitachi-cable.co.jp>
Diffstat (limited to 'java/sql')
-rw-r--r--java/sql/Date.java75
-rw-r--r--java/sql/DriverManager.java6
-rw-r--r--java/sql/Time.java82
-rw-r--r--java/sql/Timestamp.java13
4 files changed, 163 insertions, 13 deletions
diff --git a/java/sql/Date.java b/java/sql/Date.java
index 360376c25..1ba21a190 100644
--- a/java/sql/Date.java
+++ b/java/sql/Date.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package java.sql;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
@@ -82,6 +83,66 @@ public class Date extends java.util.Date
}
/**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public int getHours() throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public int getMinutes() throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public int getSeconds() throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public void setHours(int newValue) throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public void setMinutes(int newValue) throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public void setSeconds(int newValue) throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
* This method returns a new instance of this class by parsing a
* date in JDBC format into a Java date.
*
@@ -92,14 +153,20 @@ public class Date extends java.util.Date
*/
public static Date valueOf (String str)
{
- try
+ try
{
java.util.Date d = (java.util.Date) sdf.parseObject(str);
- return(new Date(d.getTime()));
+
+ if (d == null) {
+ throw new IllegalArgumentException(str);
+ }
+ else {
+ return(new Date(d.getTime()));
+ }
}
- catch(Exception e)
+ catch (ParseException e)
{
- return(null);
+ throw new IllegalArgumentException(str);
}
}
diff --git a/java/sql/DriverManager.java b/java/sql/DriverManager.java
index 229450ad0..f022758d3 100644
--- a/java/sql/DriverManager.java
+++ b/java/sql/DriverManager.java
@@ -209,9 +209,9 @@ public class DriverManager
* @param url The JDBC URL string to find a driver for.
*
* @return A <code>Driver</code> that can connect to the specified
- * URL, or <code>null</code> if a suitable driver cannot be found.
+ * URL.
*
- * @exception SQLException If an error occurs.
+ * @exception SQLException If an error occurs, or no suitable driver can be found.
*/
public static Driver getDriver(String url) throws SQLException
{
@@ -224,7 +224,7 @@ public class DriverManager
return d;
}
- return null;
+ throw new SQLException("No driver found for " + url);
}
/**
diff --git a/java/sql/Time.java b/java/sql/Time.java
index 7d515c25c..ca1510bf1 100644
--- a/java/sql/Time.java
+++ b/java/sql/Time.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package java.sql;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
@@ -55,6 +56,75 @@ public class Time extends java.util.Date
*/
private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public int getDate() throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public int getDay() throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public int getMonth() throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public int getYear() throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public void setDate(int newValue) throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public void setMonth(int newValue) throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * This method always throws an IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException when it's called.
+ * @deprecated
+ */
+ public void setYear(int newValue) throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
/**
* This method returns a new instance of this class by parsing a
@@ -70,11 +140,17 @@ public class Time extends java.util.Date
try
{
java.util.Date d = (java.util.Date) sdf.parseObject(str);
- return new Time(d.getTime());
+
+ if (d == null) {
+ throw new IllegalArgumentException(str);
+ }
+ else {
+ return new Time(d.getTime());
+ }
}
- catch (Exception e)
+ catch (ParseException e)
{
- return null;
+ throw new IllegalArgumentException(str);
}
}
diff --git a/java/sql/Timestamp.java b/java/sql/Timestamp.java
index 0f8b44c43..6177b5b17 100644
--- a/java/sql/Timestamp.java
+++ b/java/sql/Timestamp.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package java.sql;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
@@ -81,11 +82,17 @@ public class Timestamp extends java.util.Date
try
{
Date d = (Date) parse_sdf.parseObject(str);
- return new Timestamp(d.getTime());
+
+ if (d == null) {
+ throw new IllegalArgumentException(str);
+ }
+ else {
+ return new Timestamp(d.getTime());
+ }
}
- catch (Exception e)
+ catch (ParseException e)
{
- return null;
+ throw new IllegalArgumentException(str);
}
}