Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ResultSet.isBeforeFirst() not working in Java 6, WebLogic 10

Posted on 2009-05-12
13
1,264 Views
Last Modified: 2013-12-18
My team is migrating our web application from WebLogic 8.1 to WebLogic 10.3. We have a whole bunch of places where we check for the presence of data in a ResultSet using rs.isBeforeFirst(). The code works on the old server (WLS 8.1, Java 1.4), but not on the new one (WLS 10.3, Java 6). They're both hitting the same Oracle 10g database.

Is there a bug somewhere I'm not aware of? Maybe a configuration variable I need to change? Could it be a jdbc driver issue?

Thanks!
0
Comment
Question by:ftaco96
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 12

Expert Comment

by:Gibu George
ID: 24367375
If anyexceptions are there please post that
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 450 total points
ID: 24367425
>>Could it be a jdbc driver issue?

Yes. As it happens, not all drivers support that call. The important point though is that it's quite unnecessary and actually quite an expensive operation. if (rs.next()) will tell you if there's data. Why do you think you need it?
0
 
LVL 9

Author Comment

by:ftaco96
ID: 24367665
We're already using it (in 440 different places) because sometimes we want to check whether there's data before we try to write it. If there's no data, we write out a "No records retrieved" line, for instance. if (rs.next()) moves to the first record, and then screws up the while (rs.next()).

We may not NEED it, but the fact is that we already have it everywhere in the code, and changing all the code is unfeasible.

If we can find the right driver, that would be preferable. We're looking at differences between our old and new environments driver-wise. If you have any suggestions, please let me know. We're connecting to Oracle 10 in both cases.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 86

Expert Comment

by:CEHJ
ID: 24367723
>>if (rs.next()) moves to the first record, and then screws up the while (rs.next()).

Well if you want to read it, then of course it would be as below.

See the following for checking out scrollability


http://www.exampledepot.com/egs/java.sql/CanSrs.html


boolean noResults = true;
while(rs.next()) {
    noResults = false;
} 

Open in new window

0
 
LVL 9

Author Comment

by:ftaco96
ID: 24368123
So, how do I find out if my driver supports that call and where to get one that does?
0
 
LVL 92

Assisted Solution

by:objects
objects earned 50 total points
ID: 24370025
> Could it be a jdbc driver issue?

not if you haven't changed the driver version

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24370035
>>So, how do I find out if my driver supports that call

See the link i posted
0
 
LVL 92

Expert Comment

by:objects
ID: 24370036
> So, how do I find out if my driver supports that call and where to get one that does?

it would throw an exception if that was the problem :)
doubt thats the problem

0
 
LVL 9

Author Comment

by:ftaco96
ID: 24370201
Thanks guys! I'll look into it more tomorrow.
0
 
LVL 92

Expert Comment

by:objects
ID: 24370303
It may be that there was previously a bug (in java) which you were exploiting and now it has been fixed.
Post your code when you have it and I'll have a look at it for you.

0
 
LVL 9

Author Comment

by:ftaco96
ID: 24374718
Well, I don't see how we could be exploiting a bug, since we're using the method as it's documented.

I should mention that this code works in some places in the web app and breaks in other places. Not sure why.

> > Could it be a jdbc driver issue?
>
> not if you haven't changed the driver version

Actually, I believe the driver version did change. I think the driver was in the ojdbc14.jar file in WLS 8.1 but is in ojdbc6.jar in WLS 10.3. Please correct me if I'm wrong.

I attached a code snippet. I want to reiterate, though, that changing all the code is unfeasible, so I don't need to figure out an alternate way to do this.

public ArrayList getAudit(String monthYear, String orderBy)
   throws Exception {
  OracleCallableStatement stmt = null;
  ResultSet rs = null;
  ArrayList arrData = new ArrayList();
  DOAudit doAudit = null;
 
  DOAuditNotes doNotes = null;
 
  try {
    verifyConnection();
    String spcall = "{call PKG_AUDIT.SP_AUDIT_RESULTS(?,?,?)}";
    stmt = (OracleCallableStatement) con.prepareCall(spcall);
    stmt.registerOutParameter(1, OracleTypes.CURSOR);
    stmt.setString(2, monthYear);
    stmt.setString(3, orderBy);
 
    stmt.execute();
    rs = stmt.getCursor(1);
 
    if (rs.isBeforeFirst()) {
 
      while (rs.next()) {
        /*
          a lot of complicated code
        */
      }       
      arrData.add(doAudit); 
    } 
 
  } catch (Exception ex) {
    logger.error("getAudit", ex);
    throw ex;
  } finally {
	ReleaseResources.release(con, stmt, rs);
	rs = null;
	stmt = null;
	con = null;
  }
  return(arrData);
}

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24374970

>>I should mention that this code works in some places in the web app and breaks in other places. Not sure why.

Could be that different drivers are being loaded in different parts
0
 
LVL 9

Accepted Solution

by:
ftaco96 earned 0 total points
ID: 24379054
It turns out that there is a patch version of the ojdbc6.jar file that can be downloaded from Oracle.

Here's the readme that discusses the fix...
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/111070_readme.html

BUG-6208793
Behavioural difference in isBeforeFirst between thin and oci when fetched as
cursors.

The download page...
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_111060.html
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Function to return one result based on data in first query 11 49
Html Table Looping (part 2) 5 27
Bot application - advice 3 38
oracle collections 2 20
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question