Modified:
branches/branch_5_1/src/com/mysql/jdbc/BlobFromLocator.java
branches/branch_5_1/src/com/mysql/jdbc/Clob.java
Log:
Fixed up a couple of JDBC4-related stream methods.
Modified: branches/branch_5_1/src/com/mysql/jdbc/BlobFromLocator.java
===================================================================
--- branches/branch_5_1/src/com/mysql/jdbc/BlobFromLocator.java 2008-02-27 15:35:10 UTC
(rev 6745)
+++ branches/branch_5_1/src/com/mysql/jdbc/BlobFromLocator.java 2008-02-27 15:36:19 UTC
(rev 6746)
@@ -32,8 +32,6 @@
import java.util.ArrayList;
import java.util.List;
-import com.mysql.jdbc.exceptions.NotYetImplementedException;
-
/**
* The representation (mapping) in the JavaTM programming language of an SQL
* BLOB value. An SQL BLOB is a built-in type that stores a Binary Large Object
@@ -164,7 +162,7 @@
*/
public OutputStream setBinaryStream(long indexToWriteAt)
throws SQLException {
- throw new NotImplemented();
+ throw SQLError.notImplemented();
}
/**
@@ -577,6 +575,29 @@
pStmt = createGetBytesStatement();
}
+ LocatorInputStream(long pos, long len) throws SQLException {
+ length = pos + len;
+ currentPositionInBlob = pos;
+ long blobLength = length();
+
+ if (pos + len > blobLength) {
+ throw SQLError.createSQLException(
+ Messages.getString("Blob.invalidStreamLength",
+ new Object[] {new Long(blobLength), new Long(pos), new Long(len)}),
+ SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+ }
+
+ if (pos < 1) {
+ throw SQLError.createSQLException(Messages.getString("Blob.invalidStreamPos"),
+ SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+ }
+
+ if (pos > blobLength) {
+ throw SQLError.createSQLException(Messages.getString("Blob.invalidStreamPos"),
+ SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+ }
+ }
+
public int read() throws IOException {
if (currentPositionInBlob + 1 > length) {
return -1;
@@ -677,6 +698,6 @@
}
public InputStream getBinaryStream(long pos, long length) throws SQLException {
- throw new NotYetImplementedException();
+ return new LocatorInputStream(pos, length);
}
}
Modified: branches/branch_5_1/src/com/mysql/jdbc/Clob.java
===================================================================
--- branches/branch_5_1/src/com/mysql/jdbc/Clob.java 2008-02-27 15:35:10 UTC (rev 6745)
+++ branches/branch_5_1/src/com/mysql/jdbc/Clob.java 2008-02-27 15:36:19 UTC (rev 6746)
@@ -32,8 +32,6 @@
import java.io.Writer;
import java.sql.SQLException;
-import com.mysql.jdbc.exceptions.NotYetImplementedException;
-
/**
* Simplistic implementation of java.sql.Clob for MySQL Connector/J
*
@@ -294,10 +292,10 @@
}
public void free() throws SQLException {
- throw new NotYetImplementedException();
+ this.charData = null;
}
public Reader getCharacterStream(long pos, long length) throws SQLException {
- throw new NotYetImplementedException();
+ return new StringReader(getSubString(pos, (int)length));
}
}
| Thread |
|---|
| • Connector/J commit: r6746 - branches/branch_5_1/src/com/mysql/jdbc | mmatthews | 27 Feb 2008 |