# run_sql_tool **Repository Path**: Scout-Lee/run_sql_tool ## Basic Information - **Project Name**: run_sql_tool - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-16 - **Last Updated**: 2026-04-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # run-sql-tool JDBC-based SQL execution tool supporting Oracle and GaussDB. ## Features - Execute SQL statements directly from command line - Execute SQL files with multiple statements - Support for Oracle 11g/19c and GaussDB databases - **Built-in JDBC drivers** - Oracle and GaussDB drivers packaged in the JAR - YAML-based configuration for multiple database profiles - Query result display with formatted output - Execution statistics summary ## Requirements - JDK 8 or higher - Maven 3.x ## Quick Start ### 1. Build the project ```bash mvn clean package ``` This creates: - `target/run-sql-tool-1.0.0.jar` - Standalone JAR with embedded JDBC drivers ### 2. Configure database connections Edit `config.yaml`: ```yaml databases: oracle19c: type: oracle host: 192.168.1.101 port: 1521 database: ORCLPDB1 username: sys password: your_password # GaussDB using PostgreSQL protocol gaussdb_pg: type: gaussdb protocol: pg host: 192.168.1.200 port: 5432 database: gaussdb username: dbuser password: your_password # GaussDB using native protocol gaussdb_direct: type: gaussdb protocol: direct host: 192.168.1.200 port: 5432 database: gaussdb username: dbuser password: your_password ``` ### 3. Run SQL ```bash java -jar target/run-sql-tool-1.0.0.jar --config config.yaml --profile oracle19c --file script.sql ``` 启动时会自动提取并加载内置的 JDBC 驱动: ``` ============================================================ run-sql-tool - JDBC Driver Loader ============================================================ JAR: run-sql-tool-1.0.0.jar Extracting embedded JDBC drivers... Extracted: gaussdbjdbc.jar Extracted: ojdbc8-19.18.0.0.jar Extracted: orai18n.jar Extracted: postgresql-42.7.4.jar Registered: org.postgresql.Driver Registered: oracle.jdbc.OracleDriver Registered: com.huawei.gaussdb.jdbc.Driver Total JDBC drivers registered: 3 ``` ## Usage ``` java -jar run-sql-tool-1.0.0.jar --config --profile --sql "" java -jar run-sql-tool-1.0.0.jar --config --profile --file java -jar run-sql-tool-1.0.0.jar --help Options: --config Path to configuration YAML file (required) --profile Database profile name from config (required) --sql SQL statement to execute (required if no --file) --file Path to SQL file to execute (required if no --sql) --help Show this help message ``` ## SQL File Format - Statements separated by semicolons (`;`) - Lines starting with `--` are comments - Block comments `/* */` are supported - Empty lines are skipped Example: ```sql -- Create table CREATE TABLE users ( id NUMBER PRIMARY KEY, name VARCHAR2(100) ); -- Insert data INSERT INTO users VALUES (1, 'John Doe'); -- Query data SELECT * FROM users; ``` ## Supported Databases | Database | Protocol | JDBC Driver | JDBC URL | Default Port | |----------|----------|-------------|----------|--------------| | Oracle 11g/19c | Oracle | Oracle JDBC Thin (ojdbc8) | jdbc:oracle:thin:@//host:port/db | 1521 | | GaussDB | PostgreSQL | PostgreSQL JDBC | jdbc:postgresql://host:port/db | 5432 | | GaussDB | Native | Huawei GaussDB JDBC | jdbc:gaussdb://host:port/db | 5432 | **GaussDB 协议说明:** - `protocol: pg` - 使用 PostgreSQL 兼容协议 (jdbc:postgresql://) - `protocol: direct` - 使用 GaussDB 原生协议 (jdbc:gaussdb://) ## Built-in JDBC Drivers The JAR includes these JDBC drivers (packaged from `hc_drs/lib/` during build): - `ojdbc8-19.18.0.0.jar` - Oracle 11g/19c JDBC driver - `gaussdbjdbc.jar` - Huawei GaussDB JDBC driver - `postgresql-42.7.4.jar` - PostgreSQL JDBC driver (GaussDB compatible) - `orai18n.jar` - Oracle Internationalization ## License MIT