• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.nullpointerexception  RSS feed

 
Jaikiran mathukumalli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a beginner in java programming. I am trying to read response from url and insert it into database. I ran my program which is posted below and it came back with this error:




I have been trying to solve this issue on my own through research, but I could not solve it. I was wondering if anyone can help me. If you do need any other information about my program, please just ask. Thanks in advance!

here is the code i have written

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In future, while posting code, please UseCodeTags
I have added them this time for you. As you can see the tags make the code much more easier to read and understand
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stack trace is telling you what is gone wrong


JavaApplication Line 41 is

So the variable "input" is null.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this point in the code:

the static variable input is null. When passed to the parseResponseString method, the NullPointerException is thrown on the line:

because input is null.

From looking at the whole class, I think you think you are setting the input variable here:

But you are not as you had declared a local variable called input on line 5 of the snippet above. This is used and then discarded once this method completes.
 
Jaikiran mathukumalli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot it helped but now i am getting new errors,sorry but i really am new to java please help

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:536)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at javaapp.JavaApplication1.insertToDatabase(JavaApplication1.java:61)
at javaapp.JavaApplication1.main(JavaApplication1.java:78)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

at oracle.net.ns.NSProtocol.connect(NSProtocol.java:386)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1054)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:308)
... 8 more
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have Oracle installed correctly on the same machine?

If so, go to the command line and type the following:

tnsping xe

What output do you get?
 
Doug Slavens
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!