Skip to content

Commit 504db3c

Browse files
committed
Misc. copy editing
1 parent ef0d202 commit 504db3c

File tree

14 files changed

+146
-133
lines changed

14 files changed

+146
-133
lines changed

src/docs/asciidoc/appendices/characterencoding/characterencoding.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ These issues were addressed in Firebird 2.0 and at the moment nothing prevents d
4646
A developer must ensure two things to enable use of Unicode characters in the database and the application:
4747

4848
. The database objects must be defined with the `UTF8` character set;
49-
this can be done by either creating database with default `UTF8` character set or by adding `CHARACTER SET UTF8` clause to the column or domain definitions.
49+
this can be done by either creating the database with a default character set of `UTF8`, or by adding the `CHARACTER SET UTF8` clause to column or domain definitions.
5050
. The `encoding` connection property in the JDBC driver has to be set to `UTF8`;
5151
this can be done in several ways: the easiest one is to add the appropriate parameter to the JDBC URL (see the first example), another possibility is to use appropriate method of the `DriverManager` class (see the second example).
5252
Applications that use `DataSource` interface to obtain the database connections also have access to the
@@ -77,10 +77,10 @@ There are a few limitations related to using the `UTF8` character set:
7777

7878
* It is not possible to create Unicode columns longer than 8191 Unicode characters;
7979
this limitation is caused by the fact that the longest possible `VARCHAR` column can occupy 32765 bytes (32767 for `CHAR` columns) and a single `UTF8` character can occupy up to four bytes.
80-
* It is not possible to index Unicode columns longer than 1023 characters -- or 2047 characters in Firebird 4.0 with a page size of 32 kilobytes;
81-
this limitation is caused by the fact that the longest index key cannot be longer than a quarter of the database page, which has a maximum of 16k ([.since]_Firebird 4.0_ 32k) and the before mentioned fact that each `UTF8` character can occupy up to four bytes.
80+
* It is not possible to index Unicode columns longer than 2047 characters -- this requires a page size of 32 kilobytes;
81+
this limitation is caused by the fact that the longest index key cannot be longer than a quarter of the database page, which has a maximum of 32k and the fact that each `UTF8` character can occupy up to four bytes.
8282

83-
It should be mentioned that using Unicode character set might cause noticeable performance degradation when the database is accessed over wide-area networks.
83+
Using the `UTF8` character set might cause noticeable performance degradation when the database is accessed over wide-area networks.
8484
This mainly applies to the cases when non-latin characters are stored in the database, as those characters will require two or more bytes, which in turn might cause additional roundtrips to the server to fetch data.
8585

8686
==== The NONE character set
@@ -91,17 +91,17 @@ When the `NONE` character set is used, Jaybird does not know how to interpret th
9191
The only choice that is left to Jaybird is to construct a string using the default character set of the JVM, which usually matches the regional settings of the operating system and can be accessed from within the JVM through the `file.encoding` system property.
9292

9393
With connection character set `NONE`, Jaybird uses the explicit character set of `CHAR`, `VARCHAR` and `BLOB SUB_TYPE TEXT` columns for the conversion.
94-
This addresses most of the problems described in this paragraph, except for columns without an explicit character set (i.e. their character set is `NONE`).
94+
This addresses most of the problems described in this section, except for columns without an explicit character set (i.e. their character set is `NONE`).
9595

9696
It is clear that a conversion using default character set that happens inside the JVM can lead to errors when the same content is accessed from two or more different Java Virtual Machines that have different configuration.
9797
One application running on the computer with, for example, Russian regional settings saves the Russian text (the default character set of the JVM is Cp1251) and another application running on computer with German regional settings (default character set is Cp1252) will read in such case some special or accented characters.
9898
However, when all client applications run on the same OS with the same regional settings, in most cases this will not have any severe consequences, except probably wrong sorting order or uppercasing on the server side.
9999

100100
On Linux and other Unix platforms, it might have more severe consequences as it is very common that regional settings are not configured and that the default "C" locale is used and the non-ASCII characters will be replaced with question marks ("?").
101101

102-
Therefore, application should use `NONE` character encoding as an encoding for a database and a connection only when at least one of the following is met:
102+
Therefore, an application should only use `NONE` character encoding as an encoding for a database and a connection when at least one of the following is met:
103103

104-
* Database will contain only ASCII characters,
104+
* The database will contain only ASCII characters,
105105
* It is guaranteed that all Java Virtual Machines accessing the database will have the same default encoding that can correctly handle all characters stored in the database,
106106
* All columns have an explicit character set.
107107
When columns have an explicit character set (other than `NONE`) and connection character set `NONE` is used, Firebird will send an identifier of the character set of each column, and Jaybird will use that character set for the conversion.

src/docs/asciidoc/appendices/jdbcescape/jdbcescape.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ Legend: X -- available in this mode.
333333
|The current local time as a time value
334334

335335
|DAYNAME(date)
336-
|Xfootnote:[Always returns English full names (e.g. Sunday)]
336+
|Xfootnote:[Always returns English full names (e.g. "`Sunday`")]
337337
|{nbsp}
338338
|A character string representing the day component of `date`;
339339
the name for the day is specific to the data source
@@ -510,5 +510,6 @@ With explicit length, `CHARACTER SET OCTETS` is appended.
510510
* `(SQL_)LONGVARBINARY`, `(SQL_)BLOB` will be cast to `BLOB SUB_TYPE BINARY`
511511
* `(SQL_)TINYINT` is mapped to `SMALLINT`
512512
* `(SQL_)ROWID` is not supported as length of `DB_KEY` values depend on the context
513-
* `(SQL_)DECIMAL` and `(SQL_)NUMERIC` without precision and scale are passed as is, in current Firebird versions, this means the value will be equivalent to `DECIMAL(9,0)` (which is equivalent to `INTEGER`)
513+
* `(SQL_)DECIMAL` and `(SQL_)NUMERIC` without precision and scale are passed as is.
514+
In current Firebird versions, this means the value will be equivalent to `DECIMAL(9,0)`/`NUMERIC(9,0)`, which is equivalent to `INTEGER`.
514515
* Unsupported/unknown _SQLtype_ values (or invalid length or precision and scale) are passed as is to cast, resulting in an error from the Firebird engine if the resulting cast is invalid

src/docs/asciidoc/appendices/systemproperties/systemproperties.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ The following system properties control other global behaviour of Jaybird.
123123

124124
`org.firebirdsql.jna.syncWrapNativeLibrary`::
125125
Set to true to add a synchronization proxy around the native client library.
126+
+
127+
This can be used to address thread-safety issues with older client libraries (Firebird 2.1 and older, as far as we know).
126128
`org.firebirdsql.datatypeCoderCacheSize`::
127129
Integer value for the number of encoding specific data type coders cached (default and minimum is 1).
128130
Setting to a higher value may improve performance, most common use case is connection character set `NONE` with a database that uses more than one character set for its columns.

src/docs/asciidoc/chapters/connection/connection.adoc

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Jaybird is a regular JDBC driver and supports two primary ways to obtain connect
66
[[connection-drivermanager]]
77
=== Obtaining connection java.sql.DriverManager
88

9-
`java.sql.DriverManager` was the first connection factory in Java. It is based on the concept of the JDBC URL, a string that uniquely identifies the database to connect.
9+
`java.sql.DriverManager` is a database connection factory introduced with JDBC 1.
10+
It is based on the concept of the JDBC URL, a string that uniquely identifies the database to connect.
1011
The driver manager then checks which driver(s) -- if any -- can establish a connection.
1112

1213
There is also support to specify additional connection parameters, like username and password.
@@ -19,14 +20,14 @@ jdbc:firebird://localhost:3050/c:/database/example.fdb
1920

2021
* `jdbc` +
2122
JDBC protocol
22-
* `firebird` or `firebirdsql` +
23+
* `firebird` (also supported: `firebirdsql`) +
2324
JDBC subprotocol, identifies driver to use, in this case Jaybird
2425
* `//localhost:3050/c:/database/example.fdb`
2526
+
2627
This is a database specific part, and identifies the database for the driver to connect, in the case of Jaybird that is `//<host>:<port>/<path to database>`
2728

2829
The first part, `jdbc:firebird:` or `jdbc:firebirdsql:`, is required by JDBC and specifies the so-called protocol and subprotocol for the JDBC connection.
29-
In other words, the type of connection that the application wants to obtain, in this example it is a connection to a Firebird database.
30+
In other words, it specifies the type of connection that the application wants to obtain, in this example, a connection to a Firebird database.
3031

3132
An example of obtaining a connection is shown below.
3233

@@ -40,14 +41,13 @@ import java.sql.*;
4041
public class HelloServer {
4142
4243
public static void main(String[] args) throws Exception {
43-
4444
Class.forName("org.firebirdsql.jdbc.FBDriver"); // <1>
4545
46-
Connection connection = DriverManager.getConnection(
47-
"jdbc:firebird://localhost:3050/c:/db/employee.fdb",
48-
"SYSDBA", "masterkey"); // <2>
49-
50-
// do something here
46+
try (Connection connection = DriverManager.getConnection(
47+
"jdbc:firebird://localhost:3050/c:/db/employee.fdb",
48+
"SYSDBA", "masterkey")) { // <2>
49+
// use connection here
50+
}
5151
}
5252
}
5353
----
@@ -56,7 +56,7 @@ The first line of this code is important -- it tells Java to load the Jaybird JD
5656
As required by the JDBC specification, at this point driver registers itself with `java.sql.DriverManager`.
5757

5858
Since Java 6 (JDBC 4), explicitly loading the driver using `Class.forName("org.firebirdsql.jdbc.FBDriver")` is no longer necessary, except when the driver is not on the system class path.
59-
Examples where it may be necessary to explicitly load the driver are web applications that include the driver in the deployment.
59+
Examples where it may be necessary to explicitly load the driver are web applications that include the driver in the deployment (e.g. in `WEB-INF/lib` of the WAR).
6060
There, the driver is not on the system class path, so it will need to be loaded explicitly.
6161

6262
We will leave out usages of `Class.forName` in further examples, they will work because of automatic driver loading.
@@ -78,8 +78,8 @@ The JDBC specification requires that during class initialization the driver regi
7878
....
7979
Class.forName("org.firebirdsql.jdbc.FBDriver");
8080
....
81-
3. The JDBC driver name is listed in the `jdbc.drivers` system property.
82-
Multiple drivers can be separated using a colon (`:`).
81+
3. The JDBC driver class name is listed in the `jdbc.drivers` system property.
82+
Multiple drivers can be separated using a colon ('```:```').
8383
+
8484
You can specify the value of this property during JVM startup:
8585
+
@@ -129,18 +129,15 @@ import java.util.*;
129129
public class HelloServerWithEncoding {
130130
131131
public static void main(String[] args) throws Exception {
132-
Properties props = new Properties();
133-
132+
var props = new Properties();
134133
props.setProperty("user", "SYSDBA");
135134
props.setProperty("password", "masterkey");
136135
props.setProperty("encoding", "UTF8");
137136
138137
try (Connection connection = DriverManager.getConnection(
139138
"jdbc:firebird://localhost:3050/C:/db/employee.fdb",
140139
props)) {
141-
142-
// do something here
143-
140+
// use connection here
144141
}
145142
}
146143
}
@@ -149,10 +146,10 @@ public class HelloServerWithEncoding {
149146
The `user` and `password` properties are defined in JDBC. All other property names, like `encoding` here, are driver-specific.
150147

151148
Additional properties, for example the SQL role for the connection can be added to the `props` object.
152-
The list of properties available in Jaybird can be found in <<Extended connection properties>>.
149+
The list of properties available in Jaybird can be found in <<connectionproperties>>.
153150

154-
It is not always possible to use the above described method.
155-
Jaybird also provides a possibility to specify extended properties in the JDBC URL.
151+
It is not always possible to use the above described method to add properties.
152+
Jaybird also provides a possibility to specify connection properties in the JDBC URL.
156153

157154
.Extended JDBC URL format
158155
....
@@ -163,10 +160,8 @@ jdbc:firebird://host[:port]/<path to db>?<properties>
163160

164161
The example below shows the specification for extended JDBC properties in the URL.
165162

166-
In this case extended properties are passed together with the URL using the HTTP-like parameter passing scheme: first comes the main part of the URL, then `"?"`, then name-value pairs separated with `&` or `;`.
167-
This example is equivalent to the previous example.
168-
169-
NOTE: Jaybird only supports URL encoding in Jaybird 4 and higher.
163+
In this case extended properties are passed together with the URL using the HTTP-like parameter passing scheme: first comes the main part of the URL, then '```?```', then name-value pairs separated with '```&```' or '```;```'.
164+
The following example is equivalent to the previous example.
170165

171166
[source,java]
172167
.Specifying extended properties in the JDBC URL
@@ -184,20 +179,24 @@ Connection connection = DriverManager.getConnection(
184179
[[connection-drivermanager-props-urlencoding]]
185180
===== URL encoding in query part of JDBC URL
186181

182+
NOTE: Jaybird only supports URL encoding in Jaybird 4 and higher.
183+
187184
UTF-8 URL encoded values (and keys) can be used in the query part of the JDBC URL.
188185

189-
As a result of this change, the following previously unsupported characters can be used in a connection property value when escaped:
186+
This can be used to include otherwise unsupported characters in a connection property value:
190187

191188
* `;` escaped as `%3B`
192189
* `&` escaped as `%26`
190+
* `{plus}` escaped as `%2B`
191+
+
192+
A {plus} in the query part means _space_ (0x20), so occurrences of `{plus}` (_plus_) need to be escaped;
193+
make sure to do this for _base64_ encoded values of `dbCryptConfig`, or better yet use the _base64url_ encoding instead.
194+
* `%` escaped as `%25`.
195+
+
196+
A `%` in the query part introduces an escape, so occurrences of `%` (_percent_) need to be escaped.
197+
* Optionally, a _space_ (0x20) can be escaped as {plus}
193198

194-
In addition, the following characters must also be escaped:
195-
196-
* `{plus}` in the query part now means _space_ (0x20), so occurrences of `{plus}` (_plus_) need to be escaped as `%2B`;
197-
make sure to do this for _base64_ encoded values of `dbCryptConfig` (or use the _base64url_ encoding instead)
198-
* `%` in the query part now introduces an escape, so occurrences of `%` (_percent_) need to be escaped as `%25`
199-
200-
URL encoding can also be used to encode any unicode character in the query string.
199+
URL encoding can also be used to encode any Unicode codepoint in the query string.
201200
Jaybird will always use UTF-8 for decoding.
202201

203202
Invalid URL encoded values will throw a `SQLNonTransientConnectionException`.
@@ -213,6 +212,15 @@ Data sources can be created and configured using code or bean introspection, loo
213212

214213
Jaybird itself provides one `javax.sql.DataSource` implementation, `org.firebirdsql.ds.FBSimpleDataSource`, which is a plain factory of connections, without connection pooling.
215214

215+
[TIP]
216+
====
217+
If you need connection pooling, use a third-party connection pool library like https://brettwooldridge.github.io/HikariCP/[HikariCP^], https://commons.apache.org/proper/commons-dbcp/[DBCP^], or https://www.mchange.com/projects/c3p0/[c3p0^].
218+
Application servers, and for example Tomcat, also provide built-in connection pool support.
219+
Consult their documentation for more information.
220+
221+
See also <<connection-pooling>>.
222+
====
223+
216224
A simple example of creating a data source and obtaining a connection via a `DataSource` object is shown below.
217225

218226
[source,java]
@@ -237,7 +245,7 @@ public class HelloServerDataSource {
237245
ds.setDatabaseName("C:/database/employee.fdb");
238246
239247
try (Connection connection = ds.getConnection()) {
240-
// do something here...
248+
// use connection here
241249
}
242250
}
243251
}
@@ -302,6 +310,8 @@ The `DataSource` implementation supports all connection properties available to
302310
====
303311
Manually binding to JNDI like shown above is uncommon.
304312
If you find yourself copying this code, rethink what you're doing.
313+
314+
In fact, use of JNDI is extremely uncommon these days.
305315
====
306316

307317
[[driver-types]]
@@ -320,6 +330,7 @@ The `PURE_JAVA` type (JDBC Type 4) uses a pure Java implementation of the Firebi
320330
This type is recommended for connecting to a remote database server using TCP/IP sockets.
321331
No installation is required except adding the JDBC driver to the class path.
322332
This type of driver provides the best performance when connecting to a remote server.
333+
Some Jaybird features are only available in the pure Java implementation.
323334

324335
To obtain a connection using the `PURE_JAVA` driver type you have to use a JDBC URL as shown in <<Obtaining connection java.sql.DriverManager>>.
325336

@@ -343,9 +354,7 @@ If _portNumber_ is not specified, it defaults to `3050`.
343354

344355
In theory, even `<database-coordinates>` and _databaseName_ are optional, but this requires specifying the database name using connection property `databaseName`, which is possible, but not recommended.
345356

346-
When using `javax.sql.DataSource` implementation, you can specify either `"PURE_JAVA"` or `"TYPE4"` driver type, however this type is used by default.
347-
348-
Some URL examples
357+
When using `javax.sql.DataSource` implementation, you can specify either `"PURE_JAVA"` or `"TYPE4"` driver type, however this type is already used by default.
349358

350359
.Pure Java URL examples
351360
[listing]
@@ -403,7 +412,7 @@ The following JDBC URL syntax is supported:
403412
----
404413

405414
[.since]_Jaybird 5_ Since Jaybird 5, all URLs supported by fbclient can be used.
406-
The supported URLs depend on the fbclient version and the OS (e.g. XNET and WNET are Windows only, and WNET support will be removed in Firebird 5).
415+
The supported URLs depend on the fbclient version and the OS (e.g. XNET and WNET are Windows only, and WNET support has been removed in Firebird 5).
407416

408417
When connecting to a local database server using the `LOCAL` driver, you should use following:
409418

@@ -545,11 +554,11 @@ The following JDBC URL syntax is supported:
545554
[listing,subs=+quotes]
546555
----
547556
<embedded-url> ::=
548-
jdbc:firebird[sql]:embedded:_dbname-or-alias_
557+
jdbc:firebird[sql]:embedded:__dbname-or-alias__
549558
----
550559

551560
In practice, the URL accepts the same `<fbclient-url>` values as described for `NATIVE`.
552-
That is, the embedded server acts as client library (i.e. you get the same Type 2 behavior as you would get with using "native").
561+
That is, the embedded server also acts as client library (i.e. you get the same Type 2 behavior as you would get with using "native").
553562

554563
This driver tries to load `fbembed.dll/libfbembed.so` (the name used in Firebird 2.5 and earlier) and `fbclient.dll/libfbclient.so`.
555564

@@ -570,7 +579,7 @@ This implies the same restrictions on the classloader that will load the Jaybird
570579

571580
By default, the Firebird embedded library opens databases in exclusive mode.
572581
This means that this particular database is accessible only to one Java virtual machine.
573-
This can be changed by the `ServerMode` setting in `firebird.conf`.
582+
This can be changed with the `ServerMode` setting in `firebird.conf`.
574583

575584
[[driver-ooremote]]
576585
==== OOREMOTE type
@@ -608,7 +617,7 @@ Each time a connection is opened via `DriverManager`, a new physical connection
608617
It is closed when the connection is closed.
609618
To avoid the overhead of creating connections, you can use a connection pool implementation to maintain a cache of open physical connections that can be reused between user sessions.
610619

611-
Since Jaybird 3, Jaybird no longer provides a connection pool.
620+
Since Jaybird 3, Jaybird no longer provides its own connection pool implementation.
612621
If you need a `javax.sql.DataSource` implementation that provides a connection pool, either use the connection pool support of your application server, or consider using https://brettwooldridge.github.io/HikariCP/[HikariCP^], https://commons.apache.org/proper/commons-dbcp/[DBCP^], or https://www.mchange.com/projects/c3p0/[c3p0^].
613622

614623
[[connection-pooling-hikaricp]]

0 commit comments

Comments
 (0)