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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

remove ";" at end of String not working

goodluck247Nov 28 2016 — edited Dec 1 2016

Hello all,

I am new to Java. I have a simple Java program which selects text from an Oracle database table (a Varchar2 column), then prints it to a file.

Here's an extract from the code:

.....

import Java.lang.*;

.....

String recom = null;

String recomf = null;

.....

query = "select recom from recom_logic where labno = " + labno;

rs1 = stmt1.executeQuery(query);

while (rs1.next()){

     recom = rs1.getString("RECOM");

}

if (recom.endsWith(";")){

     recomf = recom.substring(0, recom.length() - 1);

}

.....

the program then goes on to print the data...

the program compiles successfully.

HOWEVER, when running the program, it gives the following error:

Exception in thread "main" java.lang.NullPointerException

I understand it has something to do with my String vars. What am I doing wrong?

Thanks in advance.

This post has been answered by rpc1 on Nov 28 2016
Jump to Answer

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 29 2016
Added on Nov 28 2016
11 comments
450 views