Derby
  1. Derby
  2. DERBY-33

Connection.setTypeMap throws unimplemented exception with empty map

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.0.2.0
    • Fix Version/s: 10.1.1.0
    • Component/s: JDBC
    • Labels:
      None

      Description

      With some other unimplemented methods Derby accepts a default value or value that is in effect a no-op. In this case an empty map should be accepted. May want to apply the same logi to other JDBC methods that take a type map.

      Original bug discovered by Edward Rayl

      http://nagoya.apache.org/eyebrowse/ReadMsg?listName=derby-user@db.apache.org&msgNo=43

        Activity

        Hide
        Shreyas Kaushik added a comment -

        I wrote a sample program using JdbcRowSet and found it to working perfectly with Derby. I am attaching the sample program here.

        It did not throw up the error

        JdbcRowSet (setTypeMap) : null.

        This error appears becaus eof the fix suggested in the link that causes a NPE if the map is null ( map.isEmpty()) causes a NPE that appears as this problem.

        My suggested fix to handle this problem is :

        if((map != null))

        { if(!(map.isEmpty())) throw Util.notImplemented(); }

        I also did not get the error when the connection is actually closed. The right way to clean up things when using the JdbcRowSet is to call close() method in the JdbcRowSet and then call the close method on the connection.

        Please have a look at this and let me know.

        thanks
        Shreyas

        Show
        Shreyas Kaushik added a comment - I wrote a sample program using JdbcRowSet and found it to working perfectly with Derby. I am attaching the sample program here. It did not throw up the error JdbcRowSet (setTypeMap) : null. This error appears becaus eof the fix suggested in the link that causes a NPE if the map is null ( map.isEmpty()) causes a NPE that appears as this problem. My suggested fix to handle this problem is : if((map != null)) { if(!(map.isEmpty())) throw Util.notImplemented(); } I also did not get the error when the connection is actually closed. The right way to clean up things when using the JdbcRowSet is to call close() method in the JdbcRowSet and then call the close method on the connection. Please have a look at this and let me know. thanks Shreyas
        Hide
        Shreyas Kaushik added a comment -

        I wrote a sample program using JdbcRowSet and found it to working perfectly with Derby. I am attaching the sample program here.

        It did not throw up the error

        JdbcRowSet (setTypeMap) : null.

        This error appears becaus eof the fix suggested in the link that causes a NPE if the map is null ( map.isEmpty()) causes a NPE that appears as this problem.

        My suggested fix to handle this problem is :

        if((map != null))

        { if(!(map.isEmpty())) throw Util.notImplemented(); }

        I also did not get the error when the connection is actually closed. The right way to clean up things when using the JdbcRowSet is to call close() method in the JdbcRowSet and then call the close method on the connection.

        Please have a look at this and let me know.

        PS: Please see below for the attached sample program

        thanks
        Shreyas

        --------------------Sample Program begins---------------------------------

        import java.sql.*;
        import javax.sql.rowset.*;
        import com.sun.rowset.*;

        public class updateNull{

        public static void main(String [] args) {

        String strUrl = "jdbc:derby:;databaseName=testdb;create=true";
        try {
        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
        Connection con = DriverManager.getConnection(strUrl);

        Statement stmt = con.createStatement();
        try

        { stmt.executeUpdate("drop table test"); }

        catch(SQLException ex)

        { // Do nothing. }

        con.commit();

        Statement stmt1 = con.createStatement();
        stmt1.executeUpdate("create table test(i_val integer, s_val varchar(10))");
        stmt1.executeUpdate("insert into test values(1,'shreyas')");
        con.commit();

        JdbcRowSet jrs = new JdbcRowSetImpl(con);
        jrs.setCommand("select * from test");
        jrs.execute();
        jrs.close();

        con.close();

        } catch(ClassNotFoundException cnfe)

        { System.out.println("Class not found: "+cnfe.getMessage()); }

        catch(SQLException sqle)

        { System.out.println("SQL:Caught: "+sqle.getMessage()); sqle.printStackTrace(); }

        catch(Exception e) {

        }

        }
        }

        -------------------Sample Program Ends---------------------------------------

        Show
        Shreyas Kaushik added a comment - I wrote a sample program using JdbcRowSet and found it to working perfectly with Derby. I am attaching the sample program here. It did not throw up the error JdbcRowSet (setTypeMap) : null. This error appears becaus eof the fix suggested in the link that causes a NPE if the map is null ( map.isEmpty()) causes a NPE that appears as this problem. My suggested fix to handle this problem is : if((map != null)) { if(!(map.isEmpty())) throw Util.notImplemented(); } I also did not get the error when the connection is actually closed. The right way to clean up things when using the JdbcRowSet is to call close() method in the JdbcRowSet and then call the close method on the connection. Please have a look at this and let me know. PS: Please see below for the attached sample program thanks Shreyas -------------------- Sample Program begins --------------------------------- import java.sql.*; import javax.sql.rowset.*; import com.sun.rowset.*; public class updateNull{ public static void main(String [] args) { String strUrl = "jdbc:derby:;databaseName=testdb;create=true"; try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); Connection con = DriverManager.getConnection(strUrl); Statement stmt = con.createStatement(); try { stmt.executeUpdate("drop table test"); } catch(SQLException ex) { // Do nothing. } con.commit(); Statement stmt1 = con.createStatement(); stmt1.executeUpdate("create table test(i_val integer, s_val varchar(10))"); stmt1.executeUpdate("insert into test values(1,'shreyas')"); con.commit(); JdbcRowSet jrs = new JdbcRowSetImpl(con); jrs.setCommand("select * from test"); jrs.execute(); jrs.close(); con.close(); } catch(ClassNotFoundException cnfe) { System.out.println("Class not found: "+cnfe.getMessage()); } catch(SQLException sqle) { System.out.println("SQL:Caught: "+sqle.getMessage()); sqle.printStackTrace(); } catch(Exception e) { } } } ------------------- Sample Program Ends ---------------------------------------
        Hide
        Daniel John Debrunner added a comment -

        Sending java\engine\org\apache\derby\iapi\reference\SQLState.java
        Sending java\engine\org\apache\derby\impl\jdbc\EmbedCallableStatement20.java
        Sending java\engine\org\apache\derby\impl\jdbc\EmbedConnection20.java
        Sending java\engine\org\apache\derby\impl\jdbc\EmbedResultSet20.java
        Sending java\engine\org\apache\derby\loc\messages_en.properties
        Transmitting file data .....
        Committed revision 106787.

        Fix for Derby-33 - not implemented exception when passing in empty type map to JBDC calls.

        Handling the map conditions the following way

        null Map --> throw a SQLException
        empty Map --> no-op
        non-empty Map --> throw notImplemented.

        Patch contributed by Shreyas Kaushik (Shreyas.Kaushik@Sun.COM)

        Show
        Daniel John Debrunner added a comment - Sending java\engine\org\apache\derby\iapi\reference\SQLState.java Sending java\engine\org\apache\derby\impl\jdbc\EmbedCallableStatement20.java Sending java\engine\org\apache\derby\impl\jdbc\EmbedConnection20.java Sending java\engine\org\apache\derby\impl\jdbc\EmbedResultSet20.java Sending java\engine\org\apache\derby\loc\messages_en.properties Transmitting file data ..... Committed revision 106787. Fix for Derby-33 - not implemented exception when passing in empty type map to JBDC calls. Handling the map conditions the following way null Map --> throw a SQLException empty Map --> no-op non-empty Map --> throw notImplemented. Patch contributed by Shreyas Kaushik (Shreyas.Kaushik@Sun.COM)
        Hide
        Kristian Waagan added a comment -

        Verified fix by quick code inspection and minimalistic JDBC testing.
        Closing the issue.

        Show
        Kristian Waagan added a comment - Verified fix by quick code inspection and minimalistic JDBC testing. Closing the issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Daniel John Debrunner
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development