Re: [TOMCAT-JDBC] rs.absolute() throws "Invalid operation for forward only resultset: absolute"

2016-09-08 Thread Mohamad Abbas
I've created Bug 60099


2016-09-08 17:20 GMT+02:00 Christopher Schultz :

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Mohamad,
>
> On 9/8/16 4:20 AM, Mohamad Abbas wrote:
> > Hello,
> >
> > I am working on a legacy web application running on a tomcat
> > 8.0.37, and i am getting an error "Invalid operation for forward
> > only resultset: absolute" when trying to use an
> > InsensitiveScrollableResultSet (to paginate results).
> >
> > To make it simple and reproduce the problem i've created a test
> > project who contains the "Main" class below. The test project is
> > executed on on a windows 7, using jdk1.8.0_92. The only jars are
> > present in the classpath of the project are: tomcat-jdbc(8.0.37),
> > tomcat-juli(8.8.37), and ojdbc7-12.1.0.2.0.
> >
> > Those are the steps to reproduce the problem:
> >
> > - Create a Statement using the method .prepareStatement(String)=>
> > OK - Execute the query => OK (simple query: SELECT 1 FROM dual) -
> > Create a new Statement (with a SCROLL_INSENSITIVE type) for the
> > same query (SELECT 1 FROM dual) => KO (or OK?), tomcat-jdbc is
> > returning the cached Statement created in Step 1 (a FORWARD_ONLY
> > Statement). - Execute the query => OK - Call absolute method =>
> > Exception: Invalid operation for forward only resultset: absolute
> >
> > I don't know if it is really a bug in tomcat-jdbc or if my problem
> > is due to a misconfiguration.
>
> This looks like a bug to me. Please file a BZ issue for this, and
> include your test case. Also please include a full stack trace of the
> error. If this is possible to get working with an embedded database
> e.g. Derby (which ships with recent Java versions), please do that
> instead of complicating things with Oracle, etc.
>
> Thanks,
> - -chris
> -BEGIN PGP SIGNATURE-
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJX0YGsAAoJEBzwKT+lPKRYJHMQAIkgWgJq+5WQj9uNEVYE55oY
> aw6rqc3HOA7V5YK83Q02uPW+XxklXXc74EsJV9nSHfuG6K+gU4zk10/+1YNDM4M4
> OljO9ACua+/lV21t1zqaBIr0+cJQ8dDphwMve9q1j5YNiqCB2UsxmT/fOLwUqPrx
> gItN5trShCDvIGlGNSx5BJS2mF5jm6yJUeFUccRUWKJWthi2jzjNjFSqBHh5+wZV
> aIDI8ljXpqCie5tflRM9wF+Bf/jufufssQMSY2+nmcTuu9NHyA5hshGNo3XNAIIA
> E3tJsi9BQ6wvR0eqV7VbgfANSGRRUpWqvaPmtiXSXvYszVjCkItPhp+drjbyFil5
> 6j7p/c0gWtHPhQJ9xWGnIrXvSt6otlAxNEHQedrz43wE5ekEmBTSmIFafaWYICpm
> vHpKoRvnEFKB2UdONRjEs7kX7arTqzpaxuqcN4/1178Cir16ab12NL5fab0cnzx8
> Lwqer8EGOndtc1a5nn3vtxwd2HQb8HN+mG98Czy5ChDeiGZv4MHByCeck8wJF+nQ
> TqvBuIRDyrVCG09bmBIRdVb65MmdQhlxoxB+k+uURGGGY5GgkC5O21mje9N8+vcn
> UmmfeyDrHs4HvecvSfz7/kmFAM+yj8AqsjeYNpWQU4wG/v/kz+Eof1zkLbZs4VyH
> Tu30JtRs0P0hzlTAq60N
> =htwU
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: [TOMCAT-JDBC] rs.absolute() throws "Invalid operation for forward only resultset: absolute"

2016-09-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Mohamad,

On 9/8/16 4:20 AM, Mohamad Abbas wrote:
> Hello,
> 
> I am working on a legacy web application running on a tomcat
> 8.0.37, and i am getting an error "Invalid operation for forward
> only resultset: absolute" when trying to use an
> InsensitiveScrollableResultSet (to paginate results).
> 
> To make it simple and reproduce the problem i've created a test
> project who contains the "Main" class below. The test project is
> executed on on a windows 7, using jdk1.8.0_92. The only jars are
> present in the classpath of the project are: tomcat-jdbc(8.0.37),
> tomcat-juli(8.8.37), and ojdbc7-12.1.0.2.0.
> 
> Those are the steps to reproduce the problem:
> 
> - Create a Statement using the method .prepareStatement(String)=>
> OK - Execute the query => OK (simple query: SELECT 1 FROM dual) -
> Create a new Statement (with a SCROLL_INSENSITIVE type) for the
> same query (SELECT 1 FROM dual) => KO (or OK?), tomcat-jdbc is
> returning the cached Statement created in Step 1 (a FORWARD_ONLY
> Statement). - Execute the query => OK - Call absolute method =>
> Exception: Invalid operation for forward only resultset: absolute
> 
> I don't know if it is really a bug in tomcat-jdbc or if my problem
> is due to a misconfiguration.

This looks like a bug to me. Please file a BZ issue for this, and
include your test case. Also please include a full stack trace of the
error. If this is possible to get working with an embedded database
e.g. Derby (which ships with recent Java versions), please do that
instead of complicating things with Oracle, etc.

Thanks,
- -chris
-BEGIN PGP SIGNATURE-
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJX0YGsAAoJEBzwKT+lPKRYJHMQAIkgWgJq+5WQj9uNEVYE55oY
aw6rqc3HOA7V5YK83Q02uPW+XxklXXc74EsJV9nSHfuG6K+gU4zk10/+1YNDM4M4
OljO9ACua+/lV21t1zqaBIr0+cJQ8dDphwMve9q1j5YNiqCB2UsxmT/fOLwUqPrx
gItN5trShCDvIGlGNSx5BJS2mF5jm6yJUeFUccRUWKJWthi2jzjNjFSqBHh5+wZV
aIDI8ljXpqCie5tflRM9wF+Bf/jufufssQMSY2+nmcTuu9NHyA5hshGNo3XNAIIA
E3tJsi9BQ6wvR0eqV7VbgfANSGRRUpWqvaPmtiXSXvYszVjCkItPhp+drjbyFil5
6j7p/c0gWtHPhQJ9xWGnIrXvSt6otlAxNEHQedrz43wE5ekEmBTSmIFafaWYICpm
vHpKoRvnEFKB2UdONRjEs7kX7arTqzpaxuqcN4/1178Cir16ab12NL5fab0cnzx8
Lwqer8EGOndtc1a5nn3vtxwd2HQb8HN+mG98Czy5ChDeiGZv4MHByCeck8wJF+nQ
TqvBuIRDyrVCG09bmBIRdVb65MmdQhlxoxB+k+uURGGGY5GgkC5O21mje9N8+vcn
UmmfeyDrHs4HvecvSfz7/kmFAM+yj8AqsjeYNpWQU4wG/v/kz+Eof1zkLbZs4VyH
Tu30JtRs0P0hzlTAq60N
=htwU
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: [TOMCAT-JDBC] rs.absolute() throws "Invalid operation for forward only resultset: absolute"

2016-09-08 Thread Mohamad Abbas
The ojdbc7-12.1.0.2.0 support TYPE_SCROLL_INSENSITIVE. I already made the
test by calling only the second method who creates a Statement with a
SCROLL_INSENSITIVE type, and it worked.

Regards,

2016-09-08 11:29 GMT+02:00 Terence M. Bandoian :

> On 9/8/2016 3:20 AM, Mohamad Abbas wrote:
>
>> Hello,
>>
>> I am working on a legacy web application running on a tomcat 8.0.37, and i
>> am getting an error "Invalid operation for forward only resultset:
>> absolute" when trying to use an InsensitiveScrollableResultSet (to
>> paginate
>> results).
>>
>> To make it simple and reproduce the problem i've created a test project
>> who
>> contains the "Main" class below. The test project is executed on on a
>> windows 7, using jdk1.8.0_92. The only jars are present in the classpath
>> of
>> the project are: tomcat-jdbc(8.0.37), tomcat-juli(8.8.37),
>> and ojdbc7-12.1.0.2.0.
>>
>> Those are the steps to reproduce the problem:
>>
>> - Create a Statement using the method .prepareStatement(String)=> OK
>> - Execute the query => OK (simple query: SELECT 1 FROM dual)
>> - Create a new Statement (with a SCROLL_INSENSITIVE type) for the same
>> query (SELECT 1 FROM dual) => KO (or OK?), tomcat-jdbc is returning
>> the
>> cached Statement created in Step 1 (a FORWARD_ONLY Statement).
>> - Execute the query => OK
>> - Call absolute method => Exception: Invalid operation for forward
>> only
>>
>> resultset: absolute
>>
>> I don't know if it is really a bug in tomcat-jdbc or if my problem is due
>> to a misconfiguration.
>>
>> Here is the code:
>>
>> package test;
>>
>> import java.sql.Connection;
>> import java.sql.PreparedStatement;
>> import java.sql.ResultSet;
>>
>> import org.apache.tomcat.jdbc.pool.DataSource;
>> import org.apache.tomcat.jdbc.pool.PoolProperties;
>>
>> public class Main {
>>
>>  private static DataSource datasource;
>>
>>  static {
>>  PoolProperties p = new PoolProperties();
>>  p.setUrl("jdbc:oracle:thin:@localhost:1531:test");
>>  p.setDriverClassName("oracle.jdbc.OracleDriver");
>>  p.setUsername("test");
>>  p.setPassword("test");
>>  p.setTestWhileIdle(true);
>>  p.setTestOnBorrow(false);
>>  p.setValidationQuery("SELECT 1 FROM dual");
>>  p.setValidationInterval(3);
>>  p.setMaxActive(1); // to simplify the test
>>  p.setInitialSize(1); // to simplify the test
>>  p.setMaxWait(1); // to simplify the test
>>  p.setMinEvictableIdleTimeMillis(3);
>>  p.setMinIdle(1); // to simplify the test
>>  p.setMaxIdle(1); // to simplify the test
>>  p.setJdbcInterceptors("StatementCache(max=10)"); // If i
>> replace max=10 by max = 0, the problem disappears
>>  datasource = new DataSource();
>>  datasource.setPoolProperties(p);
>>  }
>>
>>  public static void main(String[] args) throws Exception {
>>  testWithForwardOnlyResultSet(datasource);
>>  testWithInsensitiveResultSet(datasource);
>>  }
>>
>>  private static void testWithForwardOnlyResultSet(DataSource
>> datasource)
>> throws Exception {
>>  Connection con = datasource.getConnection();
>>  PreparedStatement st = con.prepareStatement("select 1 from
>> dual");
>>  ResultSet rs = st.executeQuery();
>>  while (rs.next()) {
>>  System.out.println("Result = " + rs.getString(1));
>>  }
>>  rs.close();
>>  st.close();
>>  con.close();
>>  }
>>
>>  private static void testWithInsensitiveResultSet(DataSource
>> datasource)
>> throws Exception {
>>  Connection con = datasource.getConnection();
>>  PreparedStatement st = con.prepareStatement("select 1 from dual",
>> ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
>>  ResultSet rs = st.executeQuery();
>>  rs.absolute(1);
>>  while (rs.next()) {
>>  System.out.println("Result = " + rs.getString(1));
>>  }
>>  rs.close();
>>  st.close();
>>  con.close();
>>  }
>>
>> }
>>
>> Please tell me, if you need more informations.
>>
>> Thanks for your help!
>>
>
>
> If a JDBC driver does not support TYPE_SCROLL_INSENSITIVE, it may fall
> back silently to TYPE_FORWARD_ONLY.
>
> -Terence Bandoian
>  http://www.tmbsw.com/
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: [TOMCAT-JDBC] rs.absolute() throws "Invalid operation for forward only resultset: absolute"

2016-09-08 Thread Terence M. Bandoian

On 9/8/2016 3:20 AM, Mohamad Abbas wrote:

Hello,

I am working on a legacy web application running on a tomcat 8.0.37, and i
am getting an error "Invalid operation for forward only resultset:
absolute" when trying to use an InsensitiveScrollableResultSet (to paginate
results).

To make it simple and reproduce the problem i've created a test project who
contains the "Main" class below. The test project is executed on on a
windows 7, using jdk1.8.0_92. The only jars are present in the classpath of
the project are: tomcat-jdbc(8.0.37), tomcat-juli(8.8.37),
and ojdbc7-12.1.0.2.0.

Those are the steps to reproduce the problem:

- Create a Statement using the method .prepareStatement(String)=> OK
- Execute the query => OK (simple query: SELECT 1 FROM dual)
- Create a new Statement (with a SCROLL_INSENSITIVE type) for the same
query (SELECT 1 FROM dual) => KO (or OK?), tomcat-jdbc is returning the
cached Statement created in Step 1 (a FORWARD_ONLY Statement).
- Execute the query => OK
- Call absolute method => Exception: Invalid operation for forward only
resultset: absolute

I don't know if it is really a bug in tomcat-jdbc or if my problem is due
to a misconfiguration.

Here is the code:

package test;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties;

public class Main {

 private static DataSource datasource;

 static {
 PoolProperties p = new PoolProperties();
 p.setUrl("jdbc:oracle:thin:@localhost:1531:test");
 p.setDriverClassName("oracle.jdbc.OracleDriver");
 p.setUsername("test");
 p.setPassword("test");
 p.setTestWhileIdle(true);
 p.setTestOnBorrow(false);
 p.setValidationQuery("SELECT 1 FROM dual");
 p.setValidationInterval(3);
 p.setMaxActive(1); // to simplify the test
 p.setInitialSize(1); // to simplify the test
 p.setMaxWait(1); // to simplify the test
 p.setMinEvictableIdleTimeMillis(3);
 p.setMinIdle(1); // to simplify the test
 p.setMaxIdle(1); // to simplify the test
 p.setJdbcInterceptors("StatementCache(max=10)"); // If i
replace max=10 by max = 0, the problem disappears
 datasource = new DataSource();
 datasource.setPoolProperties(p);
 }

 public static void main(String[] args) throws Exception {
 testWithForwardOnlyResultSet(datasource);
 testWithInsensitiveResultSet(datasource);
 }

 private static void testWithForwardOnlyResultSet(DataSource datasource)
throws Exception {
 Connection con = datasource.getConnection();
 PreparedStatement st = con.prepareStatement("select 1 from dual");
 ResultSet rs = st.executeQuery();
 while (rs.next()) {
 System.out.println("Result = " + rs.getString(1));
 }
 rs.close();
 st.close();
 con.close();
 }

 private static void testWithInsensitiveResultSet(DataSource datasource)
throws Exception {
 Connection con = datasource.getConnection();
 PreparedStatement st = con.prepareStatement("select 1 from dual",
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
 ResultSet rs = st.executeQuery();
 rs.absolute(1);
 while (rs.next()) {
 System.out.println("Result = " + rs.getString(1));
 }
 rs.close();
 st.close();
 con.close();
 }

}

Please tell me, if you need more informations.

Thanks for your help!



If a JDBC driver does not support TYPE_SCROLL_INSENSITIVE, it may fall 
back silently to TYPE_FORWARD_ONLY.


-Terence Bandoian
 http://www.tmbsw.com/


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



[TOMCAT-JDBC] rs.absolute() throws "Invalid operation for forward only resultset: absolute"

2016-09-08 Thread Mohamad Abbas
Hello,

I am working on a legacy web application running on a tomcat 8.0.37, and i
am getting an error "Invalid operation for forward only resultset:
absolute" when trying to use an InsensitiveScrollableResultSet (to paginate
results).

To make it simple and reproduce the problem i've created a test project who
contains the "Main" class below. The test project is executed on on a
windows 7, using jdk1.8.0_92. The only jars are present in the classpath of
the project are: tomcat-jdbc(8.0.37), tomcat-juli(8.8.37),
and ojdbc7-12.1.0.2.0.

Those are the steps to reproduce the problem:

   - Create a Statement using the method .prepareStatement(String)=> OK
   - Execute the query => OK (simple query: SELECT 1 FROM dual)
   - Create a new Statement (with a SCROLL_INSENSITIVE type) for the same
   query (SELECT 1 FROM dual) => KO (or OK?), tomcat-jdbc is returning the
   cached Statement created in Step 1 (a FORWARD_ONLY Statement).
   - Execute the query => OK
   - Call absolute method => Exception: Invalid operation for forward only
   resultset: absolute

I don't know if it is really a bug in tomcat-jdbc or if my problem is due
to a misconfiguration.

Here is the code:

package test;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties;

public class Main {

private static DataSource datasource;

static {
PoolProperties p = new PoolProperties();
p.setUrl("jdbc:oracle:thin:@localhost:1531:test");
p.setDriverClassName("oracle.jdbc.OracleDriver");
p.setUsername("test");
p.setPassword("test");
p.setTestWhileIdle(true);
p.setTestOnBorrow(false);
p.setValidationQuery("SELECT 1 FROM dual");
p.setValidationInterval(3);
p.setMaxActive(1); // to simplify the test
p.setInitialSize(1); // to simplify the test
p.setMaxWait(1); // to simplify the test
p.setMinEvictableIdleTimeMillis(3);
p.setMinIdle(1); // to simplify the test
p.setMaxIdle(1); // to simplify the test
p.setJdbcInterceptors("StatementCache(max=10)"); // If i
replace max=10 by max = 0, the problem disappears
datasource = new DataSource();
datasource.setPoolProperties(p);
}

public static void main(String[] args) throws Exception {
testWithForwardOnlyResultSet(datasource);
testWithInsensitiveResultSet(datasource);
}

private static void testWithForwardOnlyResultSet(DataSource datasource)
throws Exception {
Connection con = datasource.getConnection();
PreparedStatement st = con.prepareStatement("select 1 from dual");
ResultSet rs = st.executeQuery();
while (rs.next()) {
System.out.println("Result = " + rs.getString(1));
}
rs.close();
st.close();
con.close();
}

private static void testWithInsensitiveResultSet(DataSource datasource)
throws Exception {
Connection con = datasource.getConnection();
PreparedStatement st = con.prepareStatement("select 1 from dual",
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = st.executeQuery();
rs.absolute(1);
while (rs.next()) {
System.out.println("Result = " + rs.getString(1));
}
rs.close();
st.close();
con.close();
}

}

Please tell me, if you need more informations.

Thanks for your help!