Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JDBC PreparedStatement gives null after executing a valid SELECT statement

bdzevelJan 4 2013 — edited Jan 7 2013
Hello,

I have the following code:
    public static String GetJobLogLocation(Connection connection, int jobId) throws SQLException
    {
        String sqlstr = "SELECT LOGFILE_NAME FROM apps.fnd_concurrent_requests WHERE REQUEST_ID = ?";
        PreparedStatement prest = connection.prepareStatement(sqlstr);
        prest.setInt(1, jobId);
        ResultSet rs1 = prest.executeQuery();
        String rv = null;
        if (rs1.next())
        {
            rv = rs1.getString(1);
            System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + rv);
        }
        rs1.close();
        prest.close();
        return rv;
    }
As you can see, this function executes a select statement. Before I continue, let me first say that executing the exact same statement in PL/SQL Developer (external program) yields correct/expected results. Also, running this on my Windows environment yields correct/expected results. I seem to be having this problem only on my Unix environment (SunOS).

Anyways, I get output as follows from this function (running against my Unix environment, of course):

+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>null+

The thing is, it doesn't error out, which means that the ResultSet contains a String, but the string is returned to me as null, even though there is a real, valid result (which, in this case, is a path).

Does anyone have any idea what's going on? I've tried using ojdbc6.jar AND ojdbc14.jar, with the same results. I just don't get it...

Thanks.

Edited by: 964530 on Jan 4, 2013 2:31 PM

Edited by: EJP on 7/01/2013 17:48: added {noformat}
{noformat} tags and removed your bizarre bold formatting. Please do this properly in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
This post has been answered by TPD-Opitz on Jan 7 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 4 2013
Added on Jan 4 2013
22 comments
2,907 views