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

sqlserver: requested operation is not supported on forward..

 
   Database Forums (Home) -> Java RSS
Next:  'Null' columns disappear in dynamic pivots  
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: 3



(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: Jun 30, 2005
Posts: 8



(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:
Advise on mapping JTable to large PostgreSQL table request.. - Hi, I *must* (as in: I have no choice and it can't be solved another way by customer demand) display a large table (> 1.100.000 records) in a JTable ( or something that looks like a JTable for the customer). The customer wants to able to search th...

is there a JDBC equivalent to Oracle's PRO*C DESCRIBE oper.. - I am porting code from Oracle's PRO*C to JDBC. In PRO*C, if I have a text which represents an unknown SQL statement, I can describe it and get the names (and number) of bind variables in it. For example, describing SELECT a,b from t where a= :bind1 an...

Callable statements, SQLServer and JRun - Hi, I'm developing a java application which uses SQL Server as the database. I use Callable Statements to connect to the database. I use JRun as the app server. When running the application I want to be able to monitor locks/process info etc in the..

2nd Globals Programming Challenge - USD $3,500 Grand Prize.. - Want to show how good you are at coding "Big Data" solutions? InterSystems Corp. is hosting a series of programming challenges in the Globals Community. Our 2nd Globals Challenge kicks off with a two day competition on Friday, December 02, 20...

algorithm for generating top fuzzy variations ... - Hello all, I am interested in obtaining the top N fuzzy variations of an string (a person or company name) using the same concept as the Levenshtein distance. Ussually Levenshtein is used to compute the distance between two given strings ... but I would...
   Database Forums (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 ]