i just finished one game in java using JApplet. is there a way for me to use a database so i can keep track of scores? I am using xampp control apache for my website database to keep track of username etc.... in php.

Can i connect to it using java? or should i use different database.

you can not connect from an applet to any resource hosted on a different host from the applet itself, that's for security reasons.
Best practice is to have the applet talk to a serverside resource (say a servlet or web service) and have that perform the database access.
That way the database username and password are also not downloaded to the client, reducing security risks greatly.