Configuring the Adapter for MariaDB

Topics:

xx

Configuring the adapter consists of specifying connection and authentication information for each of the connections you want to establish.

Declaring Connection Attributes

How to:

Reference:

x

The SET CONNECTION_ATTRIBUTES command allows you to declare a connection to one MariaDB database server and to supply authentication attributes necessary to connect to the server.

You can declare connections to more than one MariaDB database server by issuing multiple SET CONNECTION_ATTRIBUTES commands. The actual connection takes place when the first query referencing that connection is issued (see Overriding the Default Connection). You can include SET CONNECTION_ATTRIBUTES commands in an RPC or a server profile. The profile can be encrypted.

If you issue multiple SET CONNECTION_ATTRIBUTES commands:

  • The first SET CONNECTION_ATTRIBUTES command sets the default MariaDB database server to be used.
  • If more than one SET CONNECTION_ATTRIBUTES command declares the same MariaDB database server, the authentication information is taken from the last SET CONNECTION_ATTRIBUTES command.

Procedure: How to Configure an Adapter

  1. From the Web Console sidebar, click Connect to Data.

    or

    From the Data Management Console, expand the Adapters folder.

    In the DMC, the Adapters folder opens. In the Web Console, the Adapters page opens showing your configured adapters.

  2. In the Web Console, click the New Datasource button on the menu bar and find the adapter on the page or, in the DMC, expand the Available folder if it is not already expanded.
    On the Web Console, you can select a category of adapter from the drop-down list or use the search option (magnifying glass) to search for specific characters.
  3. In the DMC, expand the appropriate group folder and the specific adapter folder. The group folder is described in the connection attributes reference.
  4. Right-click the adapter name and/or version and select Configure.

    The Add Adapter to Configuration pane opens.

  5. Enter values for the parameters required by the adapter, as described in the chapter for the specific adapter you want to configure.
  6. Click Configure. The configured adapter is added to the Adapters list in the DMC resources tree or the Configured list in the Web Console.
    In the Web Console, the adapter remains on the Available Adapters list with an asterisk to indicate that at least one connection has been configured. You can configure additional connections from either the Configured or Available list by right-clicking the adapter and clicking Add Connection.

Reference: Connection Attributes for MariaDB

The MariaDB adapter is under the SQL group folder.

The following list describes the connection attributes for which you can supply values. To complete the attribute declaration, click the Configure button.

Connection name

Logical name used to identify this particular set of connection attributes. The default is CON01.

URL

Enter the location URL for the MariaDB data source. The basic syntax is

jdbc:MariaDB://host:port/database

where:

host:port

Is the computer name or IP address and port on which the MariaDB database is located.

database

Is the name of the database.

These are two examples:

jdbc:MariaDB://localhost/qatst
jdbc:MariaDB://<host>:<port>/qatst

You can reference additional MariaDB connection properties in the URL. If you wish to do so, follow these guidelines: in the URL the first property must be preceded by the ? character, and the second and subsequent properties referenced in the URL must be preceded by the & character followed immediately by an | character, as illustrated in the following example.

Suppose that you wish to add the following connection properties:

sessionVariables=sql_mode=PIPES_AS_CONCAT
 zeroDateTimeBehavior=convertToNull

Enter the URL as follows:

jdbc:MariaDB://host/database?sessionVariables=sql_mode=P
IPES_AS_CONCAT&| 
 zeroDateTimeBehavior=convertToNull

Note: The URL must be entered as a single line, without a space after the | character.

Driver name

Name of the Microsoft JDBC driver: org.mariadb.jdbc.Driver

Security

There are two methods by which a user can be authenticated when connecting to a database server:

  • Explicit. The user ID and password are explicitly specified for each connection and passed to the database, at connection time, for authentication.
  • Password Passthru. The user ID and password received from the client application are passed to the database, at connection time, for authentication.
User

Primary authorization ID by which you are known to the data source.

Password

Password associated with the primary authorization ID.

Select profile

Select a profile from the drop-down menu to indicate the level of profile in which to store the CONNECTION_ATTRIBUTES command. The global profile, edasprof.prf, is the default.

If you wish to create a new profile, either a user profile (user.prf) or a group profile if available on your platform (using the appropriate naming convention), choose New Profile from the drop-down menu and enter a name in the Profile Name field (the extension is added automatically).

Store the connection attributes in the server profile (edasprof).

Syntax: How to Declare Connection Attributes Manually

For explicit authentication:

ENGINE SQLMAR SET CONNECTION_ATTRIBUTES [connection]/userid,password

For password passthru authentication:

ENGINE SQLMAR SET CONNECTION_ATTRIBUTES connection/

where:

SQLMAR

Indicates the adapter. You can omit this value if you previously issued the SET SQLENGINE command.

connection

The name of the connection. You can give any name to the connection that you want.

userid

Is the primary authorization ID by which you are known to MariaDB.

password

Is the password associated with the primary authorization ID.

Example: Declaring Connection Attributes

The following SET CONNECTION_ATTRIBUTES command connects to the MariaDB database server named TEST with an explicit user ID and password:

ENGINE SQLMAR SET CONNECTION_ATTRIBUTES TEST/USERA,PWDA

The following SET CONNECTION_ATTRIBUTES command connects to the MariaDB database server named TEST using password passthru authentication:

ENGINE SQLMAR SET CONNECTION_ATTRIBUTES TEST/

Authenticating a User

x

There are two methods by which a user can be authenticated when connecting to a MariaDB database server:

  • Explicit. User IDs and passwords are explicitly stated in SET CONNECTION_ATTRIBUTES commands. You can include these commands in the server global profile, edasprof.prf, for all users.
  • Database or Password Passthru. User ID and password received from the client application are passed to the MariaDB database server for authentication.

When a client connects to the server, the user ID and password are passed to MariaDB for authentication and are not authenticated by the server. To implement this type of authentication, start the server with security turned off. The server allows the client connection, and then stores an encrypted form of the client connection message to be used for connection to a MariaDB database server at anytime during the lifetime of the server agent.

Overriding the Default Connection

How to:

x

Once all MariaDB connections to be accessed have been declared using the SET CONNECTION_ATTRIBUTES command, there are two ways to select a specific MariaDB connection from the list of declared connections:

  • You can select a default connection using the SET DEFAULT_CONNECTION command. If you do not issue this command, the connection name value specified in the first SET CONNECTION_ATTRIBUTES command is used.
  • You can include the CONNECTION= attribute in the Access File of the table specified in the current SQL query. When you include a connection name in the CREATE SYNONYM command from the Web Console, the CONNECTION= attribute is automatically included in the Access File. This attribute supersedes the default connection.

Syntax: How to Select a Connection to Access

ENGINE SQLMAR SET DEFAULT_CONNECTION [connection]

where:

SQLMAR

Indicates the adapter. You can omit this value if you previously issued the SET SQLENGINE command.

connection

Is the connection name specified in a previously issued SET CONNECTION_ATTRIBUTES command. If omitted, then the local database server will be set as the default. If this connection name has not been previously declared, a FOC1671 message is issued.

Note:

  • If you use the SET DEFAULT_CONNECTION command more than once, the connection name specified in the last command will be the active connection name.
  • The SET DEFAULT_CONNECTION command cannot be issued while an uncommitted transaction (LUW) is pending. In that case, a FOC1671 message is issued.

Example: Selecting a Connection to Access

The following SET DEFAULT_CONNECTION command selects the MariaDB database server named TNSNAMEB as the default MariaDB database server:

ENGINE SQLMAR SET DEFAULT_CONNECTION datasource_name

Note: You must have previously issued a SET CONNECTION_ATTRIBUTES command for the datasource_name.

Controlling Connection Scope

How to:

x

This topic explains how to set the scope of logical units of work using adapters. This is accomplished by the SET AUTODISCONNECT command.

A connection occurs at the first interaction with the declared database server.

Syntax: How to Control the Connection Scope

ENGINE SQLMAR SET AUTODISCONNECT ON {FIN|COMMAND|COMMIT}

where:

SQLMAR

Indicates the adapter. You can omit this value if you previously issued the SET SQLENGINE command.

FIN

Disconnects automatically only after the session has been terminated. FIN is the default value.

COMMAND

Disconnects automatically after each request. Depending on how often the event occurs, the SET AUTODISCONNECT command may result in considerable overhead. Almost all of this overhead is not related to the server. It is related to the operating system and the data source.

COMMIT

Disconnects automatically only after COMMIT or ROLLBACK is issued as a native SQL command.

WebFOCUS

Feedback