How to connect to the database for java

step 1. Create the database on the java server.

step 2. Setup a database user and password for the same.

Step3. In your code where you need to connect to the database, use the following code.


DRIVER="com.mysql.jdbc.Driver";

CONNECTION_URL="jdbc:mysql://localhost:3306/DB Name";

USERNAME="DB Username";

PASSWORD="DB Password";


Enter the respective values and it will connect to the database.