I want create certificates to be stored on a database and i dont have any idea about how to do it, if exits an API or library help me do it Thanks
A public key infrastructure is far more than a database of signed public keys. For instance one of the most important parts of the PKI is the ability to revoke certificates using the OCSP protocol.
In short everything needed to build a PKI in java has been built for you and is open source, you should use EJBCA.