(持续更新整理中)
有时候为了测试 JDBC 需要用到 sql-workbench.
sql-workbench 对于命令行似乎不太友好。整理一下常见的几个命令。
1. 下载 sql-workbench
官网能够下载到压缩包 http://www.sql-workbench.net . 因为是基于 Java 的,所以能用于各个操作系统。
2. 启动 sql-workbench 命令行模式。
~$ sqlworkbench/sqlwbconsole.sh
3. 创建连接。 -url 指定 JDBC URL. -driverJar 指定 JDBC driver Jar 文件,暂时不知道怎么指定多个。 -driver 指定 JDBC 的 class.
SQL> WbConnect -url="jdbc:awsathena://athena.cn-northwest-1.amazonaws.com.cn:443;S3OutputLocation=s3://feichashao-nx;AwsRegion=cn-northwest-1;EndpointOverride=athena.cn-northwest-1.amazonaws.com.cn:443" -driverJar=AthenaJDBC42_2.0.9.jar -driver=com.simba.athena.jdbc.Driver -username=AKIA576C56GLAPMRBIWO -password=secret_key ;
AKIA576C56GLAPMRBIWO@AwsDataCatalog> show tables;
AKIA576C56GLAPMRBIWO@AwsDataCatalog> show tables;
4. 要用多个 JAR, 可以把这些 JAR 都放在 ext/ 目录下,这个目录是 sql-workbench 的 classpath 之一。
5. (未测试成功)如果要指定多个 jar, 可以在 $HOME/.sqlworkbench/WbDrviers.xml 中指定。实例如下(WbDrivers.xml sample).
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.8.0_191" class="java.beans.XMLDecoder">
<object class="java.util.ArrayList">
<void method="add">
<object class="workbench.db.DbDriver">
<void property="driverClass">
<string>com.amazon.hive.jdbc41.HS2Driver</string>
</void>
<void property="libraryList">
<object class="java.util.Collections" method="unmodifiableList">
<object class="java.util.ArrayList">
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbcHiveJDBC41.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbcTCLIServiceClient.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbccommons-codec-1.3.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbccommons-logging-1.1.1.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbchive_metastore.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbchive_service.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbchttpclient-4.1.3.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbchttpcore-4.1.3.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbclibfb303-0.9.0.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbclibthrift-0.9.0.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbclog4j-1.2.14.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbcql.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbcslf4j-api-1.5.11.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbcslf4j-log4j12-1.5.11.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbczookeeper-3.4.6.jar</string>
</void>
</object>
</object>
</void>
<void property="name">
<string>HiveServer2</string>
</void>
<void property="sampleUrl">
<string></string>
</void>
</object>
</void>
</object>
</java>
<java version="1.8.0_191" class="java.beans.XMLDecoder">
<object class="java.util.ArrayList">
<void method="add">
<object class="workbench.db.DbDriver">
<void property="driverClass">
<string>com.amazon.hive.jdbc41.HS2Driver</string>
</void>
<void property="libraryList">
<object class="java.util.Collections" method="unmodifiableList">
<object class="java.util.ArrayList">
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbcHiveJDBC41.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbcTCLIServiceClient.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbccommons-codec-1.3.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbccommons-logging-1.1.1.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbchive_metastore.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbchive_service.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbchttpclient-4.1.3.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbchttpcore-4.1.3.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbclibfb303-0.9.0.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbclibthrift-0.9.0.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbclog4j-1.2.14.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbcql.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbcslf4j-api-1.5.11.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbcslf4j-log4j12-1.5.11.jar</string>
</void>
<void method="add">
<string>/home/ec2-user/sqlwb/hivejdbczookeeper-3.4.6.jar</string>
</void>
</object>
</object>
</void>
<void property="name">
<string>HiveServer2</string>
</void>
<void property="sampleUrl">
<string></string>
</void>
</object>
</void>
</object>
</java>