...
Info | ||
---|---|---|
| ||
This routine is available since starting with katl-commons 2.6.5 |
Syntax
...
databaseAvailable(dbstring [, sqlstring])
Description
...
Excerpt |
---|
Checks if the database is available. Optionally, it can check also the availability of the results for the SQL passed in as the second parameter. |
Parameters
...
Parameter name | Type | Required | Description |
---|---|---|---|
dbstring | string | yes | The datasource JNDI name or the datasource name. For JIRA database, this is set to "jdbc/JiraDS" by default (if exported) |
sqlstring | string | no | The SQL string |
Return type
...
boolean (true/false)
Example
...
Let's suppose in our examples `TextField` is a custom field text already configured for the current Jira server instance and `TestDB` represents the database resource name configured in the server context. For more details see SQL Data Sources.
Example 1
...
Code Block | ||
---|---|---|
| ||
TextField=databaseAvailable("TestDB"); //will set `TextField` value to `true` |
Example 2
...
Code Block | ||
---|---|---|
| ||
TextField=databaseAvailable("TestDB", "select pname from project"); //will set `TextField` value to `true` if the SQL passed in can be executed |
Example 3
...
Code Block | ||
---|---|---|
| ||
TextField=databaseAvailable("TestDB", "select pname from inexistentTableName");//will set `TextField` value to `false`, because the SQL passed in cannot be executed |
Example 4
...
Code Block | ||
---|---|---|
| ||
TextField=databaseAvailable("InexistentTestDB", "select pname from project");//will set `TextField` value to `false`, because the database resource does not exist |
Notes
...
Note |
---|
To see how you should configure the data source, check the corresponding configuration chapter: SQL Data Sources |
See
...
also
Filter by label (Content by label) showLabels false showSpace false cql label = "sql_support" labels sql_support