Giter Site home page Giter Site logo

db-build's Introduction

自动构建SQL工具包

前言

使用纯JDBC方式进行构建,不依赖第三方,适用于项目启动时自动构建等工作。

工具贴,后续会上传至Maven。

说明

  • IbatisRunner mybatis提供的类,执行SQL脚本的方法需要调用该类。
  • RuntimeSqlException 异常类。
  • QmDbBuildConfig 工具配置对象
  • QmDbBuildClient 工具客户端
  • Main 示例

使用

github上下载源码

git clone https://github.com/starmcc/db-build.git

复制进项目中,在需要调用的地方创建QmDbBuildConfig对象设置基础配置。

QmDbBuildConfig config = new QmDbBuildConfig();
config.setUrl("jdbc:mysql://localhost:3306/test_db");
config.setUsername("root");
config.setPassword("123");

创建 QmDbBuildClient对象,调用提供的方法构建数据库环境。

QmDbBuildClient build = new QmDbBuildClient(config);
// 构建数据库
build.buildDataBase();
// 执行SQL脚本
build.buildSqlFile(true,"build/test_db.sql");

API

buildDataBase

构建数据库,自动从url连接当中获取数据库名和数据库连接地址,并进行创建操作,当数据库存在时,不执行创建操作。

buildSqlFile

执行SQL脚本。

两个参数

  • transaction 是否开启事务。
  • sqlFilePath SQL脚本路径数组。路径解析为项目中的resource下的路径。

buildSql

执行SQL语句集。

一个参数

  • sql 执行的SQL语句数组,每个下标为一个SQL语句。

Author

name: starmcc - qm

email: [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.