jdbc Creating a database connection



  • DBMS: Data Base Driver Manager, this can be any DBMS (mysql, oracle, postgresql, sqlite, ...), exemple of mysql: "com.mysql.jdbc.Driver"

  • DB_HOST: your database base host, the IP adress of your database exemple :, the default is localhost or

  • DB_PORT: Database port, every DBMS has a defeaut port exemple mysql=3306, postegesql=5432

  • DB_NAME: the name of your Database

  • To connect you should to obtains a reference to the class object,

  • Class.forName(DRIVER);

  • And to connect to database, you need to create a connection

  • java.sql.Connection con = DriverManager.getConnection(DB_URL, DB_USER_NAME, DB_PASSWORD);

  • DB_USER_NAME : the username of your databse

  • DB_PASSWORD : the password of your database