Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

sqlserver: requested operation is not supported on forward..

 
   Database Help (Home) -> Java RSS
Next:  Using anchor links within pages defined by GETS  
Author Message
Thufir Hawat

External


Since: Feb 26, 2009
Posts: 2



(Msg. 1) Posted: Thu Feb 26, 2009 10:28 am
Post subject: sqlserver: requested operation is not supported on forward only
Archived from groups: comp>lang>java>help, others (more info?)

follow up to databases.


Going by:

<http://svn.apache.org/repos/asf/commons/proper/dbcp/branches/dbcp/doc/
ManualPoolingDataSourceExample.java>



The tomcat log shows:


BaseServlet.getMethodEnum:
crud: BEATLES
Feb 26, 2009 6:18:58 AM a00720398.database.NewDbcp setUri
INFO: jdbc:sqlserver://
j2ee.ca:1433;databaseName=jspweb;selectMethod=cursor;
Feb 26, 2009 6:18:58 AM a00720398.servlet.Controller beatles
SEVERE: null
com.microsoft.sqlserver.jdbc.SQLServerException: The requested operation
is not supported on forward only result sets.


I believe that if a different sort of ResultSet were returned, with
different attributes, that would fix the error. Unfortunately, I don't
know how to get a scrollable result set. No matter what arguments are
passed for the booleans in the PoolableConnectionFactory constructor the
same error occurs.

Obviously, a different approach is needed. What's the correct, or at
least a better, approach?


code:

package a00720398.database;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.dbcp.ConnectionFactory;
import org.apache.commons.dbcp.DriverManagerConnectionFactory;
import org.apache.commons.dbcp.PoolableConnectionFactory;
import org.apache.commons.dbcp.PoolingDataSource;
import org.apache.commons.pool.ObjectPool;
import org.apache.commons.pool.impl.GenericObjectPool;

public class NewDbcp {

private static final String driver2005 =
"com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String url = "jdbc:sqlserver://";
private static final String serverName = "j2ee.ca";
private static final String portNumber = "1433";
private static final String databaseName = "jspweb";
private static final String userName = "userName";
private static final String password = "Password";
private static final String selectMethod = "cursor";
private static Logger logger = Logger.getLogger(NewDbcp.class.getName
()); //Controller.class.getName()
private static PoolingDataSource poolingDataSource = null;
private static Connection connection = null;
private static String uri = "uri";

private NewDbcp() {
}

private static void setUri() {
uri = url + serverName + ":" + portNumber + ";databaseName=" +
databaseName + ";selectMethod=" + selectMethod + ";";
logger.log(Level.INFO, uri);
}

private static void setConnection() {
try {
Class.forName(driver2005);
withGenericObjectPool();
//connection = DriverManager.getConnection(uri, userName,
password);
connection = poolingDataSource.getConnection();
} catch (SQLException ex) {
Logger.getLogger(NewDbcp.class.getName()).log(Level.SEVERE,
null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewDbcp.class.getName()).log(Level.SEVERE,
null, ex);
}
}

private static void withGenericObjectPool() {
setUri();
ObjectPool objectPool = new GenericObjectPool(null);
ConnectionFactory connectionFactory = new
DriverManagerConnectionFactory(uri, userName, password);
PoolableConnectionFactory poolableConnectionFactory = new
PoolableConnectionFactory(connectionFactory, objectPool, null, null,
true, false);
poolingDataSource = new PoolingDataSource(objectPool);
}

public static Connection getConnection() {
setConnection();
return connection;
}
}



Also, which is better, or more appropriate:

ObjectPool objectPool = new GenericObjectPool(null);
GenericObjectPool genericObjectPool = new GenericObjectPool(null);


and, same question, which is better/more appropiate, DataSource or
DriverManager?

"An alternative to the DriverManager facility, a DataSource object is the
preferred means of getting a connection."
http://java.sun.com/j2se/1.5.0/docs/api/javax/sql/DataSource.html




Maybe changes along those lines would fix this error.





thanks,

Thufir

 >> Stay informed about: sqlserver: requested operation is not supported on forward.. 
Back to top
Login to vote
joe.weinstein

External


Since: Feb 26, 2009
Posts: 1



(Msg. 2) Posted: Thu Feb 26, 2009 12:21 pm
Post subject: Re: sqlserver: requested operation is not supported on forward only [Login to view extended thread Info.]
Archived from groups: comp>lang>java>databases (more info?)

Hi. This has to do with the createStatement(), prepareStatement() and
prepareCall()
methods being made on the connection. There are versions of these
methods that
allow you to define(ask for) what sort of result set you get back.

 >> Stay informed about: sqlserver: requested operation is not supported on forward.. 
Back to top
Login to vote
Patricia Shanahan

External


Since: Jul 18, 2006
Posts: 6



(Msg. 3) Posted: Thu Feb 26, 2009 12:44 pm
Post subject: Re: sqlserver: requested operation is not supported on forward only [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

wrote:
> Hi. This has to do with the createStatement(), prepareStatement() and
> prepareCall()
> methods being made on the connection. There are versions of these
> methods that
> allow you to define(ask for) what sort of result set you get back.
>

Also, remember that there are two ways to fix the problem, changing the
capabilities of the result set or changing what is being done with it.

Sometimes, doing more in SQL, such as sorting, grouping, or joining, can
remove the need for other than sequential access to the result set. In
other cases, it can be done by using the result set to initialize a Java
data structure, especially if the result set is known to be small.

Patricia
 >> Stay informed about: sqlserver: requested operation is not supported on forward.. 
Back to top
Login to vote
Thufir Hawat

External


Since: Feb 26, 2009
Posts: 2



(Msg. 4) Posted: Fri Feb 27, 2009 1:25 am
Post subject: Re: sqlserver: requested operation is not supported on forward only [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Thu, 26 Feb 2009 12:44:21 -0800, Patricia Shanahan wrote:

> wrote:
>> Hi. This has to do with the createStatement(), prepareStatement() and
>> prepareCall()
>> methods being made on the connection. There are versions of these
>> methods that
>> allow you to define(ask for) what sort of result set you get back.
>>
>>
> Also, remember that there are two ways to fix the problem, changing the
> capabilities of the result set or changing what is being done with it.
>
> Sometimes, doing more in SQL, such as sorting, grouping, or joining, can
> remove the need for other than sequential access to the result set. In
> other cases, it can be done by using the result set to initialize a Java
> data structure, especially if the result set is known to be small.
>
> Patricia


Thanks, I may take this up again, but I just went in a different
direction instead.

I wanted to use DBCP, and then I found OJB and that seemed better, now
I've settled on JNDI as per:

http://www.ibm.com/developerworks/library/j-jstlsql/index.html


which seems to be the easy way to get pooling?

For my hw I'll have to go back and re-implement as a servlet.

The proliferation of tools and approaches is overwhelming. I'd like to
do something like:

http://www.netbeans.org/kb/articles/hibernate-javaee.html

although I'd have to adapt it for mssql.



thanks,

Thufir
 >> Stay informed about: sqlserver: requested operation is not supported on forward.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
SQLServer 2000 Driver for JDBC behaviour on SQL Server res.. - 1) My java code properly connects to the SQL Server DB via the SQL Server 2000 JDBC driver. 2) During one of our stress tests, we restarted the SQL Server to see how the code handles it. 3) My code doesn't really recognize that the SQL server is up and m...

Displaying contents from database in an applet - I have created a connection to an MSAccess database, but I am unable to display the results in an webbrowser. My question is therefore how do I retrieve and displaty the records of my database on a webpage? Kind regards Johan Reimers

Hibernate and log4j config under Tomcat. - "Under Tomcat 3.x and 4.x, you should place the log4j.properties under the WEB-INF/classes directory of your web-applications. Log4j will find the properties file and initialize itself. This is easy to do and it works." "The XML configu...

Java &amp; MySQL show table status command - Hi, I am using java to retrieve a resultset with "show table status" mysql command. I am having problem reading the [name] and [engine] column. In the metadata object it is showing as VARCHAR but when I do getString() it is returning me the o...

Error returning REF CURSOR - Hello, I'm trying to invoke a PLSQL function returning a REF CURSOR I'm using OracleCallableStatement .... and this is the code: =================CODE======================= Connection conn = null; OracleCallableStatement..
   Database Help (Home) -> Java All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]