There are two types of database connection:
External: Used to connect to any database, such as your sales or contacts database.
Local: Connects to the current database your Atlassian application is using.
The Resources page lists all previously configured database connections.
To set up a connection to an external database, you need to know the following information for the database:
The JDBC URL
Any required credential information (username and password)
The driver class
Your database administrator should be able to provide this information if you do not know it.
To set up an external database connection and make the database available to scripts:
Navigate to ScriptRunner > Resources > Add New Item > Database Connection.
Provide a name for the connection in Pool Name.
Enter the JDBC URL of the database to which you wish to connect.
For more information on sample JDBC URLs, see JDBC Driver Connection URL Strings.
Provide the Driver Class Name.
Click Show examples to see a list of common driver classes.
Enter the username required to authenticate the database in User and the corresponding Password.
The User and Password fields are not required if the information is provided in the URL.
Optionally, enter a query into the SQL field to test receiving information from the database. Use Preview to test out different queries.
This SQL query is not saved and is only used to test the connection.
Again, optionally, you can set advanced connection pool properties, such as the maximum pool size. This may be useful in several cases:
If you are using Data Center, by default, the database resource will take 10 connections per node in your cluster.
If this totals too many connections, you can limit the maximum size by entering, for example:
If you would like to limit a database session to ten minutes, enter
maxLifetime=600000(ten minutes in milliseconds).
If you see connections are growing, it could be that a prepared statement was not closed. Enter
leakDetectionThreshold=2000to report any connection that was borrowed from the pool for more than two seconds.
Look for an exception in your logs beginning:
java.lang.Exception: Apparent connection leak detected.
If your database query is expected to take more than two seconds, then this is probably not a leak, and you should raise this value.
If the preview is successful, click Add.
If you need to use another database driver (like an Excel or CSV driver), copy it into the tomcat lib directory of your installation and restart. For example, this could be
You might want to use these to create a custom field that allows users to pick from a row in a spreadsheet.
In the example shown below, we are using a CSV driver. This makes available all CSV in the directory provided in the JDBC URL. So in
/tmp, we have a CSV file called