Fetch oracle data VARCHAR2(N BYTE) return blank string in JAVA
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.
java oracle fetch varchar2
|
show 16 more comments
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.
java oracle fetch varchar2
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 '18 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 '18 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. TrySystem.out.print(Rs.getString(1))
– Vall0n
Nov 21 '18 at 12:28
1
Is there any chance that the code you execute isn't the code you see?
– Thomas
Nov 21 '18 at 12:32
1
Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
– secret super star
Nov 21 '18 at 13:31
|
show 16 more comments
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.
java oracle fetch varchar2
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.
java oracle fetch varchar2
java oracle fetch varchar2
edited 2 days ago
Cœur
17.4k9103145
17.4k9103145
asked Nov 21 '18 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 '18 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 '18 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. TrySystem.out.print(Rs.getString(1))
– Vall0n
Nov 21 '18 at 12:28
1
Is there any chance that the code you execute isn't the code you see?
– Thomas
Nov 21 '18 at 12:32
1
Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
– secret super star
Nov 21 '18 at 13:31
|
show 16 more comments
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 '18 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 '18 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. TrySystem.out.print(Rs.getString(1))
– Vall0n
Nov 21 '18 at 12:28
1
Is there any chance that the code you execute isn't the code you see?
– Thomas
Nov 21 '18 at 12:32
1
Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
– secret super star
Nov 21 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 12:28
1
1
Is there any chance that the code you execute isn't the code you see?
– Thomas
Nov 21 '18 at 12:32
Is there any chance that the code you execute isn't the code you see?
– Thomas
Nov 21 '18 at 12:32
1
1
Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
– secret super star
Nov 21 '18 at 13:31
Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
– secret super star
Nov 21 '18 at 13:31
|
show 16 more comments
1 Answer
1
active
oldest
votes
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
add a comment |
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',
autoActivateHeartbeat: false,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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%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
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
add a comment |
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
add a comment |
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
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
answered Nov 21 '18 at 14:14
kizawa tomaru
186
186
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 '18 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 '18 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 '18 at 12:28
1
Is there any chance that the code you execute isn't the code you see?
– Thomas
Nov 21 '18 at 12:32
1
Well, not sure if it helps..bjurr.com/jdbc-problem-resultset-getstring-returns-nothing
– secret super star
Nov 21 '18 at 13:31