# How to Create a Valid SQL Script

To create a valid SQL script in Appvance AIQ, you must configure the database connection properties correctly. These properties are based on Hibernate and are used to map the database configuration and establish a connection through the appropriate JDBC driver.

The following configuration values are required:

- User Name
- Password
- URL (Connection String)
- Driver Class
- Database Name
- Dialect
- Connection Delimiters

All of these values must be correctly configured in the SQL script when using ASE to establish a database connection.

## Database Connection Properties

### 1. User Name

The **User Name** is the database account used to authenticate and access the required database.

Make sure that:

- The user exists in the database.
- The user has the required permissions to perform the requested operations.
- The database allows connections from the machine where the script is executed.
- For remote databases, remote access is enabled and permitted by the database and network configuration.

### 2. Password

The **Password** is the password associated with the specified database user.

The credentials must match a valid database account. If authentication fails, verify the username, password, and database access permissions.

### 3. URL

The **URL** specifies the JDBC connection string used to connect to the database.

The format of the URL depends on the database engine and JDBC driver being used.

For example, a typical MySQL JDBC connection URL can be structured as follows:

```text
jdbc:mysql://<host>:<port>/<database>
```

Additional connection parameters can be included when required by the database or JDBC driver.

### 4. Driver Class

The **Driver Class** identifies the JDBC driver that Appvance uses to establish the database connection.

Each database engine has its own JDBC driver class.

For example, the current MySQL Connector/J driver class is:

```text
com.mysql.cj.jdbc.Driver
```

> **Note:** Older MySQL documentation may reference `<span class="editor-theme-code">com.mysql.jdbc.Driver</span>`. This class name was deprecated in MySQL Connector/J 8.0 and should not be used for current configurations.

Make sure the appropriate JDBC driver is available to the AIQ environment where the SQL script is executed.

### 5. DB Name

The **DB Name** is the name of the database that the script connects to.

It must correspond to an existing database that is accessible by the configured user.

For example:

```text
my_database
```

The database name is also commonly included as part of the JDBC connection URL.

### 6. Dialect

The **Dialect** specifies the Hibernate dialect used to communicate with the selected database engine.

For Appvance AIQ, the dialect must use the Appvance-specific Hibernate dialect package:

```text
org.appvance.hibernate.dialect
```

The Appvance dialect package is based on Hibernate dialect implementations and was modified to include the `<span class="editor-theme-code">appvance</span>` package name to avoid runtime conflicts.

The appropriate dialect must be selected according to the database engine being used. Refer to the supported dialect table in this documentation for the available values.

### 7. Connection Delimiters

The SQL script must include the commands required to explicitly open and close the database connection.

The connection delimiters are:

```text
Connect
Disconnect
```

**Connect** starts the database connection using the configured connection properties.

**Disconnect** closes the database connection after the SQL operations have completed.

These commands should be used to clearly define the beginning and end of the database interaction.

## Example Configuration

A valid SQL script must contain the required connection information and use the appropriate connection delimiters. The exact syntax and values depend on the database engine and JDBC driver being used.

Before executing the script, verify that:

1. The database user and password are valid.
2. The database is reachable from the AIQ execution environment.
3. The JDBC URL is correctly formatted.
4. The required JDBC driver is available.
5. The database name is correct.
6. The appropriate Appvance Hibernate dialect is configured.
7. The `<span class="editor-theme-code">Connect</span>` and `<span class="editor-theme-code">Disconnect</span>` delimiters are present.
8. The database user has sufficient permissions for the SQL operations performed by the script.

---

**Last updated: August, 17 2026**

If you have any feedback on this topic, please contact us at <documentation@appvance.ai>.