Results 1 to 7 of 7
  1. #1
    RajeshB is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Post JDBC ResultSet Issue With Oracle 11g Database

    Hi All ,

    I need an urgent help on a very pecualiar JDBC issue.

    The scenario is as given below.

    We have a standlaone java client(Named as FileConverter) which accepts input files(ic CSVs and text file format) and does the necessary processing.

    It just does reads from the Oracle DB(11g version) while processing the input files and does no insert/update/delete activity.

    This client was earlier working seamlessly with IBM DB2 database.As a result of the client decision , there was a migration happend from DB2 to Oracle a sometime back.

    Post migration , there is an issue reported by the testing team that, in the output files(which get generated by the FileConverter and are also in CSV format) , the

    data fields which are supposed to hold character/String values , are displaying junk characters.


    After analyzing the application log file , I noticed that, fetching up the results from the JDBC ResultSet(just to update you that this utlity was developed long back hence still uses classic JDBC to interact with the Oracle DB)

    (especially while retrieving the VARCHAR2 type fields) ,gives back this junk characters which are of the pattern "???" , "??????", "?????????". The ResultSet method used to retrieve these values are ResultSet.getBinaryStream(Colomn name)which returns an InputStream that finally gets converted to a java String.

    ResultSet.getBinaryStream(column name) itself gives back these junk characters.


    Just as a context, the character encoding set in DB2 was UCS2 which supports a 16-bit encoding where as the character encoding set in the Oracle DB post migration is UTF-8.

    I had requested the DBA team to change the character encoding in the present DB from UTF-8 to UTF-16 but they can't entertain this request due to a DB level constraint hence this client/utlity somehow needs to address this peculiar issue.

    The pecualiarity here is,there is hardly I can do about playing around with the ResultSet as it's a JDBC API .


    As a resolution approach , I tried few things so far.

    1) Updated the old JDBC driver class to use the latest JDBC driver compatible with Oracle 11g

    2) Tried using ResultSet.getString() , ResultSet.getObject() in place of the existing one i.e. ResultSet.getBinaryStream()

    3) Tried enforcing UTF-8 format whenever I am reading an input file and writing into an output file.

    4) Tried using OracleResultSet in place of ResultSet.


    Unfortunately none of the above approaches has worked till now!!!


    Ideally the latest compliant JDBC driver with Oracle 11g should have taken care of this issue but it didn't.

    So any suggestions for a speedy resolution of this issue will be a big favor and much appreciated .


    Regards
    Rajesh

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,874
    Rep Power
    5

    Default Re: JDBC ResultSet Issue With Oracle 11g Database

    If it is so massively urgent you are posting in the wrong site, try the OTN forums.

    https://community.oracle.com/communi...eloper/english

    If you need quick and direct assistance, post in a place where you have the biggest chance of reaching people who use the same stuff as you do. Just a tip: don't post that it is urgent, that will only backfire on you as most people interpret that as something very rude to do.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default Re: JDBC ResultSet Issue With Oracle 11g Database

    If the column is not a LOB or CLOB or BLOB, but rather a simple CHAR or VARCHAR or NVARCHAR or NCHAR, then use getString.

    Sorry, I see you claim to have tried getString, in which case, check the data in the DB.

  4. #4
    RajeshB is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Re: JDBC ResultSet Issue With Oracle 11g Database

    Hi ,

    Thanks for the response and sorry for highlighting the urgency of this help. Your point taken on this and I will ensure that this rudeness won't be repeated in future.

    I will go ahead with your suggestion in parallel.

  5. #5
    RajeshB is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Re: JDBC ResultSet Issue With Oracle 11g Database

    Hi ,

    Thanks for suggesting this which I have tried already (coincidentally)through a SQL GUI analyzer and running the application query there fetched me data which looked OK to me.

    I am truly baffled as to what else might be wrong here.

  6. #6
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,874
    Rep Power
    5

    Default Re: JDBC ResultSet Issue With Oracle 11g Database

    I have seen character set shit in the past. I believe a colleague of mine resolved that by setting a specific java system property that the OJDBC driver would interpret, but I have no documentation ready for that.

    And PS number 2: when you do create a post in OTN, add a link to this thread. Cross-posting without telling you did that is a second "no-no" in the land of (programming) internet forums.
    Last edited by gimbal2; 02-13-2014 at 03:13 PM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    RajeshB is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Re: JDBC ResultSet Issue With Oracle 11g Database

    Thanks a lot again for providing the the pointer on a probable java system property setting. I will try to find out what it is.

    Secondly , I will also take care about the cross-platform posting etiquette you have recommended.

Similar Threads

  1. Replies: 1
    Last Post: 04-08-2013, 10:22 AM
  2. Replies: 2
    Last Post: 04-01-2010, 04:35 AM
  3. Replies: 0
    Last Post: 12-01-2009, 10:01 PM
  4. Using JDBC to connect to ORACLE database
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-10-2008, 11:27 AM
  5. Oracle Resultset slow
    By Peter in forum JDBC
    Replies: 2
    Last Post: 07-04-2007, 01:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •