Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 1x 1x 36x 36x 36x 36x 36x 36x 36x 16x 8x 8x 36x 36x 1x 35x 26x 9x 9x 1x 1x 1x 1x 1x | import {db, DriverType,DriverConfig, QueryType } from './IDatabase';
import { BaseConfig } from './IConfig';
export default class DatabaseDriver implements DriverType {
protected config: BaseConfig;
public driver: DriverConfig;
public driverPath: string;
constructor(type: any, config: BaseConfig) {
this.config = config
this.driver = db.getDriver(type)
this.driverPath = db.getJar(type)
}
public get_config = () => {
return {
url: this.get_jdbcUrl(),
drivername: this.driver.className,
...(this.config.username && { user: this.config.username }),
...(this.config.password && { password: this.config.password }),
...(this.config.minpoolsize && { minpoolsize: this.config.minpoolsize }),
...(this.config.maxpoolsize && { maxpoolsize: this.config.maxpoolsize }),
}
}
public get_query = (tableName: string, Itype: string = 'D') => {
if (QueryType.columns == type) {
return this.driver.query.columns(tableName)
} else {
return this.driver.query.describe(tableName)
}
}
protected get_jdbcUrl = () => {
if (this.config.jdbcUrl) {
return this.config.jdbcUrl
}else if(this.config.path){
return `jdbc:${this.driver.connectionType}://${this.config.path}`
} else {
const { host, port, database, } = this.config
return `jdbc:${this.driver.connectionType}://${host}:${port}/${database}`;
}
}
protected set_driver(driver: DriverConfig){
this.driver = driver
}
protected set_driver_path(path: string){
this.driverPath = path
}
}
|