JDBC Error

Can anyone help with this. I am trying to get a JDBC connection working however the following code produces this error "java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY" and I am not sure why.

try {
      Connection con = DriverManager.getConnection("jdbc:odbc:server", "user", "passsword");
      Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
      ResultSet uprs = stmt.executeQuery("select * from table");


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zzynxSr. Software engineerCommented:
>> Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
      Statement stmt = con.createStatement();

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Maybe the db/driver doesn't support that type of Statement?
>>Replace .... by ....

How would that work with



Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

For that code so far, you might try:

Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
zzynxSr. Software engineerCommented:
>> How would that work with
>> uprs.absolute(4);
The API doc says:
createStatement() creates a Statement object for sending SQL statements to the database. (...)
Result sets created using the returned Statement object will by default be type TYPE_FORWARD_ONLY
and have a concurrency level of CONCUR_READ_ONLY.

So, writing
>> Statement stmt = con.createStatement();
is in fact the same as
>> Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

OK good point
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.