🔸 TLDR
Java Champion Vlad Mihalcea published a useful reference for the JDBC Driver, JDBC URL and Hibernate Dialect of the most common relational databases.
Source article: https://vladmihalcea.com/jdbc-driver-connection-url-strings
🔸 WHAT IS JDBC?
JDBC: Java Database Connectivity is the standard Java API used to connect to relational databases, execute SQL statements, retrieve results and manage transactions through database-specific JDBC drivers.
🔸 ORACLE
Driver: oracle.jdbc.OracleDriver
URL: jdbc:oracle:thin:@localhost:1521:orclpdb1
Hibernate: org.hibernate.dialect.OracleDialect
▪️ Oracle URLs typically identify the host, port and database/service.
💡NB: orclpdb1 is the Oracle service name: it tells the listener which database/PDB your JDBC connection should reach.
🔸 MYSQL
Driver: com.mysql.jdbc.Driver
URL: jdbc:mysql://localhost/high_performance_java_persistence
Hibernate: org.hibernate.dialect.MySQLDialect
▪️ The database name comes directly after the host.
🔸 POSTGRESQL
Driver: org.postgresql.Driver
URL: jdbc:postgresql://localhost/high_performance_java_persistence
Hibernate: org.hibernate.dialect.PostgreSQLDialect
▪️ PostgreSQL uses one of the most readable JDBC URL formats: protocol → host → database.
🔸 SQL SERVER
Driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
URL: jdbc:sqlserver://localhost; instance=SQLEXPRESS; databaseName=high_performance_java_persistence
▪️ SQL Server adds connection properties such as the instance and database name directly to the URL.
🔸 DATASOURCE
You don't always have to manipulate a raw connection directly.
Vlad also shows vendor-specific DataSource implementations such as:
OracleDataSource
MysqlDataSource
PGSimpleDataSource
▪️ A DataSource centralizes connection configuration and integrates naturally with connection pools and frameworks.
🔸 TAKEAWAYS
▪️ JDBC URLs are database-specific.
▪️ The pattern usually starts with jdbc::.
▪️ Know the Driver + URL + Dialect trio when configuring Hibernate manually.
▪️ Prefer a DataSource in most enterprise applications.
▪️ Bookmark Vlad Mihalcea's article: it is a handy JDBC connection cheat sheet. 🔖
#Java #JDBC #Database #SQL #Hibernate #Oracle #PostgreSQL #MySQL #SQLServer #JavaDeveloper
Go further with Java certification:
Java👇
Spring👇
SpringBook👇
JavaFullstackBook👇