#NullPointer

1 messages · Page 1 of 1 (latest)

gray oyster
#

Hi this is error shown when i try to add data to database from textfields, anyone have an idea what is wrong with my code?

sullen snowBOT
#

This post has been reserved for your question.

Hey @gray oyster! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

gray oyster
#

Some parts are comments

surreal jungle
#

Cannot invoke "java.sql.Connection.prepareStatement(String)" because "this.connection" is null

sullen snowBOT
gray oyster
#

@surreal jungle I am newbie with programing and i don't understand how that post can help me

fiery grove
#

Your GetConnection() always returns null

gray oyster
#

What can i do then ?

surreal jungle
#

return connection lol

fiery grove
#

lol

#

And you shouldn’t use your DatabaseConnector class to execute statements etc.

#

It’s a utility class. You create a connection once and use it whenever needed

gray oyster
#

Thanks

Can you explain me how i can use datepicker to get value from that to add to database ?
preparedStatement.setString(2, String.valueOf(dataPicker.getValue()));
is this correct?

fiery grove
#

That reminds me of school when we had to do this

#

Damn, datepickers are a struggle

gray oyster
#

Yeah, i can see that 😅

#

What do you recommend then instead of datepicker?

gray oyster
fiery grove
#

What does DatePicker.getValue() return?

gray oyster
#

I have no idea where to look 😛

surreal jungle
#

d; DatePicker#getValue

fiery grove
#

Hover over it in your IDE

fiery grove
surreal jungle
#

ahh its in maintenance

fiery grove
#

rip

#

Ah, okay

#

It’s a LocalDate

#

@gray oyster if you want to store it ad a date type in your database, you will have to convert it from LocalDate to another type of date afaik

gray oyster
#

This is how it show in ma program after i add to database

#

I choose date by myself

surreal jungle
#

LGTM

fiery grove
#

So it works?

gray oyster
#

Yes it works

fiery grove
#

Alright then