Fetch oracle data VARCHAR2(N BYTE) return blank string in JAVA …SOLVED











up vote
0
down vote

favorite












I would like to know what's going on when, I'm trying to fetch data from ORACLE database. The datatype of the column is VARCHAR2(40 BYTE) NOT NULL ENABLE.



From @Thoma advise in comment section I've changed the pics into text.



In SQL DEVELOPPER, I have the following result



SELECT ZONE_DESC FROM IC_RATE_ZONES;
"ZONE_DESC"
VIRGIN ISLANDS UK
VIRGIN ISLANDS US
WALLIS AND FUTUNA IS
YEMEN
ZAMBIA
ZAMBIA MOBILE


And when i've tried to fetch those data in JAVA code :



try{
con = conn.getOracle();
stm = con.createStatement();
Rs = stm.executeQuery("select ZONE_DESC FROM IC_RATE_ZONES");
while(Rs.next()){
System.out.println(Rs.getString("ZONE_DESC"));
}
} catch(Exception e){
e.printStackTrace();
}


I get a blank result in my console output.



thanks for your help.










share|improve this question




















  • 3




    Instead of posting images you might want to post at least your code in properly formatted text form. This makes it easier to preserve (images can get deleted) and work with - and it shows some effort on your part.
    – Thomas
    Nov 21 at 12:25












  • @Thomas, sorry for this. this is a remote host and I cannot copy it because of the restriction. I'll try to write it all and post the text later.
    – kizawa tomaru
    Nov 21 at 12:26












  • What did you expect on the console? You add data to your model but you do not log the actual data to the console. Try System.out.print(Rs.getString(1))
    – Vall0n
    Nov 21 at 12:28








  • 1




    Is there any chance that the code you execute isn't the code you see?
    – Thomas
    Nov 21 at 12:32






  • 1




    Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
    – secret super star
    Nov 21 at 13:31















up vote
0
down vote

favorite












I would like to know what's going on when, I'm trying to fetch data from ORACLE database. The datatype of the column is VARCHAR2(40 BYTE) NOT NULL ENABLE.



From @Thoma advise in comment section I've changed the pics into text.



In SQL DEVELOPPER, I have the following result



SELECT ZONE_DESC FROM IC_RATE_ZONES;
"ZONE_DESC"
VIRGIN ISLANDS UK
VIRGIN ISLANDS US
WALLIS AND FUTUNA IS
YEMEN
ZAMBIA
ZAMBIA MOBILE


And when i've tried to fetch those data in JAVA code :



try{
con = conn.getOracle();
stm = con.createStatement();
Rs = stm.executeQuery("select ZONE_DESC FROM IC_RATE_ZONES");
while(Rs.next()){
System.out.println(Rs.getString("ZONE_DESC"));
}
} catch(Exception e){
e.printStackTrace();
}


I get a blank result in my console output.



thanks for your help.










share|improve this question




















  • 3




    Instead of posting images you might want to post at least your code in properly formatted text form. This makes it easier to preserve (images can get deleted) and work with - and it shows some effort on your part.
    – Thomas
    Nov 21 at 12:25












  • @Thomas, sorry for this. this is a remote host and I cannot copy it because of the restriction. I'll try to write it all and post the text later.
    – kizawa tomaru
    Nov 21 at 12:26












  • What did you expect on the console? You add data to your model but you do not log the actual data to the console. Try System.out.print(Rs.getString(1))
    – Vall0n
    Nov 21 at 12:28








  • 1




    Is there any chance that the code you execute isn't the code you see?
    – Thomas
    Nov 21 at 12:32






  • 1




    Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
    – secret super star
    Nov 21 at 13:31













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I would like to know what's going on when, I'm trying to fetch data from ORACLE database. The datatype of the column is VARCHAR2(40 BYTE) NOT NULL ENABLE.



From @Thoma advise in comment section I've changed the pics into text.



In SQL DEVELOPPER, I have the following result



SELECT ZONE_DESC FROM IC_RATE_ZONES;
"ZONE_DESC"
VIRGIN ISLANDS UK
VIRGIN ISLANDS US
WALLIS AND FUTUNA IS
YEMEN
ZAMBIA
ZAMBIA MOBILE


And when i've tried to fetch those data in JAVA code :



try{
con = conn.getOracle();
stm = con.createStatement();
Rs = stm.executeQuery("select ZONE_DESC FROM IC_RATE_ZONES");
while(Rs.next()){
System.out.println(Rs.getString("ZONE_DESC"));
}
} catch(Exception e){
e.printStackTrace();
}


I get a blank result in my console output.



thanks for your help.










share|improve this question















I would like to know what's going on when, I'm trying to fetch data from ORACLE database. The datatype of the column is VARCHAR2(40 BYTE) NOT NULL ENABLE.



From @Thoma advise in comment section I've changed the pics into text.



In SQL DEVELOPPER, I have the following result



SELECT ZONE_DESC FROM IC_RATE_ZONES;
"ZONE_DESC"
VIRGIN ISLANDS UK
VIRGIN ISLANDS US
WALLIS AND FUTUNA IS
YEMEN
ZAMBIA
ZAMBIA MOBILE


And when i've tried to fetch those data in JAVA code :



try{
con = conn.getOracle();
stm = con.createStatement();
Rs = stm.executeQuery("select ZONE_DESC FROM IC_RATE_ZONES");
while(Rs.next()){
System.out.println(Rs.getString("ZONE_DESC"));
}
} catch(Exception e){
e.printStackTrace();
}


I get a blank result in my console output.



thanks for your help.







java oracle fetch varchar2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 14:42

























asked Nov 21 at 12:23









kizawa tomaru

186




186








  • 3




    Instead of posting images you might want to post at least your code in properly formatted text form. This makes it easier to preserve (images can get deleted) and work with - and it shows some effort on your part.
    – Thomas
    Nov 21 at 12:25












  • @Thomas, sorry for this. this is a remote host and I cannot copy it because of the restriction. I'll try to write it all and post the text later.
    – kizawa tomaru
    Nov 21 at 12:26












  • What did you expect on the console? You add data to your model but you do not log the actual data to the console. Try System.out.print(Rs.getString(1))
    – Vall0n
    Nov 21 at 12:28








  • 1




    Is there any chance that the code you execute isn't the code you see?
    – Thomas
    Nov 21 at 12:32






  • 1




    Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
    – secret super star
    Nov 21 at 13:31














  • 3




    Instead of posting images you might want to post at least your code in properly formatted text form. This makes it easier to preserve (images can get deleted) and work with - and it shows some effort on your part.
    – Thomas
    Nov 21 at 12:25












  • @Thomas, sorry for this. this is a remote host and I cannot copy it because of the restriction. I'll try to write it all and post the text later.
    – kizawa tomaru
    Nov 21 at 12:26












  • What did you expect on the console? You add data to your model but you do not log the actual data to the console. Try System.out.print(Rs.getString(1))
    – Vall0n
    Nov 21 at 12:28








  • 1




    Is there any chance that the code you execute isn't the code you see?
    – Thomas
    Nov 21 at 12:32






  • 1




    Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
    – secret super star
    Nov 21 at 13:31








3




3




Instead of posting images you might want to post at least your code in properly formatted text form. This makes it easier to preserve (images can get deleted) and work with - and it shows some effort on your part.
– Thomas
Nov 21 at 12:25






Instead of posting images you might want to post at least your code in properly formatted text form. This makes it easier to preserve (images can get deleted) and work with - and it shows some effort on your part.
– Thomas
Nov 21 at 12:25














@Thomas, sorry for this. this is a remote host and I cannot copy it because of the restriction. I'll try to write it all and post the text later.
– kizawa tomaru
Nov 21 at 12:26






@Thomas, sorry for this. this is a remote host and I cannot copy it because of the restriction. I'll try to write it all and post the text later.
– kizawa tomaru
Nov 21 at 12:26














What did you expect on the console? You add data to your model but you do not log the actual data to the console. Try System.out.print(Rs.getString(1))
– Vall0n
Nov 21 at 12:28






What did you expect on the console? You add data to your model but you do not log the actual data to the console. Try System.out.print(Rs.getString(1))
– Vall0n
Nov 21 at 12:28






1




1




Is there any chance that the code you execute isn't the code you see?
– Thomas
Nov 21 at 12:32




Is there any chance that the code you execute isn't the code you see?
– Thomas
Nov 21 at 12:32




1




1




Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
– secret super star
Nov 21 at 13:31




Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
– secret super star
Nov 21 at 13:31












1 Answer
1






active

oldest

votes

















up vote
0
down vote













THANKS A LOT FOR EVERYONE THAT take the time to answer it. the solution has been mentionned by @secretsuperstar in the comment section but i've do it wrong the first time.



https://bjurr.com/jdbc-problem-resultset-getstring-returns-nothing/



It have to get the ASCII first and read it. The datatype made it complicated.



here is the final result :



try{
con = conn.getOracle();
stm = con.createStatement();
Rs = stm.executeQuery("select ZONE_DESC FROM IC_RATE_ZONES");

while(Rs.next()){
String str = new String();
InputStreamReader in = new InputStreamReader(Rs.getAsciiStream("ZONE_DESC"));
while(in.ready()){
str = str + (char)in.read();
}
System.out.println(str);
}
} catch(Exception e){
e.printStackTrace();
}


thank you all. HOPE IT HELP SOMEONE ELSE






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411959%2ffetch-oracle-data-varchar2n-byte-return-blank-string-in-java-solved%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    THANKS A LOT FOR EVERYONE THAT take the time to answer it. the solution has been mentionned by @secretsuperstar in the comment section but i've do it wrong the first time.



    https://bjurr.com/jdbc-problem-resultset-getstring-returns-nothing/



    It have to get the ASCII first and read it. The datatype made it complicated.



    here is the final result :



    try{
    con = conn.getOracle();
    stm = con.createStatement();
    Rs = stm.executeQuery("select ZONE_DESC FROM IC_RATE_ZONES");

    while(Rs.next()){
    String str = new String();
    InputStreamReader in = new InputStreamReader(Rs.getAsciiStream("ZONE_DESC"));
    while(in.ready()){
    str = str + (char)in.read();
    }
    System.out.println(str);
    }
    } catch(Exception e){
    e.printStackTrace();
    }


    thank you all. HOPE IT HELP SOMEONE ELSE






    share|improve this answer

























      up vote
      0
      down vote













      THANKS A LOT FOR EVERYONE THAT take the time to answer it. the solution has been mentionned by @secretsuperstar in the comment section but i've do it wrong the first time.



      https://bjurr.com/jdbc-problem-resultset-getstring-returns-nothing/



      It have to get the ASCII first and read it. The datatype made it complicated.



      here is the final result :



      try{
      con = conn.getOracle();
      stm = con.createStatement();
      Rs = stm.executeQuery("select ZONE_DESC FROM IC_RATE_ZONES");

      while(Rs.next()){
      String str = new String();
      InputStreamReader in = new InputStreamReader(Rs.getAsciiStream("ZONE_DESC"));
      while(in.ready()){
      str = str + (char)in.read();
      }
      System.out.println(str);
      }
      } catch(Exception e){
      e.printStackTrace();
      }


      thank you all. HOPE IT HELP SOMEONE ELSE






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        THANKS A LOT FOR EVERYONE THAT take the time to answer it. the solution has been mentionned by @secretsuperstar in the comment section but i've do it wrong the first time.



        https://bjurr.com/jdbc-problem-resultset-getstring-returns-nothing/



        It have to get the ASCII first and read it. The datatype made it complicated.



        here is the final result :



        try{
        con = conn.getOracle();
        stm = con.createStatement();
        Rs = stm.executeQuery("select ZONE_DESC FROM IC_RATE_ZONES");

        while(Rs.next()){
        String str = new String();
        InputStreamReader in = new InputStreamReader(Rs.getAsciiStream("ZONE_DESC"));
        while(in.ready()){
        str = str + (char)in.read();
        }
        System.out.println(str);
        }
        } catch(Exception e){
        e.printStackTrace();
        }


        thank you all. HOPE IT HELP SOMEONE ELSE






        share|improve this answer












        THANKS A LOT FOR EVERYONE THAT take the time to answer it. the solution has been mentionned by @secretsuperstar in the comment section but i've do it wrong the first time.



        https://bjurr.com/jdbc-problem-resultset-getstring-returns-nothing/



        It have to get the ASCII first and read it. The datatype made it complicated.



        here is the final result :



        try{
        con = conn.getOracle();
        stm = con.createStatement();
        Rs = stm.executeQuery("select ZONE_DESC FROM IC_RATE_ZONES");

        while(Rs.next()){
        String str = new String();
        InputStreamReader in = new InputStreamReader(Rs.getAsciiStream("ZONE_DESC"));
        while(in.ready()){
        str = str + (char)in.read();
        }
        System.out.println(str);
        }
        } catch(Exception e){
        e.printStackTrace();
        }


        thank you all. HOPE IT HELP SOMEONE ELSE







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 at 14:14









        kizawa tomaru

        186




        186






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411959%2ffetch-oracle-data-varchar2n-byte-return-blank-string-in-java-solved%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Futebolista

            Lallio

            Jornalista