1

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
kizawa tomaru
  • 103
  • 1
  • 8

1 Answers1

1

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

kizawa tomaru
  • 103
  • 1
  • 8