db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r407549 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/tests/jdbc4/
Date Thu, 18 May 2006 13:45:27 GMT
Author: rhillegas
Date: Thu May 18 06:45:26 2006
New Revision: 407549

URL: http://svn.apache.org/viewvc?rev=407549&view=rev
Log:
DERBY-1255: Narayanan's ClobBlob_create_v1.diff patch. This adds the first increment of support
for Connection.createClob() and createBlob(), new methods added in JDBC4.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java?rev=407549&r1=407548&r2=407549&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java Thu
May 18 06:45:26 2006
@@ -46,12 +46,56 @@
         throw Util.notImplemented();
     }
     
+    /**
+     *
+     * Constructs an object that implements the <code>Blob</code> interface.
The object
+     * returned initially contains no data.  The <code>setBinaryStream</code>
and
+     * <code>setBytes</code> methods of the <code>Blob</code> interface
may be used to add data to
+     * the <code>Blob</code>.
+     *
+     * @return  An object that implements the <code>Blob</code> interface
+     * @throws SQLException if an object that implements the
+     * <code>Blob</code> interface can not be constructed, this method is 
+     * called on a closed connection or a database access error occurs.
+     *
+     */
     public Blob createBlob() throws SQLException {
-        throw Util.notImplemented();
+        if (isClosed()) {
+            throw Util.noCurrentConnection();
+        }
+        // Forward the createBlob call to the physical connection
+        try {
+            return getRealConnection().createBlob();
+        } catch (SQLException sqle) {
+            notifyException(sqle);
+            throw sqle;
+        }
     }
 
+    /**
+     *
+     * Constructs an object that implements the <code>Clob</code> interface.
The object
+     * returned initially contains no data.  The <code>setAsciiStream</code>,
+     * <code>setCharacterStream</code> and <code>setString</code>
methods of 
+     * the <code>Clob</code> interface may be used to add data to the <code>Clob</code>.
+     *
+     * @return An object that implements the <code>Clob</code> interface
+     * @throws SQLException if an object that implements the
+     * <code>Clob</code> interface can not be constructed, this method is 
+     * called on a closed connection or a database access error occurs.
+     *
+     */
     public Clob createClob() throws SQLException{
-        throw Util.notImplemented();
+        if (isClosed()) {
+            throw Util.noCurrentConnection();
+        }
+        // Forward the createClob call to the physical connection
+        try {
+            return getRealConnection().createClob();
+        } catch (SQLException sqle) {
+            notifyException(sqle);
+            throw sqle;
+        }
     }
     
     
@@ -122,9 +166,25 @@
         throw Util.notImplemented();
     }
     
+    /**
+     *
+     * This method forwards all the calls to default query object provided by 
+     * the jdk.
+     * @param ifc interface to generated concreate class
+     * @return concrete class generated by default qury object generator
+     *
+     */
     public <T extends BaseQuery>T createQueryObject(Class<T> ifc) 
         throws SQLException {
-        throw Util.notImplemented();
+        if (isClosed()) {
+            throw Util.noCurrentConnection();
+        }
+        try {
+            return getRealConnection().createQueryObject(ifc);
+        } catch (SQLException sqle) {
+            notifyException(sqle);
+            throw sqle;
+        }
     }
     
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java?rev=407549&r1=407548&r2=407549&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java Thu May 18 06:45:26
2006
@@ -95,6 +95,24 @@
     //been invalidated by calling free() on it
     private boolean isValid = true;
 
+     /**
+     * This constructor is used to create a empty Blob object. It is used by the
+     * Connection interface method createBlob().
+     * 
+     * @param blobBytes A byte array containing the data to be stores in the 
+     *        Blob.
+     *
+     * @param con The EmbedConnection object associated with this Blob object.
+     *
+     */
+    
+     EmbedBlob(byte [] blobBytes,EmbedConnection con) {
+         super(con);
+         myBytes = blobBytes;
+         isBytes = true;
+         myLength = myBytes.length;
+     }
+     
     /*
       This constructor should only be called by EmbedResultSet.getBlob
     */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java?rev=407549&r1=407548&r2=407549&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java Thu May 18 06:45:26
2006
@@ -79,6 +79,23 @@
     //been invalidated by calling free() on it
     private boolean isValid = true;
 
+    /**
+     * This constructor is used to create a empty Clob object. It is used by the
+     * Connection interface method createClob().
+     * 
+     * @param clobString A String object containing the data to be stores in the 
+     *        Clob.
+     *
+     * @param con The Connection object associated with this EmbedClob object.
+     *
+     */
+    
+    EmbedClob(String clobString,EmbedConnection con) {
+        super(con);
+        myString = clobString;
+        isString = true;
+    }
+    
     /*
     This constructor should only be called by EmbedResultSet.getClob
     */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java?rev=407549&r1=407548&r2=407549&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java Thu
May 18 06:45:26 2006
@@ -62,12 +62,40 @@
         throw Util.notImplemented();
     }
     
+    /**
+     *
+     * Constructs an object that implements the <code>Clob</code> interface.
The object
+     * returned initially contains no data.  The <code>setAsciiStream</code>,
+     * <code>setCharacterStream</code> and <code>setString</code>
methods of 
+     * the <code>Clob</code> interface may be used to add data to the <code>Clob</code>.
+     *
+     * @return An object that implements the <code>Clob</code> interface
+     * @throws SQLException if an object that implements the
+     * <code>Clob</code> interface can not be constructed, this method is 
+     * called on a closed connection or a database access error occurs.
+     *
+     */
     public Clob createClob() throws SQLException {
-        throw Util.notImplemented();
+        checkIfClosed();
+        return new EmbedClob("",this);
     }
     
+    /**
+     *
+     * Constructs an object that implements the <code>Blob</code> interface.
The object
+     * returned initially contains no data.  The <code>setBinaryStream</code>
and
+     * <code>setBytes</code> methods of the <code>Blob</code> interface
may be used to add data to
+     * the <code>Blob</code>.
+     *
+     * @return  An object that implements the <code>Blob</code> interface
+     * @throws SQLException if an object that implements the
+     * <code>Blob</code> interface can not be constructed, this method is 
+     * called on a closed connection or a database access error occurs.
+     *
+     */
     public Blob createBlob() throws SQLException {
-        throw Util.notImplemented();
+        checkIfClosed();
+        return new EmbedBlob(new byte[0],this);
     }
     
     public NClob createNClob() throws SQLException {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java?rev=407549&r1=407548&r2=407549&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
Thu May 18 06:45:26 2006
@@ -81,24 +81,46 @@
    
     //------------------------- T E S T  M E T H O D S ------------------------
     
-    public void embeddedCreateBlobNotImplemented()
+    /**
+     *
+     * Tests the Embedded implementation for the createBlob method. The Embedded
+     * server does'nt currently have the set methods implemented. Hence the 
+     * create methods cannot be tested by inserting data into the empty LOB 
+     * object. Here we do a simple test of checking that the length of the 
+     * LOB object is 0.
+     *
+     * @throws SQLException upon failure in the createBlob or the length 
+     *         methods.
+     *
+     */
+    public void embeddedCreateBlob()
         throws SQLException {
-        try {
-            con.createBlob();
-            fail("createBlob() should not be implemented");
-        } catch (SQLFeatureNotSupportedException sfnse) {
-            // Do nothing, we are fine
-        }
+            Blob blob = con.createBlob();
+            //Check if the blob is empty
+            if(blob.length() > 0)
+                fail("The new Blob should not have more than zero bytes " +
+                        "contained in it");
     }
     
-    public void embeddedCreateClobNotImplemented()
+    /**
+     *
+     * Tests the Embedded implementation for the createClob method. The Embedded
+     * server does'nt currently have the set methods implemented. Hence the 
+     * create methods cannot be tested by inserting data into the empty LOB 
+     * object. Here we do a simple test of checking that the length of the 
+     * LOB object is 0.
+     *
+     * @throws SQLException upon failure in the createClob or the length 
+     *         methods.
+     *
+     */
+    public void embeddedCreateClob()
         throws SQLException {
-        try {
-            con.createClob();
-            fail("createClob() should not be implemented");
-        } catch (SQLFeatureNotSupportedException sfnse) {
-            // Do nothing, we are fine
-        }
+            Clob clob = con.createClob();
+            //check if the Clob is empty
+            if(clob.length() > 0)
+                fail("The new Clob should not have a length of greater than " +
+                        "zero");
     }
 
     public void testCreateArrayNotImplemented()
@@ -268,9 +290,9 @@
     private static TestSuite embeddedSuite() {
         TestSuite embeddedSuite = new TestSuite();
         embeddedSuite.addTest(new ConnectionTest(
-                    "embeddedCreateBlobNotImplemented"));
+                    "embeddedCreateBlob"));
         embeddedSuite.addTest(new ConnectionTest(
-                    "embeddedCreateClobNotImplemented"));
+                    "embeddedCreateClob"));
         return embeddedSuite;
     }
     



Mime
View raw message