Git Product home page Git Product logo

java-sql-cli's Introduction

Quick Start

1. 下载最新的jar包

前往release页面中找到最新的jar,当前最新版本为java-sql-cli-1.0.jar

2. 创建配置文件

java-sql-cli-{version}.jar的同一目录下,创建一个名为application.properties的文件

touch application.properties

在此文件中键入相关配置(花括号中的配置项需要改成自己的),下面分别是oracle和mysql的配置文件示例

# oracle
jdbc.driver=oracle.jdbc.OracleDriver
jdbc.url=jdbc:oracle:thin:@{db_ip}:{port}/{scheme}
jdbc.username={username}
jdbc.password={password}
outputfile=output.log
# mysql
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://{db_ip}:{port}/{databases}
jdbc.username={username}
jdbc.password={password}
outputfile=output.log

3. 启动

java -jar java-sql-cli-{version}.jar

4. 执行sql命令

注意此步骤是在启动jar之后的交互界面中进行的

exec "select * from help_keyword limit 10"

默认返回的是一个表格,如下

+---------------------------------------------+
|                   Result                    |
|---------------------------------------------|
|help_keyword_id|            name             |
|---------------------------------------------|
|      670      |            (JSON            |
|      475      |             ->              |
|      658      |             <>              |
|      510      |           ACCOUNT           |
|      642      |           ACTION            |
|      450      |             ADD             |
|      327      |         AES_DECRYPT         |
|      619      |         AES_ENCRYPT         |
|      497      |            AFTER            |
|      398      |           AGAINST           |
|      109      |          AGGREGATE          |
|      456      |          ALGORITHM          |
|      217      |             ALL             |
+---------------------------------------------+

还可以通过—json选项来指定返回值按照json的格式来输出

exec "select * from help_keyword limit 5" --json

返回的是一段json字符串,如下

[
	{
		"name":"(JSON",
		"help_keyword_id":"670"
	},
	{
		"name":"->",
		"help_keyword_id":"475"
	},
	{
		"name":"<>",
		"help_keyword_id":"658"
	},
	{
		"name":"ACCOUNT",
		"help_keyword_id":"510"
	},
	{
		"name":"ACTION",
		"help_keyword_id":"642"
	}
]

5. 查询结果备份

执行过的sql,其结果会自动保存到output.log之中(文件名称可以在application.properties中修改)

java-sql-cli's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.