@@ -60,7 +60,7 @@ more popular options are:
60
60
### Setting up a data source
61
61
62
62
A "database spec" is a Clojure map that specifies how to access the data
63
- source. Most commonly, you specify the database type, the the database name,
63
+ source. Most commonly, you specify the database type, the database name,
64
64
and the username and password. For example,
65
65
66
66
``` clojure
@@ -71,71 +71,8 @@ and the username and password. For example,
71
71
:password " secret" })
72
72
```
73
73
74
- Some DBs require a different format for the "database spec". Here is an example
75
- that was required for an in-memory [ H2 database] ( http://www.h2database.com ) prior
76
- to ` java.jdbc ` release 0.7.6:
77
-
78
- ``` clojure
79
- (def db-spec
80
- {:classname " org.h2.Driver"
81
- :subprotocol " h2:mem" ; the prefix `jdbc:` is added automatically
82
- :subname " demo;DB_CLOSE_DELAY=-1" ; `;DB_CLOSE_DELAY=-1` very important!!!
83
- ; http://www.h2database.com/html/features.html#in_memory_databases
84
- :user " sa" ; default "system admin" user
85
- :password " " ; default password => empty string
86
- })
87
- ```
88
-
89
- Note that file-based H2 databases have been supported directly via the simple
90
- "database spec" for a long time:
91
-
92
- ``` clojure
93
- (def db-spec
94
- {:dbtype " h2"
95
- :dbname " /path/to/my/database" })
96
- ```
97
-
98
- As of ` java.jdbc ` 0.7.6, the in-memory version is supported directly:
99
-
100
- ``` clojure
101
- (def db-spec
102
- {:dbtype " h2:mem"
103
- :dbname " mydb" })
104
- ```
105
-
106
- Out of the box, ` java.jdbc ` understands the following ` :dbtype ` values (with
107
- their default class names):
108
-
109
- * ` "derby" ` - ` org.apache.derby.jdbc.EmbeddedDriver `
110
- * ` "h2" ` - ` org.h2.Driver `
111
- * ` "h2:mem" ` - ` org.h2.Driver `
112
- * ` "hsqldb" ` or ` "hsql" ` - ` org.hsqldb.jdbcDriver `
113
- * ` "jtds:sqlserver" ` or ` "jtds" ` - ` net.sourceforge.jtds.jdbc.Driver `
114
- * ` "mysql" ` - ` com.mysql.jdbc.Driver `
115
- * ` "oracle:oci" ` - ` oracle.jdbc.OracleDriver `
116
- * ` "oracle:thin" ` or ` "oracle" ` - ` oracle.jdbc.OracleDriver `
117
- * ` "postgresql" ` or ` "postgres" ` - ` org.postgresql.Driver `
118
- * ` "pgsql" ` - ` com.impossibl.postgres.jdbc.PGDriver `
119
- * ` "redshift" ` - ` com.amazon.redshift.jdbc.Driver `
120
- * ` "sqlite" ` - ` org.sqlite.JDBC `
121
- * ` "sqlserver" ` - ` "mssql" ` - ` com.microsoft.sqlserver.jdbc.SQLServerDriver `
122
-
123
- You must specify the appropriate JDBC driver dependency in your project -- these
124
- drivers are not included with ` java.jdbc ` .
125
-
126
- You can overide the default class name by specifying ` :classname ` as well as
127
- ` :dbtype ` .
128
-
129
- For databases that require a hostname or IP address, ` java.jdbc ` assumes
130
- ` "127.0.0.1" ` but that can be overidden with the ` :host ` option.
131
-
132
- For databases that require a port, ` java.jdbc ` has the following defaults,
133
- which can be overridden with the ` :port ` option:
134
-
135
- * Microsoft SQL Server - 1433
136
- * MySQL - 3306
137
- * Oracle - 1521
138
- * PostgreSQL - 5432
74
+ See [ ** Database Support** ] [ #database-support ] below for a complete list of
75
+ databases and drivers supported by ` java.jdbc ` out of the box.
139
76
140
77
### A "Hello World" Query
141
78
@@ -249,7 +186,79 @@ Ensure you tear down your tables and indexes in the opposite order of creation:
249
186
250
187
These are all the commands we need to write a simple migration for our database!
251
188
252
- ## More detailed java.jdbc documentation
189
+ ## Database Support
190
+
191
+ Out of the box, ` java.jdbc ` understands the following ` :dbtype ` values (with
192
+ their default class names):
193
+
194
+ * ` "derby" ` - ` org.apache.derby.jdbc.EmbeddedDriver `
195
+ * ` "h2" ` - ` org.h2.Driver `
196
+ * ` "h2:mem" ` - ` org.h2.Driver `
197
+ * ` "hsqldb" ` or ` "hsql" ` - ` org.hsqldb.jdbcDriver `
198
+ * ` "jtds:sqlserver" ` or ` "jtds" ` - ` net.sourceforge.jtds.jdbc.Driver `
199
+ * ` "mysql" ` - ` com.mysql.jdbc.Driver `
200
+ * ` "oracle:oci" ` - ` oracle.jdbc.OracleDriver `
201
+ * ` "oracle:thin" ` or ` "oracle" ` - ` oracle.jdbc.OracleDriver `
202
+ * ` "postgresql" ` or ` "postgres" ` - ` org.postgresql.Driver `
203
+ * ` "pgsql" ` - ` com.impossibl.postgres.jdbc.PGDriver `
204
+ * ` "redshift" ` - ` com.amazon.redshift.jdbc.Driver `
205
+ * ` "sqlite" ` - ` org.sqlite.JDBC `
206
+ * ` "sqlserver" ` - ` "mssql" ` - ` com.microsoft.sqlserver.jdbc.SQLServerDriver `
207
+
208
+ You must specify the appropriate JDBC driver dependency in your project -- these
209
+ drivers are not included with ` java.jdbc ` .
210
+
211
+ You can overide the default class name by specifying ` :classname ` as well as
212
+ ` :dbtype ` .
213
+
214
+ For databases that require a hostname or IP address, ` java.jdbc ` assumes
215
+ ` "127.0.0.1" ` but that can be overidden with the ` :host ` option.
216
+
217
+ For databases that require a port, ` java.jdbc ` has the following defaults,
218
+ which can be overridden with the ` :port ` option:
219
+
220
+ * Microsoft SQL Server - 1433
221
+ * MySQL - 3306
222
+ * Oracle - 1521
223
+ * PostgreSQL - 5432
224
+
225
+ Some databases require a different format for the "database spec". Here is an example
226
+ that was required for an in-memory [ H2 database] ( http://www.h2database.com ) prior
227
+ to ` java.jdbc ` release 0.7.6:
228
+
229
+ ``` clojure
230
+ (def db-spec
231
+ {:classname " org.h2.Driver"
232
+ :subprotocol " h2:mem" ; the prefix `jdbc:` is added automatically
233
+ :subname " demo;DB_CLOSE_DELAY=-1" ; `;DB_CLOSE_DELAY=-1` very important!!!
234
+ ; http://www.h2database.com/html/features.html#in_memory_databases
235
+ :user " sa" ; default "system admin" user
236
+ :password " " ; default password => empty string
237
+ })
238
+ ```
239
+
240
+ This is the most general form of database spec, that allows you to control each
241
+ piece of the JDBC connection URL that would be created.
242
+
243
+ Note: as of ` java.jdbc ` 0.7.6, in-memory H2 databases are supported directly
244
+ via the simple spec form:
245
+
246
+ ``` clojure
247
+ (def db-spec
248
+ {:dbtype " h2:mem"
249
+ :dbname " mydb" })
250
+ ```
251
+
252
+ For file-based databases, such as H2, Derby, SQLite etc, the ` :dbname ` will
253
+ specify the filename:
254
+
255
+ ``` clojure
256
+ (def db-spec
257
+ {:dbtype " h2"
258
+ :dbname " /path/to/my/database" })
259
+ ```
260
+
261
+ ## More detailed ` java.jdbc ` documentation
253
262
254
263
* [ Using SQL:] [ using-sql ] a more detailed guide on using SQL with ` java.jdbc `
255
264
* [ Using DDL:] [ using-ddl ] how to create your tables using the ` java.jdbc ` DDL
0 commit comments