boxlang-database-accesslisted
Install: claude install-skill ortus-boxlang/skills
# BoxLang Database Access
## Overview
BoxLang provides first-class database access via JDBC. Datasources are configured
in `boxlang.json` or `Application.bx`. Queries use `queryExecute()` (script) or
`bx:query` (tag syntax) with built-in parameterization to prevent SQL injection.
## Datasource Configuration
### In `boxlang.json`
```json
{
"datasources": {
"mainDB": {
"driver": "mysql",
"host": "${DB_HOST:localhost}",
"port": "${DB_PORT:3306}",
"database": "${DB_NAME:myapp}",
"username": "${DB_USER}",
"password": "${DB_PASS}",
"options": {
"maximumPoolSize": 10,
"minimumIdle": 2,
"connectionTimeout": 30000
}
},
"readReplica": {
"driver": "mysql",
"host": "replica.example.com",
"port": 3306,
"database": "myapp",
"username": "${DB_READ_USER}",
"password": "${DB_READ_PASS}"
}
}
}
```
### In `Application.bx`
```boxlang
class {
// Default datasource
this.datasource = "mainDB"
// Define datasources in application scope
this.datasources = {
mainDB: {
driver : "mysql",
host : server.system.environment.DB_HOST ?: "localhost",
port : 3306,
database : "myapp",
username : server.system.environment.DB_USER,
password : server.s