MySQL:
Here is an example on how to connect to a MySQL database server:
mysql://localhost:3306/test?user=root&password=swordfish
In this case the username, root and password, swordfish are specified as properties to the URL. An alternative is to use the auth-part of the URL to specify authentication information:
mysql://root:swordfish@localhost:3306/test
See mysql options for all properties that can be set for a mysql connection URL.
SQLite:
For a SQLite database the connection URL should simply specify a database file, since a SQLite database is just a file in the filesystem. SQLite uses pragma commands for performance tuning and other special purpose database commands. Pragma syntax on the form, name=value can be added as properties to the URL and will be set when the Connection is created. In addition to pragmas, the following properties are supported:
- heap_limit=value [KB] - Make SQLite auto-release unused memory if memory usage goes above the specified value.
An URL for connecting to a SQLite database might look like:
sqlite:///var/sqlite/test.db?synchronous=normal&heap_limit=8000&foreign_keys=on
PostgreSQL:
The URL for connecting to a PostgreSQL database server might look like:
postgresql://localhost:5432/test?user=root&password=swordfish
As with the MySQL URL, the username and password are specified as properties to the URL. Likewise, the auth-part of the URL can be used instead to specify the username and the password:
postgresql://root:swordfish@localhost/test?use-ssl=true
In this example we have also omitted the port number to the server, in which case the default port number, 5432, for PostgreSQL is used. In addition we have added an extra parameter to the URL, so connection to the server is done over a secure SSL connection.
See postgresql options for all properties that can be set for a postgresql connection URL.
Oracle:
The URL for connecting to an Oracle database server might look like:
oracle://localhost:1521/test?user=scott&password=tiger
The auth-part of the URL can be used instead to specify the username and the password. In addition, you may specify a service name in the URL instead if you have setup a tnsnames.ora configuration file.
oracle:///servicename?user=scott&password=tiger
转自http://www.tildeslash.com/libzdb/#api