|
| 1 | +.. _rm-relational-database-connection-strings: |
| 2 | + |
1 | 3 | ======================================
|
2 | 4 | Relational Database Connection Strings
|
3 | 5 | ======================================
|
| 6 | + |
| 7 | +.. include:: /includes/uri-usage-disclaimer.rst |
| 8 | + |
| 9 | +To analyze a schema or start a migration job, Relational Migrator must connect |
| 10 | +to your relational database. To connect to your source database, |
| 11 | +Relational Migrator requires a JDBC-formatted connection string. This document |
| 12 | +describes the URI formats for defining connections to relational |
| 13 | +database systems. |
| 14 | + |
| 15 | +Relational Migrator can connect to the following relational database systems: |
| 16 | + |
| 17 | +- `MySQL <#mysql>`__ |
| 18 | +- `Oracle <#oracle>`__ |
| 19 | +- `PostgreSQL <#postgresql>`__ |
| 20 | +- `SQL Server <#sql-server>`__ |
| 21 | + |
| 22 | +Relational Migrator's connection form contains fields where you can specify a |
| 23 | +username and password for the connection. The form obscures passwords |
| 24 | +and is more secure than specifying plaintext credentials in the URI. |
| 25 | + |
| 26 | +MySQL |
| 27 | +----- |
| 28 | + |
| 29 | +The general form for a MySQL connection string is: |
| 30 | + |
| 31 | +.. code-block:: |
| 32 | + |
| 33 | + jdbc:mysql://<host:port>/<database>?<properties> |
| 34 | + |
| 35 | +For example, consider the following connection string: |
| 36 | + |
| 37 | +.. code-block:: |
| 38 | + |
| 39 | + jdbc:mysql://host1:3306/test |
| 40 | + |
| 41 | +The preceding connection string specifies these connection |
| 42 | +details: |
| 43 | + |
| 44 | +.. list-table:: |
| 45 | + :header-rows: 1 |
| 46 | + |
| 47 | + * - Property |
| 48 | + - Value |
| 49 | + * - Host |
| 50 | + - ``host1`` |
| 51 | + * - Port |
| 52 | + - ``3306`` |
| 53 | + * - Database |
| 54 | + - ``test`` |
| 55 | + |
| 56 | +.. note:: |
| 57 | + |
| 58 | + To learn more about MySQL connection strings, see: |
| 59 | + |
| 60 | + - `MySQL Connection URL Syntax <https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-jdbc-url-format.html>`__ |
| 61 | + - `Connection Configuration Properties <https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html>`__ |
| 62 | + |
| 63 | +Oracle |
| 64 | +------ |
| 65 | + |
| 66 | +The general form for an Oracle connection string is: |
| 67 | + |
| 68 | +.. code-block:: |
| 69 | + |
| 70 | + jdbc:oracle:thin:@<host:port>:SID |
| 71 | + |
| 72 | +For example, consider the following connection string: |
| 73 | + |
| 74 | +.. code-block:: |
| 75 | + |
| 76 | + jdbc:oracle:thin:@prodHost:1521:ORCL |
| 77 | + |
| 78 | +The preceding connection string specifies these connection |
| 79 | +details: |
| 80 | + |
| 81 | +.. list-table:: |
| 82 | + :header-rows: 1 |
| 83 | + |
| 84 | + * - Property |
| 85 | + - Value |
| 86 | + * - Host |
| 87 | + - ``prodHost`` |
| 88 | + * - Port |
| 89 | + - ``1521`` |
| 90 | + * - SID (System Identifier) |
| 91 | + - ``ORCL`` |
| 92 | + |
| 93 | +.. note:: |
| 94 | + |
| 95 | + To learn more about Oracle connection strings, see: |
| 96 | + |
| 97 | + - `Oracle JDBC Developer's Guide and Reference <https://docs.oracle.com/cd/B28359_01/java.111/b31224/jdbcthin.htm>`__ |
| 98 | + - `Connection String Attributes <https://docs.oracle.com/cd/E85694_01/ODPNT/ConnectionConnectionString.htm#GUID-DF4ED9A3-1AAF-445D-AEEF-016E6CD5A0C0__BABBAGJJ>`__ |
| 99 | + |
| 100 | +PostgreSQL |
| 101 | +---------- |
| 102 | + |
| 103 | +The general form for a PostgreSQL connection string is: |
| 104 | + |
| 105 | +.. code-block:: |
| 106 | + |
| 107 | + jdbc:postgresql://<host:port>/<database>?<properties> |
| 108 | + |
| 109 | +For example, consider the following connection string: |
| 110 | + |
| 111 | +.. code-block:: |
| 112 | + |
| 113 | + jdbc:postgresql://localhost:5432/pg-demo |
| 114 | + |
| 115 | +The preceding connection string specifies these connection details: |
| 116 | + |
| 117 | +.. list-table:: |
| 118 | + :header-rows: 1 |
| 119 | + |
| 120 | + * - Property |
| 121 | + - Value |
| 122 | + * - Host |
| 123 | + - ``localhost`` |
| 124 | + * - Port |
| 125 | + - ``5432`` |
| 126 | + * - Database |
| 127 | + - ``pg-demo`` |
| 128 | + |
| 129 | +.. note:: |
| 130 | + |
| 131 | + To learn more about PostgreSQL connection strings, see: |
| 132 | + |
| 133 | + - `PostgreSQL Connection Configuration Properties <https://jdbc.postgresql.org/documentation/use/>`__ |
| 134 | + |
| 135 | +SQL Server |
| 136 | +---------- |
| 137 | + |
| 138 | +The general form for a SQL Server connection string is: |
| 139 | + |
| 140 | +.. code-block:: |
| 141 | + |
| 142 | + jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]] |
| 143 | + |
| 144 | +For example, consider the following connection string: |
| 145 | + |
| 146 | +.. code-block:: |
| 147 | + |
| 148 | + jdbc:sqlserver://localhost:1433;databaseName=test |
| 149 | + |
| 150 | +The preceding connection string specifies these connection details: |
| 151 | + |
| 152 | +.. list-table:: |
| 153 | + :header-rows: 1 |
| 154 | + |
| 155 | + * - Property |
| 156 | + - Value |
| 157 | + * - Host |
| 158 | + - ``localhost`` |
| 159 | + * - Port |
| 160 | + - ``1433`` |
| 161 | + * - databaseName |
| 162 | + - ``test`` |
| 163 | + |
| 164 | +**Using Windows Integrated Authentication** |
| 165 | + |
| 166 | +To enable Windows Integrated Authentication, add ``integratedSecurity=true;`` to the URI options. |
| 167 | +Leave the :guilabel:`Username` and :guilabel:`Password` fields blank. Windows Integrated Authentication connects |
| 168 | +to the database using the credentials of the user who launched the Relational Migrator executable. |
| 169 | + |
| 170 | +**Using TLS** |
| 171 | + |
| 172 | +JDBC connections to SQL Server use Transport Layer Security (TLS) by default. |
| 173 | +The encrypt property controls TLS. To disable it, set ``encrypt=false;``. |
| 174 | +When TLS is enabled, the driver tries to validate the server's certificate by default. |
| 175 | +To implicitly trust the server certificate, set ``trustServerCertificate=true;``. |
| 176 | + |
| 177 | +.. note:: |
| 178 | + |
| 179 | + To learn more about SQL Server connection strings, see: |
| 180 | + |
| 181 | + - `Setting Connection Properties <https://learn.microsoft.com/en-us/sql/connect/jdbc/setting-the-connection-properties>`__ |
| 182 | + - `SQL Docs: Building the Connection URL <https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15>`__. |
| 183 | + - `Connecting to SQL Server with the JDBC Driver <https://docs.microsoft.com/en-us/sql/connect/jdbc/connecting-to-sql-server-with-the-jdbc-driver?view=sql-server-ver15>`__ |
| 184 | + |
| 185 | +databaseName Property Behavior |
| 186 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 187 | + |
| 188 | +In a SQL Server connection string, use the ``databaseName`` property to |
| 189 | +specify the database to connect to. If you omit the ``databaseName`` |
| 190 | +property, the connection still succeeds but you can only see objects in |
| 191 | +the default ``dbo`` schema in all databases. |
| 192 | + |
| 193 | +If you specify the ``databaseName`` property, you can see tables from |
| 194 | +all schemas within the specified database. |
0 commit comments