The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Mysql with a java server

Okay so ill tell you my idea before showing code:
I want to do a recruit a friend where you go to our website, type in your username, the person that recruited you username and you hit submit. When you do that it stores the person that was recruited ip and username into a database and in another it stores the credit for the person that recruited that person. Then you, as the person getting credit, logs in on the server and types a command like ::claimreward and then it goes out to the MYSQL database and checks for their credit then credits them.

I got the website working perfectly, however when I try and do my java code i get a NullPointerException....
Heres my code:

Re: Mysql with a java server

i get a NullPointerException....

There is a variable with a null value on line xxx. Look at line xxx in the your source and see what variable is null. Then backtrack in the code to see why that variable does not have a valid value.
If you can not tell which variable it is, add a println just before line xxx and print out the values of all the variables on that line.

Re: Mysql with a java server

Originally Posted by Norm

There is a variable with a null value on line xxx. Look at line xxx in the your source and see what variable is null. Then backtrack in the code to see why that variable does not have a valid value.
If you can not tell which variable it is, add a println just before line xxx and print out the values of all the variables on that line.

Re: Mysql with a java server

That is the statement that is supposed to put a value in con, but it does not show what is in con when the code executes.
Add a println() statement just before the statement with the NPE that prints the values of all the variables used on the line where the NPE happens. That will be con if you are correct in finding the line with the NPE.