You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Edward Rayl <er...@bellsouth.net> on 2004/09/04 02:11:18 UTC

Rowset shortcomings

I'm working on some JDBC text that runs the same code on four different 
databases: Oracle, MySQL, HSQLDB, and Derby.  In my Rowset example, all 
databases behave correctly except Derby.  The code is shown below (I 
have omitted the DBUtil wrapper class to keep this message short).  If  
I omit the bind parameter and setInt(), it makes no difference.  The 
same version, implemented as a ResultSet, works fine.  The errors are:

 >JdbcRowSet (setTypeMap): Feature not implemented: no details.
which occurs on the statement: jrs.execute();

and the next error is:

 >SQL Exception when closing database resources
 >SQL State:   XJ012
 >Vendor code: 20000
 >Message:     'Connection' already closed.
which occurs when closing the connection.

I'm assuming that the problems are with Derby since this code runs on 
the other three databases without incident.  Any insights?  BTW, I've 
had not had a problem with a CachedRowSet test on Derby.

Ed
----------------------------------------------------------------------
import java.sql.*;
import com.sun.rowset.*;
import oi.util.DBUtil;

public class DisplayEmployeesRs
{
    private static Connection conn;
    private static JdbcRowSetImpl jrs;
    private static String query = "select * from employee where salary < ?";

    public static void salariesRowSet()
    {
        try
        {
            conn = DBUtil.getConnection();
            jrs = new JdbcRowSetImpl(conn);
            jrs.setCommand(query);
            jrs.setInt(1, 20000);
            jrs.execute();
            while (jrs.next())
            {
                String first = jrs.getString("firstname");
                String last = jrs.getString("lastname");
                int salary = jrs.getInt("salary");
                System.out.println(first + " " + last + ": " + salary);
            }
        }
        // code omitted here
        DBUtil.close(jrs);
        DBUtil.close(conn);
    }



Re: Rowset shortcomings

Posted by Edward Rayl <er...@bellsouth.net>.
Dan,

> There's probably a good chance that an empty Map object is being passed
> into setTypeMap. One could try modifying the code to accept a type map
> (but do nothing with it) if it is empty, otherwise throw the 'not
> implemented' exception.
>
> This approach has been taken before for methods that are not fully
> supported by accepting a default or no-op value.

In  EmbeddedConnection20.java, I changed:

    public void setTypeMap(java.util.Map map) throws SQLException {
        throw Util.notImplemented();
    }

to:

    public void setTypeMap(java.util.Map map) throws SQLException {
      if ((map != null) || !(map.isEmpty()))
            throw Util.notImplemented();
    }

This changed:

    JdbcRowSet (setTypeMap): Feature not implemented: no details.

to
 
    JdbcRowSet (setTypeMap): null


and I still get a SQLException when closing the connection:

    SQL State:   XJ012
    Vendor code: 20000
    Message:     'Connection' already closed.

Sort of a partial victory.

Ed




Re: Rowset shortcomings

Posted by Daniel John Debrunner <dj...@debrunners.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mamta Satoor wrote:

| Hi Ed,
|
| It seems like JdbcRowSetImpl is internally making a call to
| Connection.setTypeMap
| which is not yet implemented by Derby and that's why the exception.
|
| Mamta

There's probably a good chance that an empty Map object is being passed
into setTypeMap. One could try modifying the code to accept a type map
(but do nothing with it) if it is empty, otherwise throw the 'not
implemented' exception.

This approach has been taken before for methods that are not fully
supported by accepting a default or no-op value.

Dan.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBOeumIv0S4qsbfuQRAtVpAKCFecdDciEuhfU+z1V1kHK/lyuZbwCgyWBf
MoWXF5EiGa3+RCoob8j0b3Y=
=vkQa
-----END PGP SIGNATURE-----


Re: Rowset shortcomings

Posted by Mamta Satoor <ma...@Remulak.Net>.
Hi Ed,

It seems like JdbcRowSetImpl is internally making a call to
Connection.setTypeMap
which is not yet implemented by Derby and that's why the exception.

Mamta

Edward Rayl wrote:

> I'm working on some JDBC text that runs the same code on four different
> databases: Oracle, MySQL, HSQLDB, and Derby.  In my Rowset example, all
> databases behave correctly except Derby.  The code is shown below (I
> have omitted the DBUtil wrapper class to keep this message short).  If
> I omit the bind parameter and setInt(), it makes no difference.  The
> same version, implemented as a ResultSet, works fine.  The errors are:
>
>  >JdbcRowSet (setTypeMap): Feature not implemented: no details.
> which occurs on the statement: jrs.execute();
>
> and the next error is:
>
>  >SQL Exception when closing database resources
>  >SQL State:   XJ012
>  >Vendor code: 20000
>  >Message:     'Connection' already closed.
> which occurs when closing the connection.
>
> I'm assuming that the problems are with Derby since this code runs on
> the other three databases without incident.  Any insights?  BTW, I've
> had not had a problem with a CachedRowSet test on Derby.
>
> Ed
> ----------------------------------------------------------------------
> import java.sql.*;
> import com.sun.rowset.*;
> import oi.util.DBUtil;
>
> public class DisplayEmployeesRs
> {
>     private static Connection conn;
>     private static JdbcRowSetImpl jrs;
>     private static String query = "select * from employee where salary < ?";
>
>     public static void salariesRowSet()
>     {
>         try
>         {
>             conn = DBUtil.getConnection();
>             jrs = new JdbcRowSetImpl(conn);
>             jrs.setCommand(query);
>             jrs.setInt(1, 20000);
>             jrs.execute();
>             while (jrs.next())
>             {
>                 String first = jrs.getString("firstname");
>                 String last = jrs.getString("lastname");
>                 int salary = jrs.getInt("salary");
>                 System.out.println(first + " " + last + ": " + salary);
>             }
>         }
>         // code omitted here
>         DBUtil.close(jrs);
>         DBUtil.close(conn);
>     }