I have used JDBC to connect to many different relational systems over the years: H2, HSQLDB, MySQL, Oracle, Postgres, etc. And in every case, each system seems to have its own flavor of connection string syntax.
I can't imagine that a long-standing API like JDBC wouldn't have a defined, enforced grammar for connection string validation. For example:
Some valid HSQLDB connection strings:
jdbc:hsqldb:mem:mymemdb
jdbc:hsqldb:res:org.my.path.resdb
jdbc:hsqldb:file:/opt/db/testdb
MySQL:
jdbc:mysql://localhost/test
Postgres:
jdbc:postgresql://localhost/test
H2:
jdbc:h2:~/test
jdbc:h2:file:/data/sample
jdbc:h2:tcp://dbserv:8084/~/sample
From all these examples, I gather the basic, generalized syntax:
jdbc:<vendor>:<vendor-specific-uri>
Where <vendor>
is the name of the system (h2
, mysql
, etc.), and <vendor-specific-uri>
is either a path or some vendor-specific way of determining the location of a database.
I've done a lot of digging, and for the life of me, I can't seem to find where JDBC defines valid connection string syntax. Specifically:
- What is the general grammar/definition of a valid JDBC connection string?
- What are the different names of each token/component of the connection string? For instance, is "
jdbc:
" called something, like the "JDBC protocol"? What is the proper name for my<vendor>
and<vendor-specific-uri>
segments?