Skip to content

Commit 61783e2

Browse files
committed
Update MS SQL server connection documentation
1 parent 0965fe1 commit 61783e2

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

content/admin/configuration/database.md

+34-4
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ Example configuration:
230230
# Microsoft SQL Server
231231

232232
For now, MS SQL is only supported in Unix-like OS'es. You need to have
233-
[`unixODBC`](http://www.unixodbc.org/) installed on your machine.
233+
[`unixODBC`](http://www.unixodbc.org/) installed on your machine, and your Erlang/OTP
234+
must be compiled with ODBC support.
234235
Also, in some cases you need to add machine name to `sql_username`, especially
235236
when you have `sql_server` defined as an IP address, e.g.:
236237

@@ -240,10 +241,39 @@ when you have `sql_server` defined as an IP address, e.g.:
240241
...
241242
sql_username: user1@host
242243

243-
By default, ejabberd will use the [`FreeTDS`](https://www.freetds.org/) driver. You need to have the driver file `libtdsodbc.so` installed in your library PATH on your system.
244+
By default, ejabberd will use the [`FreeTDS`](https://www.freetds.org/) driver.
245+
You need to have the driver file `libtdsodbc.so` installed in your library PATH
246+
on your system.
244247

245-
If the FreeTDS driver is not installed in a standard location, or if you want to use another ODBC driver, you can specify the path to the driver using the [sql_odbc_driver](/admin/configuration/toplevel/#sql-odbc-driver) option, available in ejabberd 20.12 or later. For example, if you want to use Microsoft ODBC Driver 17 for SQL Server:
248+
If the FreeTDS driver is not installed in a standard location, or if you want
249+
to use another ODBC driver, you can specify the path to the driver using the
250+
[sql_odbc_driver](/admin/configuration/toplevel/#sql-odbc-driver) option,
251+
available in ejabberd 20.12 or later. For example, if you want to use Microsoft
252+
ODBC Driver 17 for SQL Server:
246253

247254
sql_odbc_driver: "/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1"
248255

249-
Note that if you use a Microsoft driver, you may have to use an IP address instead of a host name for the `sql_server` option.
256+
Note that if you use a Microsoft driver, you may have to use an IP address
257+
instead of a host name for the `sql_server` option.
258+
259+
If hostname (or IP address) is specified in `sql_server` option, ejabberd will
260+
connect using a an ODBC DSN connection string constructed with:
261+
262+
SERVER=[sql_server](/admin/configuration/toplevel/#sql-server)
263+
DATABASE=[sql_database](/admin/configuration/toplevel/#sql-database)
264+
UID=[sql_username](/admin/configuration/toplevel/#sql-username)
265+
PWD=[sql_password](/admin/configuration/toplevel/#sql-password)
266+
PORT=[sql_port](/admin/configuration/toplevel/#sql-port)
267+
ENCRYPTION=required (only if [sql_ssl](/admin/configuration/toplevel/#sql-ssl) is true)
268+
CLIENT_CHARSET=UTF-8
269+
270+
As of ejabberd 23.xx it is possible to use different connection options by
271+
putting a full ODBC connection string in `sql_server` (e.g.
272+
`DSN=database;UID=ejabberd;PWD=password`). The DSN must be configured in
273+
existing system or user odbc.ini file, where it can be configured as desired,
274+
using a driver from system odbcinst.ini. The [sql_odbc_driver](/admin/configuration/toplevel/#sql-odbc-driver)
275+
option will have no effect in this case.
276+
277+
If specifying an ODBC connection string, an ODBC connection string must also be
278+
specified for any other hosts using MS SQL DB, otherwise the auto-generated
279+
ODBC configuration will interfere.

0 commit comments

Comments
 (0)