diff --git a/README_cn.md b/README_cn.md
index a5db3ace61901b3c982816a4eccc636400d438d0..b2a60213a138aa33f8b2bee6cd87c84ebf30fddf 100644
--- a/README_cn.md
+++ b/README_cn.md
@@ -67,7 +67,6 @@ openGauss JDBC 驱动的生成支持以下操作系统:
| maven | 3.6.1 |
| java | 1.8 |
| Git Bash (Windows) | 无推荐版本 |
-| zip/unzip (Windows) | 无推荐版本 |
### 下载openGauss-connector-jdbc源码
@@ -82,89 +81,42 @@ git clone https://gitee.com/opengauss/openGauss-connector-jdbc.git
- /sda/openGauss-connector-jdbc
-### 编译第三方软件(可跳过)
-
-在构建openGauss-connector-jdbc之前,需要先编译openGauss依赖的开源及第三方软件。我们已经在openGauss-connector-jdbc目录下的open_source就提供了编译好的开源及第三方软件,直接使用我们提供的open_source可以跳过该部分。这些开源及第三方软件存储在openGauss-third_party代码仓库中,通常只需要构建一次。如果开源软件有更新,需要重新构建软件。
-
-用户也可以直接从**binarylibs**库中获取开源软件编译和构建的输出文件。
-
-如果你想自己编译第三方软件,请到openGauss-third_party仓库查看详情。
-
-执行完上述脚本后,最终编译和构建的结果保存在与**openGauss-third_party**同级的**binarylibs**目录下。在编译**openGauss-connector-jdbc**时会用到这些文件。
-
### jar包生成
-#### 使用一键式脚本生成jar包(Linux)
+#### 使用一键式脚本生成jar包(Linux/windows)
openGauss-connector-jdbc中的build.sh是编译过程中的重要脚本工具。该工具可快速进行代码编译和打包。
-参数说明请见以下表格。
-
-| 选项 | 缺省值 | 参数 | 说明 |
-| :--- | :--------------------------- | :---------------- | :----------------------------------------------------------- |
-| -3rd | ${Code directory}/binarylibs | [binarylibs path] | 指定binarylibs路径。建议将该路径指定为open_source/或者/sda/openGauss-connector-jdbc/open_source/。如果您有自己编译好openGauss依赖的的第三方库,也可以指定为编译好的三方库路径,如/sda/binarylibs。 |
-
-> **注意**
->
-> - **-3rd [binarylibs path]**为**binarylibs**的路径。默认设置为当前代码文件夹下存在**binarylibs**,因此如果**binarylibs**被移至**openGauss-server**中,或者在**openGauss-server**中创建了到**binarylibs**的软链接,则不需要指定此参数。但请注意,这样做的话,该文件很容易被**git clean**命令删除。
-
-现在你已经知晓build.sh的用法,只需使用如下格式的命令即可编译openGauss-connector-jdbc。
+只需使用如下格式的命令即可编译openGauss-connector-jdbc。
1. 执行如下命令进入到代码目录:
```
- [user@linux sda]$ cd /sda/openGauss-connector-jdbc
+ [user@linux sda]$ cd /sda/openGauss-connector-jdbc/
```
2. 执行如下命令使用build.sh进行打包:
```
- [user@linux openGauss-connector-jdbc]$ sh build.sh -3rd open_source/
+ [user@linux openGauss-connector-jdbc]$ sh build.sh
```
结束后会显示如下内容,表示打包成功:
```
Successfully make postgresql.jar
- opengauss-jdbc-${version}.jar
- postgresql.jar
- Successfully make jdbc jar package
+ Successfully make opengauss-jdbc-${version} jar package
+ packaging jdbc...
+ Successfully make jdbc jar package in openGauss-${version}-${platform}-${bit}-Jdbc.tar.gz
+ clean up temporary directory!
now, all packages has finished!
```
成功编译后会出现两个jar包,分别是opengauss-jdbc-${version}.jar与postgresql.jar。编译后的jar包路径为:**/sda/openGauss-connector-jdbc/output**。
-#### 使用一键式脚本生成jar包(Windows)
-
-1. 准备 Java 与 Maven环境, 以及可以在**Git Bash**中使用的 **zip/unzip** 命令。
-
-2. 执行如下命令进入到代码目录:
-
- ```
- [user@linux openGauss-connector-jdbc]$ cd /sda/openGauss-connector-jdbc
- ```
-
-3. 运行脚本build_on_windows_git.sh:
-
- ```
- [user@linux openGauss-connector-jdbc]$ sh build_on_windows_git.sh
- ```
-
- 脚本执行成功后,会显示如下结果:
-
- ```
- begin run
- Successfully make postgresql.jar package in /sda/openGauss-connector-jdbc/output/postgresql.jar
- Successfully make opengauss-jdbc jar package in /sda/openGauss-connector-jdbc/output/opengauss-jdbc-${version}.jar
- Successfully make jdbc jar package in /sda/openGauss-connector-jdbc/openGauss-${version}-JDBC.tar.gz
- ```
-
- 成功编译后会出现两个jar包,分别是opengauss-jdbc-${version}.jar与postgresql.jar。编译后的jar包路径为:**/sda/openGauss-connector-jdbc/output/**。此外还会出现这两个jar包的压缩包openGauss-${version}-JDBC.tar.gz,压缩包路径为 **/sda/openGauss-connector-jdbc/**。
-
-
#### 使用mvn命令生成jar包(Windows 或 Linux)
-1. 准备 Java 与 Maven环境, 若在Windows环境下还需准备可以在**Git Bash**中使用的 **zip/unzip** 命令。
+1. 准备 Java 与 Maven环境。
2. 执行如下命令进入到代码目录:
@@ -172,26 +124,10 @@ openGauss-connector-jdbc中的build.sh是编译过程中的重要脚本工具。
[user@linux sda]$ cd /sda/openGauss-connector-jdbc
```
-3. 使用demo准备脚本:
+3. 执行mvn命令:
```
- [user@linux openGauss-connector-jdbc]$ sh prepare_demo.sh
- ```
-
-4. 修改根目录下的pom.xml:
-
- 将modules部分的module由jdbc改为pgjdbc, 如下所示。
-
- ```
-
- pgjdbc
-
- ```
-
-5. 执行mvn命令:
-
- ```
- [user@linux openGauss-connector-jdbc]$ mvn clean install -Dmaven.test.skip=true
+ [user@linux openGauss-connector-jdbc]$ mvn clean install -Dgpg.skip -Dmaven.test.skip=true
```
Linux系统下构建成功后会显示如下结果:
@@ -211,7 +147,7 @@ openGauss-connector-jdbc中的build.sh是编译过程中的重要脚本工具。
```
构建成功后会出现两个jar包,分别是opengauss-jdbc-${version}.jar与original-opengauss-jdbc-${version}.jar。jar包路径为/sda/openGauss-connector-jdbc/pgjdbc/target/。
-
+ **注意:默认的mvn编译出的jdbc包名为org.postgresql,它与maven中央仓库的包名org.opengauss不同,想打包此包名,请参考build.sh脚本**
## JDBC的使用
diff --git a/README_en.md b/README_en.md
new file mode 100644
index 0000000000000000000000000000000000000000..382ba451253eb10557bb4b964d44d1e19db96872
--- /dev/null
+++ b/README_en.md
@@ -0,0 +1,200 @@
+
+
+
+
+## What is openGauss-connector-jdbc
+
+openGauss is an open source relational database management system. It has multi-core high-performance, full link security, intelligent operation and maintenance for enterprise features. openGauss, which is early originated from PostgreSQL, integrates Huawei's core experience in database field for many years. It optimizes the architecture, transaction, storage engine, optimizer and ARM architecture. At the meantime, openGauss as a global database open source community, aims to further advance the development and enrichment of the database software/hardware application ecosystem.
+
+**Java Database Connectivity** (**JDBC**) is an application programming interface (API) for the programming language Java, which defines how a client may access a database. It is a Java-based data access technology used for Java database connectivity. It provides methods to query and update data in a database, and is oriented toward relational databases. openGauss-connector-jdbc is to provide users with access to the database through the Java language application interface . Users can use the jar package provided by the openGauss official website (refer to the [Direct Access section](#1)) or build their own jar package ([refer to the Building from Source section](#BuildfromSource) to operate the database using JDBC.
+
+
+
+
+## Direct access {#1}
+
+Before using the openGauss JDBC driver, make sure your server is up and running with the openGauss database (refer to the openGauss [Quickstart](https://opengauss.org/en/docs/latest/docs/Quickstart/Quickstart.html))。
+
+### Get from maven central repository
+
+Java developers can get jar packages directly from the maven central repository with the following coordinates:
+
+```
+org.opengauss
+opengauss-jdbc
+```
+
+### Get from the community website
+
+1. Download the installation package from the official website.
+
+ Click on [link](https://opengauss.org/en/download.html) and under the openGauss Connectors section, select the download button for JDBC_${version} according to the corresponding system of the server where you are deploying the database. ${version} is the version number you need.
+
+2. Decompress the zip file.
+
+ ```
+ tar -zxvf openGauss-${version}-JDBC.tar.gz
+ ```
+
+3. After unpacking, you can see two jar packages in the same directory, opengauss-jdbc-${version}.jar and postgresql.jar. opengauss-jdbc-${version}.jar is a package that can coexist with PG-JDBC, the package name is changed from 2.0.1 to org.postgresql.jar. postgresql to org.opengauss, and the driver name is replaced from jdbc:postgresql:// to jdbc:opengauss://. This is the same package that is currently available from the maven central repository.
+
+### INSTALLING THE DRIVER
+
+To install the driver, the postgresql.jar file has to be in the classpath.
+
+ie: under LINUX/SOLARIS (the example here is my linux box):
+
+ export CLASSPATH=.:/usr/local/pgsql/share/java/postgresql.jar
+
+or
+
+```
+export CLASSPATH=.:/usr/local/pgsql/share/java/opengauss-jdbc-${version}.jar
+```
+
+
+
+## Build from Source {#BuildfromSource}
+
+### Overview
+
+The openGauss JDBC driver currently offers 3 ways to build. One is to build via the one-click script build.sh. The second is a step-by-step build via script. The third is to build via the mvn command.
+
+This will compile the correct driver for your JVM, and build a .jar file (Java ARchive) called postgresql.jar and opengauss-jdbc--${version}.jar in output/, and you can get openGauss-${version}-jdbc.tar.gz too.
+
+Notice: postgresql.jar is conflict use with postgres database. Because all class was in package org.postgresql. opengauss-jdbc-${version}.jar is compatibility with postgres database, all java package renamed `org.opengauss`, and jdbc driver is: `jdbc:opengauss:/`
+
+Remember: Once you have compiled the driver, it will work on ALL platforms that support that version of the API. You don't need to build it for each platform.
+
+### OS and Software Dependency Requirements
+
+ The openGauss JDBC driver is generated to support the following operating systems:
+
+- CentOS 7.6(x86 architecture)
+- openEuler-20.03-LTS(aarch64 architecture)
+- Windows
+
+The following table lists the software requirements for compiling the openGauss-connector-jdbc.
+
+You are advised to use the default installation packages of the following dependent software in the listed OS installation CD-ROMs or sources. If the following software does not exist, refer to the recommended versions of the software.
+
+Software dependency requirements are as follows:
+
+| Software and Environment Requirements | Recommended Version |
+| ------------------------------------- | ------------------- |
+| maven | 3.6.1 |
+| java | 1.8 |
+| Git Bash (Windows) | - |
+
+### Downloading openGauss-connector-jdbc
+
+You can download openGauss-connector-jdbc from open source community.
+
+```
+git clone https://gitee.com/opengauss/openGauss-connector-jdbc.git
+```
+
+Now we have completed openGauss-connector-jdbc code. For example, we store it in following directories.
+
+- /sda/openGauss-connector-jdbc
+
+### Compiling
+
+#### Getting jar packages with one-click scripting (Linux/Windows)
+
+The build.sh in the openGauss-connector-jdbc directory is an important scripting tool for the compilation process. This tool allows for quick code compilation and packaging.
+
+so you can compile the openGauss-connector-jdbc by one command with build.sh. In build.sh, maven and java8 will be installed automatically and use to build target.
+
+1. Execute the following command to get to the code directory:
+
+ ```
+ [user@linux sda]$ cd /sda/openGauss-connector-jdbc
+ ```
+
+2. Execute the following command to package using build.sh:
+
+ ```
+ [user@linux openGauss-connector-jdbc]$ sh build.sh
+ ```
+
+ When finished, the following will be displayed to indicate successful packaging:
+
+ ```
+ Successfully make postgresql.jar
+ Successfully make opengauss-jdbc-${version} jar package
+ packaging jdbc...
+ Successfully make jdbc jar package in openGauss-${version}-${platform}-${bit}-Jdbc.tar.gz
+ clean up temporary directory!
+ now, all packages has finished!!
+ ```
+
+ After successful compilation, two jar packages will appear, opengauss-jdbc-${version}.jar and postgresql.jar. compiled jar package path is:**/sda/openGauss-connector-jdbc/output**.
+
+#### Getting jar packages using the mvn command (Windows or Linux)
+
+1. Prepare the Java and Maven environments.
+
+2. Execute the following command to get to the code directory:
+
+ ```
+ [user@linux sda]$ cd /sda/openGauss-connector-jdbc
+ ```
+
+3. Execute the mvn command:
+
+ ```
+ [user@linux openGauss-connector-jdbc]$ mvn clean install -Dgpg.skip -Dmaven.test.skip=true
+ ```
+
+ A successful build on a Linux system will display the following result:
+
+ ```
+ [INFO] Reactor Summary:
+ [INFO]
+ [INFO] openGauss JDBC Driver ............................. SUCCESS [5.344s]
+ [INFO] PostgreSQL JDBC Driver aggregate .................. SUCCESS [0.004s]
+ [INFO] ------------------------------------------------------------------------
+ [INFO] BUILD SUCCESS
+ [INFO] ------------------------------------------------------------------------
+ [INFO] Total time: 5.439s
+ [INFO] Finished at: Tue Aug 31 21:55:01 EDT 2021
+ [INFO] Final Memory: 44M/1763M
+ [INFO] ------------------------------------------------------------------------
+ ```
+
+ Two jar packages will appear after a successful build, opengauss-jdbc-${version}.jar and original-opengauss-jdbc-${version}.jar. jar package path is /sda/openGauss-connector-jdbc/pgjdbc /target/.
+ **notice: this build artifact's package name is org.postgresql which different with maven central repository. if you want build package with org.opengauss, please refer to build.sh.**
+
+
+## Using JDBC
+
+Reference [JDBC-based development](https://opengauss.org/en/docs/latest/docs/Developerguide/development-based-on-jdbc.html).
+
+## Docs
+
+For more details about the installation guide, tutorials, and APIs, please see the [User Documentation](https://gitee.com/opengauss/docs).
+
+## Community
+
+### Governance
+
+Check out how openGauss implements open governance [works](https://gitee.com/opengauss/community/blob/master/governance.md).
+
+### Communication
+
+- WeLink- Communication platform for developers.
+- IRC channel at `#opengauss-meeting` (only for meeting minutes logging purpose)
+- Mailing-list: https://opengauss.org/en/community/onlineCommunication.html
+
+## Contribution
+
+Welcome contributions. See our [Contributor](https://opengauss.org/en/contribution.html) for more details.
+
+## Release Notes
+
+For the release notes, see our [RELEASE](https://opengauss.org/en/docs/2.0.0/docs/Releasenotes/Releasenotes.html).
+
+## License
+
+[MulanPSL-2.0](http://license.coscl.org.cn/MulanPSL2/)
\ No newline at end of file
diff --git a/build.sh b/build.sh
old mode 100755
new mode 100644
index 885b252a13e9a84fba986d9607bb41121d742bef..a9bebb5ebbf7880b2634853b1d81c4a7f1c98c60
--- a/build.sh
+++ b/build.sh
@@ -16,15 +16,12 @@
# ----------------------------------------------------------------------------
# Description : shell script for jdbc package.
#############################################################################
+set -e
BUILD_FAILED=1
-java_path=""
-ant_path=""
JDBC_DIR=$(dirname $(readlink -f $0))
LOG_FILE=$JDBC_DIR/logfile
-THIRD_DIR=$JDBC_DIR/buildtools
-libs=$JDBC_DIR/libs
-NOTICE_FILE='Copyright Notice.doc'
+ARCH=$(uname -m)
#detect platform information.
PLATFORM=32
bit=$(getconf LONG_BIT)
@@ -43,6 +40,9 @@ elif [ -f "/etc/openEuler-release" ]; then
elif [ -f "/etc/centos-release" ]; then
kernel=$(cat /etc/centos-release | awk -F ' ' '{print $1}' | tr A-Z a-z)
version=$(cat /etc/centos-release | awk -F '(' '{print $2}'| awk -F ')' '{print $1}' | tr A-Z a-z)
+elif [ -f "/etc/kylin-release" ]; then
+ kernel=$(cat /etc/kylin-release | awk -F ' ' '{print $1}' | tr A-Z a-z)
+ version=$(cat /etc/kylin-release | awk '{print $6}' | tr A-Z a-z)
else
kernel=$(lsb_release -d | awk -F ' ' '{print $2}'| tr A-Z a-z)
version=$(lsb_release -r | awk -F ' ' '{print $2}')
@@ -50,37 +50,27 @@ fi
if [ X"$kernel" == X"euleros" ]; then
dist_version="EULER"
-elif [ X"$kernel" == X"centos" ]; then
+elif [ X"$kernel" == X"centos" ]; then
dist_version="CENTOS"
-elif [ X"$kernel" == X"openeuler" ]; then
+elif [ X"$kernel" == X"openeuler" ]; then
dist_version="OPENEULER"
+elif [ X"$kernel" == X"kylin" ]; then
+ dist_version="KYLIN"
+elif [ X"$kernel" = X"suse" ]; then
+ dist_version="SUSE"
else
- echo "Only support EulerOS, OPENEULER(aarch64) and CentOS platform."
- echo "Kernel is $kernel"
- exit 1
+ echo "WARN:Only EulerOS, OPENEULER(aarch64), SUSE, and CentOS platform support, there will set to UNKNOWN"
+ dist_version="UNKNOWN"
fi
-export PLAT_FORM_STR=$(sh "${JDBC_DIR}/get_PlatForm_str.sh")
declare install_package_format='tar'
-declare mppdb_version='GaussDB Kernel'
-declare mppdb_name_for_package="$(echo ${mppdb_version} | sed 's/ /-/g')"
-declare version_number='V500R001C20'
+declare mppdb_name_for_package="openGauss"
+pom_version_number=`awk '/[^<]+<\/version>/{gsub(/|<\/version>/,"",$1);print $1;exit;}' ${JDBC_DIR}/pgjdbc/pom.xml`
+declare version_number="${pom_version_number}"
declare version_string="${mppdb_name_for_package}-${version_number}"
declare package_pre_name="${version_string}-${dist_version}-${PLATFORM}bit"
declare jdbc_package_name="${package_pre_name}-Jdbc.${install_package_format}.gz"
-coretype=$(uname -p)
-mvn_name="apache-maven-3.6.3-bin.tar.gz"
-jdk_name="OpenJDK8U-jdk_x64_linux_hotspot_8u222b10.tar.gz"
-
-if [ X"$coretype" == X"aarch64" ]; then
- jdk_name="OpenJDK8U-jdk_aarch64_linux_hotspot_8u222b10.tar.gz"
-fi
-
-tar -zxvf buildtools/$jdk_name -C buildtools/ > /dev/null
-mkdir -p buildtools/maven
-tar -zxvf buildtools/$mvn_name -C buildtools/maven/ > /dev/null
-
die()
{
echo "ERROR: $@"
@@ -89,11 +79,7 @@ die()
function prepare_java_env()
{
- echo "Prepare the build enviroment."
- export JAVA_HOME=$THIRD_DIR/jdk8u222-b10
- export JRE_HOME=$JAVA_HOME/jre
- export LD_LIBRARY_PATH=$JRE_HOME/lib/amd64/server:$LD_LIBRARY_PATH
- export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
+ echo "We no longer provide java, please makesure java(1.8*) already in PATH!"
JAVA_VERSION=`java -version 2>&1 | awk -F '"' '/version/ {print $2}'`
echo java version is $JAVA_VERSION
}
@@ -106,11 +92,11 @@ function prepare_env()
function prepare_maven_env()
{
- export MAVEN_HOME=$THIRD_DIR/maven/apache-maven-3.6.3/
- export PATH=$MAVEN_HOME/bin:$PATH
+ echo "We no longer provide mvn, please makesure mvn(3.6.0+) already in PATH!"
MAVEN_VERSION=`mvn -v 2>&1 | awk '/Apache Maven / {print $3}'`
echo maven version is $MAVEN_VERSION
}
+
function install_jdbc()
{
export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
@@ -122,24 +108,11 @@ function install_jdbc()
echo "Begin make jdbc..."
export CLASSPATH=".:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar"
echo ${JDBC_DIR}
- cd "${JDBC_DIR}/shade"
- mvn clean install -Dmaven.test.skip=true >> "$LOG_FILE" 2>&1
- cd "${JDBC_DIR}/shade/target"
- jar -xf demo-0.0.1-SNAPSHOT.jar
- rm -rf "${JDBC_DIR}/shade/temp/"
- mkdir -p "${JDBC_DIR}/shade/temp/"
- cp -r ./com "${JDBC_DIR}/shade/temp/"
- cd "${JDBC_DIR}/shade/temp"
- find ./com -name "*" | sort |xargs zip demo-0.0.1-SNAPSHOT.jar >> "$LOG_FILE" 2>&1
- mvn install:install-file -Dfile=${JDBC_DIR}/shade/temp/demo-0.0.1-SNAPSHOT.jar -DgroupId=com.huawei -DartifactId=demo-0.0.1-SNAPSHOT -Dversion=0.0.1 -Dpackaging=jar
- if [ $? -ne 0 ]; then
- die "mvn install demo failed."
- fi
rm -rf "${JDBC_DIR}/jdbc"
cp "${JDBC_DIR}/pgjdbc" "${JDBC_DIR}/jdbc" -r
cd "${JDBC_DIR}/jdbc"
find . -name 'Driver.java' | xargs sed -i "s/@GSVERSION@/${GS_VERSION}/g"
- mvn clean install -Dmaven.test.skip=true >> "$LOG_FILE" 2>&1
+ mvn clean install -Dgpg.skip -Dmaven.test.skip=true >> "$LOG_FILE" 2>&1
if [ $? -ne 0 ]; then
die "mvn install driver failed."
fi
@@ -148,15 +121,15 @@ function install_jdbc()
mkdir ${OUTPUT_DIR}
fi
cd ${OUTPUT_DIR}
- rm -rf *.jar
+ rm -rf *.jar *.gz
version=`awk '/[^<]+<\/version>/{gsub(/|<\/version>/,"",$1);print $1;exit;}' ${JDBC_DIR}/jdbc/pom.xml`
mv ${JDBC_DIR}/jdbc/target/opengauss-jdbc-${version}.jar ./postgresql.jar
echo "Successfully make postgresql.jar"
- rm -rf "${JDBC_DIR}/jdbc"
- cp "${JDBC_DIR}/pgjdbc" "${JDBC_DIR}/jdbc" -r
+# rm -rf "${JDBC_DIR}/jdbc"
+# cp "${JDBC_DIR}/pgjdbc" "${JDBC_DIR}/jdbc" -r
cd "${JDBC_DIR}/jdbc"
- find . -name 'Driver.java' | xargs sed -i "s/@GSVERSION@/${GS_VERSION}/g"
+# find . -name 'Driver.java' | xargs sed -i "s/@GSVERSION@/${GS_VERSION}/g"
find . -name 'Driver.java' | xargs sed -i "s/jdbc:postgresql:/jdbc:opengauss:/g"
find . -name 'java.sql.Driver' | xargs sed -i "s#org\.postgresql#${OPENGAUSS_PACKAGE_NAME}#g"
find . -name '*.java' -type f | xargs sed -i "s#org\.postgresql#${OPENGAUSS_PACKAGE_NAME}#g"
@@ -168,23 +141,13 @@ function install_jdbc()
die "fail to replace url name in BaseDataSource"
fi
- mvn clean install -Dmaven.test.skip=true >> "$LOG_FILE" 2>&1
+ mvn clean install -Dgpg.skip -Dmaven.test.skip=true -U >> "$LOG_FILE" 2>&1
cp ${JDBC_DIR}/jdbc/target/opengauss-jdbc-${version}.jar ${OUTPUT_DIR}/
- echo "Successfully make opengauss-jdbc jar package"
-
- cd ${OUTPUT_DIR}/
- tar -zcvf ${JDBC_DIR}/openGauss-${version}-JDBC.tar.gz *.jar
- echo "Successfully make jdbc jar package"
+ echo "Successfully make opengauss-jdbc-${version} jar package"
}
function clean()
{
- if [ -d "${JDBC_DIR}/shade/temp" ]; then
- rm -rf "${JDBC_DIR}/shade/temp"
- fi
- if [ -d "${JDBC_DIR}/shade/target" ]; then
- rm -rf "${JDBC_DIR}/shade/target"
- fi
if [ -d "${JDBC_DIR}/jdbc" ]; then
rm -rf "${JDBC_DIR}/jdbc"
fi
@@ -192,6 +155,7 @@ function clean()
rm -rf "${LOG_FILE}"
fi
}
+
function select_package_command()
{
@@ -212,56 +176,26 @@ function select_package_command()
function make_package()
{
cd ${JDBC_DIR}/output
- cp ${JDBC_DIR}/"${NOTICE_FILE}" ./
-
select_package_command
echo "packaging jdbc..."
- $package_command "${jdbc_package_name}" ./gsjdbc4.jar "${NOTICE_FILE}" >> "$LOG_FILE" 2>&1
+ $package_command "${jdbc_package_name}" *.jar >> "$LOG_FILE" 2>&1
if [ $? -ne 0 ]; then
- die "$package_command ${jdbc_package_name} failed"
+ die "$package_command ${jdbc_package_name} failed"
fi
cp "${jdbc_package_name}" ../
- echo "$pkgname tools is ${jdbc_package_name} of ${JDBC_DIR} directory " >> "$LOG_FILE" 2>&1
- echo "success!"
-}
-function registerJars()
-{
- for src in `find $third_part_lib -name '*.jar'`
- do
- cp $src $libs/
- done
- echo "copy finished"
- cd $libs
- prepare_env
- mvn install:install-file -Dfile=./commons-logging-1.2.jar -DgroupId=commons-logging -DartifactId=commons-logging -Dversion=1.2 -Dpackaging=jar
- mvn install:install-file -Dfile=./commons-codec-1.11.jar -DgroupId=commons-codec -DartifactId=commons-codec -Dversion=1.11 -Dpackaging=jar
- mvn install:install-file -Dfile=./httpclient-4.5.13.jar -DgroupId=org.apache.httpcomponents -DartifactId=httpclient -Dversion=4.5.13 -Dpackaging=jar
- mvn install:install-file -Dfile=./httpcore-4.4.13.jar -DgroupId=org.apache.httpcomponents -DartifactId=httpcore -Dversion=4.4.13 -Dpackaging=jar
- mvn install:install-file -Dfile=./fastjson-1.2.70.jar -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.2.70 -Dpackaging=jar
- mvn install:install-file -Dfile=./joda-time-2.10.6.jar -DgroupId=joda-time -DartifactId=joda-time -Dversion=2.10.6 -Dpackaging=jar
- mvn install:install-file -Dfile=./jackson-databind-2.11.2.jar -DgroupId=com.fasterxml.jackson.core -DartifactId=jackson-databind -Dversion=2.11.2 -Dpackaging=jar
- mvn install:install-file -Dfile=./jackson-core-2.11.2.jar -DgroupId=com.fasterxml.jackson.core -DartifactId=jackson-core -Dversion=2.11.2 -Dpackaging=jar
- mvn install:install-file -Dfile=./jackson-annotations-2.11.2.jar -DgroupId=com.fasterxml.jackson.core -DartifactId=jackson-annotations -Dversion=2.11.2 -Dpackaging=jar
- mvn install:install-file -Dfile=./slf4j-api-1.7.30.jar -DgroupId=org.slf4j -DartifactId=slf4j-api -Dversion=1.7.30 -Dpackaging=jar
- mvn install:install-file -Dfile=./java-sdk-core-3.0.12.jar -DgroupId=com.huawei.apigateway -DartifactId=hw-java-sdk-core -Dversion=3.0.12 -Dpackaging=jar
+ echo "$package_command tools is ${jdbc_package_name} of ${JDBC_DIR} directory " >> "$LOG_FILE" 2>&1
+ echo "Successfully make jdbc jar package in ${jdbc_package_name}"
}
+
prepare_env
-export third_part_lib=""
-if [ ! -d "${libs}" ]; then
-mkdir ${libs}
-fi
-case $1 in
- -3rd | --3rd)
- if [ ! -n "$2" ]; then
- die "3rd should not be empty"
- fi
- third_part_lib="$2"
- registerJars
- ;;
- *);;
-esac
install_jdbc
-clean
+make_package
+if [ "$1" = "-n" ] ;then
+ echo "the temporary directory has not been cleaned up, please clean up by yourself!"
+else
+ echo "clean up temporary directory!"
+ clean
+fi
echo "now, all packages has finished!"
exit 0
diff --git a/build_on_windows_git.sh b/build_on_windows_git.sh
deleted file mode 100644
index 6b68a5c170a96a7cc429dd29c912bee2caf145cb..0000000000000000000000000000000000000000
--- a/build_on_windows_git.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#/bin/bash
-# this script is to use in windows git bash shell to build opengauss jdbc jar.
-# you need build tools in window's PATH below:
-# java mvn zip tar xargs
-# after success build, the tar package in openGauss-2.0.0-JDBC.tar.gz
-# or you can int output dir find postgresql.jar and opengauss-jdbc*.jar
-# please notice: postgresql.jar is conflict with postgres database jdbc.
-# if you want to compatibiliry use opengauss and pg database, use opengauss-jdbc*.jar instead.
-# the driver string is jdbc:opengauss://, the driver class is:org.opengauss.Driver
-JDBC_DIR=$(dirname $(readlink -f $0))
-cd $JDBC_DIR
-sh prepare_maven.sh
-cd $JDBC_DIR
-sh prepare_demo.sh
-cd $JDBC_DIR
-sh prepare_windows_build.sh
diff --git a/buildtools/OpenJDK8U-jdk_aarch64_linux_hotspot_8u222b10.tar.gz b/buildtools/OpenJDK8U-jdk_aarch64_linux_hotspot_8u222b10.tar.gz
deleted file mode 100644
index 12a1cb40110c1155b4765a7f7ab7ffd65af2d02a..0000000000000000000000000000000000000000
Binary files a/buildtools/OpenJDK8U-jdk_aarch64_linux_hotspot_8u222b10.tar.gz and /dev/null differ
diff --git a/buildtools/OpenJDK8U-jdk_x64_linux_hotspot_8u222b10.tar.gz b/buildtools/OpenJDK8U-jdk_x64_linux_hotspot_8u222b10.tar.gz
deleted file mode 100644
index 403dae8a46d141ffeda6752d23e0f2ea5c503ae7..0000000000000000000000000000000000000000
Binary files a/buildtools/OpenJDK8U-jdk_x64_linux_hotspot_8u222b10.tar.gz and /dev/null differ
diff --git a/buildtools/README b/buildtools/README
deleted file mode 100644
index f7cdc741263d0cc9c805827d06398dac93d64b3b..0000000000000000000000000000000000000000
--- a/buildtools/README
+++ /dev/null
@@ -1,6 +0,0 @@
-Download the MAVEN from https://mirror.bit.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
-The version shoud be 3.6.3.
-Download the java x86-64 from https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u222-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u222b10.tar.gz
-The version should be 1.8.
-Download the java aarch64 from https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u222-b10/OpenJDK8U-jdk_aarch64_linux_hotspot_8u222b10.tar.gz
-The version should be 1.8.
diff --git a/buildtools/apache-maven-3.6.3-bin.tar.gz b/buildtools/apache-maven-3.6.3-bin.tar.gz
deleted file mode 100644
index 66fdd6d4c4e6fbe7e917c9c9992bcdce0f80f21e..0000000000000000000000000000000000000000
Binary files a/buildtools/apache-maven-3.6.3-bin.tar.gz and /dev/null differ
diff --git a/certdir/README.md b/certdir/README.md
deleted file mode 100644
index ff041e3c490e6308fcb34e2c11f17cf3589d85cf..0000000000000000000000000000000000000000
--- a/certdir/README.md
+++ /dev/null
@@ -1,44 +0,0 @@
-To run the SSL tests, the following properties are used:
-
-* certdir: directory where the certificates and keys are store
-* enable_ssl_tests: enables SSL tests
-
-In order to configure PostgreSQL for SSL tests, the following changes should be applied:
-
-* Copy server/server.crt, server/server.key, and server/root.crt to $PGDATA directory
-* In $PGDATA directory: chmod 0600 server.crt server.key root.crt
-* Set ssl=on in postgresql.conf
-* Set ssl_cert_file=server.crt in postgresql.conf
-* Set ssl_key_file=server.key in postgresql.conf
-* Set ssl_ca_file=root.crt in postgresql.conf
-* Add databases for SSL tests. Note: sslinfo extension is used in tests to tell if connection is using SSL or not
-
- for db in hostssldb hostnossldb certdb hostsslcertdb; do
- createdb $db
- psql $db -c "create extension sslinfo"
- done
-* Add test databases to pg_hba.conf. If you do not overwrite the pg_hba.conf then remember to comment out all lines
- starting with "host all".
-* Uncomment enable_ssl_tests=true in ssltests.properties
-* The username for connecting to postgres as specified in build.local.properties tests has to be "test".
-
-This directory contains example certificates generated by the following
-commands:
-
-openssl req -x509 -newkey rsa:1024 -days 3650 -keyout goodclient.key -out goodclient.crt
-#Common name is test, password is sslpwd
-
-openssl req -x509 -newkey rsa:1024 -days 3650 -keyout badclient.key -out badclient.crt
-#Common name is test, password is sslpwd
-
-openssl req -x509 -newkey rsa:1024 -days 3650 -nodes -keyout badroot.key -out badroot.crt
-#Common name is localhost
-rm badroot.key
-
-openssl pkcs8 -topk8 -in goodclient.key -out goodclient.pk8 -outform DER -v1 PBE-MD5-DES
-openssl pkcs8 -topk8 -in badclient.key -out badclient.pk8 -outform DER -v1 PBE-MD5-DES
-cp goodclient.crt server/root.crt
-cd server
-openssl req -x509 -newkey rsa:1024 -nodes -days 3650 -keyout server.key -out server.crt
-cp server.crt ../goodroot.crt
-#Common name is localhost, no password
diff --git a/certdir/badclient.crt b/certdir/badclient.crt
deleted file mode 100644
index 4f37a71e51668ffa52a8b7298ea9160c14894268..0000000000000000000000000000000000000000
--- a/certdir/badclient.crt
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIC3jCCAkegAwIBAgIJAIHg5fMq+z8aMA0GCSqGSIb3DQEBBQUAMFQxCzAJBgNV
-BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
-aWRnaXRzIFB0eSBMdGQxDTALBgNVBAMTBHRlc3QwHhcNMTExMTEwMjE0MjI3WhcN
-MjExMTA3MjE0MjI3WjBUMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0
-ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQ0wCwYDVQQDEwR0
-ZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDbMINU6XwQ/0OSQ4xYRp0o
-gYzzsaaGgZjBZEpRMCZkB+TPUD/yxDpyfcknsvsBQPQ0bqLLS9yqf5iS26jHGd4U
-/nInOy5rjIKEbJMUgkbNWiuVl5q1K+GFuTEpjpdLI9NH5X+jL1CxH/h8+j8Mr2iX
-s4C2gIFu6povShJiIwBNBQIDAQABo4G3MIG0MB0GA1UdDgQWBBQ6L/fB+7uwDN9q
-T5Do9X4GIbJnxDCBhAYDVR0jBH0we4AUOi/3wfu7sAzfak+Q6PV+BiGyZ8ShWKRW
-MFQxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJ
-bnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDTALBgNVBAMTBHRlc3SCCQCB4OXzKvs/
-GjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAKq2Q+aE5eC04gW58pAt
-pobnL/2L0JHCeLPsv0k/1vjulzjBuphbwaibZtiYWZSDKWL8Dvsg+khq7rEIY0W6
-xXGw5y2scRlCukQvseIxbHUoyOCAWJnoqr7d8MyxP2GlpqSDXHk9wEywZ/6f89oN
-yudtXjoYuW8157tmvrX3D1yd
------END CERTIFICATE-----
diff --git a/certdir/badclient.key b/certdir/badclient.key
deleted file mode 100644
index efc9b6c0132c5148aadb108858abdb6e3ac8d72f..0000000000000000000000000000000000000000
--- a/certdir/badclient.key
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: DES-EDE3-CBC,95718EE22B89E019
-
-78LEg7uq4krPR3C1sQVCiQsPIXroyoDzPHBFmI+ipEJq7obFACK9KROfUAaMlca8
-ZR1UhtQHCPK4TOG1qKjn8lxeKGLZA25Lcilw6QvZCfNyBa6JUp3cdwzUSv7/qE/Y
-d/wlVAq71JbOmYsbEwunZlq+DO1AaL91N/2ANgSSC85uR0dye0iZ1C0OZzawMXkd
-wXRrXb8c8RCH2gQ6V4aMartTZ/DQznA59+NEUYln5IMP4joRM0TTpcuv6oCq1UUw
-o7xEQcwfBB0tKayxkBfgp8Jvrghzw0usSFt4ad9I4DF/V2izojZgYsnT7yGqsop6
-7jmPR9llYhDQIZd0V4NZziiRF2Dt/lyG0iUPZq5vlhLaI59FzMAxVSAJP6DrUHQD
-L76TeGpQm2LRqWliDc+3AMTCKv0TP1IPbIWJrnLxnNf/C29adO+VSeQEQ0+tBU+/
-DE2GVsQ/xul+QyCwXiOce0pfERLuGjSu/kRa1ylAlrdH4+6vBD0ewuXXHv0eTSxB
-Vi0vde5a9PzPUMUBkg6PS7IDYJmKm04fFPxx3y8GMlzbZYOYjTepkYMbayekybGK
-fHVk9Z3lW5yzegaz8iJu/8le6Kn4Ox21FRG45domu1T+8eJuXPoiBUb290SUVuxh
-VTQWhCA8ElmVCYfrbSnYL3naeqVL+Oc6by3VVhvgiqUuXQTZvKN7mkUOhiNbpz2H
-iGLwlRj6wXEaS0qLb9NQc9H9Vv6ftj7UPa4FkiJjWhUW0WkA5sqtOKMjLzpsIZtR
-dFb26NE65tk0lrywQrzMBFM6fk90VrMYyvwukZIJIKRLCBQaG24PLQ==
------END RSA PRIVATE KEY-----
diff --git a/certdir/badclient.pk8 b/certdir/badclient.pk8
deleted file mode 100644
index cebb2d78fa02762050a5d1555d8c54b6f15b64f2..0000000000000000000000000000000000000000
Binary files a/certdir/badclient.pk8 and /dev/null differ
diff --git a/certdir/badroot.crt b/certdir/badroot.crt
deleted file mode 100644
index 88ffbcf766f52dee3ea6e2aaf4d8dcc102268641..0000000000000000000000000000000000000000
--- a/certdir/badroot.crt
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIC7zCCAligAwIBAgIJANwlio9cWdoXMA0GCSqGSIb3DQEBBQUAMFkxCzAJBgNV
-BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
-aWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMTExMTAyMTQy
-NTdaFw0yMTExMDcyMTQyNTdaMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21l
-LVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNV
-BAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA055WKnuQ
-i6RPdI3LEtx8ztXV7BuiYihPXCRYUahLyF4TAzNGfmqsdQhqUlqzr1P+nlqxh8sm
-hZGS4NtGPaEjrbPgsBsTVg0XBKpH5yf2RIhBtvAaDG+cCFBjM+LJGzc4we59JkB6
-n1a/22iSFsCAm+BFBwHk6FqF7u2gGSUOrI0CAwEAAaOBvjCBuzAdBgNVHQ4EFgQU
-rw3IpiBN56GCi44/goVmHlZdmJswgYsGA1UdIwSBgzCBgIAUrw3IpiBN56GCi44/
-goVmHlZdmJuhXaRbMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRl
-MSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxv
-Y2FsaG9zdIIJANwlio9cWdoXMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD
-gYEAa08IbYDJsgc45mYG/mviionvhBGs9BS2YapZDIREc/vd0W4FIzHXh5oTJAdF
-fkPjvHoczPuzGX8EKMBjANPs7h4Cd5xKSSE2Su+QwmZOxVg6eIeQwVZsY7SZFmkC
-Y2XwdxWvk3VzLdjgj/McmSBp4/aJUGRP6f5ehnR4B1ykVss=
------END CERTIFICATE-----
diff --git a/certdir/goodclient.crt b/certdir/goodclient.crt
deleted file mode 100644
index a45ae6c1c75d16700941c5749cb6fec7f5f24b45..0000000000000000000000000000000000000000
--- a/certdir/goodclient.crt
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIC3jCCAkegAwIBAgIJAM9GGWA8iSiIMA0GCSqGSIb3DQEBBQUAMFQxCzAJBgNV
-BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
-aWRnaXRzIFB0eSBMdGQxDTALBgNVBAMTBHRlc3QwHhcNMTExMTEwMjE0MTQ3WhcN
-MjExMTA3MjE0MTQ3WjBUMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0
-ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQ0wCwYDVQQDEwR0
-ZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCns68NbjKQAnHCpmN6amR1
-GdtliqiXDaCjoeBPpVXNQ/ZhqinP9gnDyRPXC5kPqw5/6GqNHcYJqg+IIS8G85Rq
-t3Cs5ZL+JlEDAwd0CkD0Ey5h0oJNfN1bDhV2e/yqc831ElBGK6VItGqKopSUV2y/
-pNijOOdeMZ8GuktT+9mbAQIDAQABo4G3MIG0MB0GA1UdDgQWBBTE93pAIzHiFRFw
-IU38WhnwXm03GzCBhAYDVR0jBH0we4AUxPd6QCMx4hURcCFN/FoZ8F5tNxuhWKRW
-MFQxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJ
-bnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDTALBgNVBAMTBHRlc3SCCQDPRhlgPIko
-iDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAKUsXLsp3i9Tsj1wp46R
-4IkIjwWT1bN3+JOjmA9aqwEVcxTRSStAa5kfTQwc4QSAgHK1oFPsA8gsv3sftYmZ
-MtvYrvba8cOPonuaCrvtJQMvKgv3d10S6esUGlW+5o3PVPUq5yQ7OaN5JHCDTZGS
-phuxlq7//rNjvypX2hbKUj6z
------END CERTIFICATE-----
diff --git a/certdir/goodclient.key b/certdir/goodclient.key
deleted file mode 100644
index 37d2ac5ae090521af5e95d765b8bb8d170500a82..0000000000000000000000000000000000000000
--- a/certdir/goodclient.key
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: DES-EDE3-CBC,D2A0607D6E4CE1FD
-
-/RMZp/vNTiHiAqVGyByL9Zms7sFWECqpDof6X1jzex7JWi7cjTzKDZiVyqmDfUU3
-A2v8dbMFQfak4tfpeWqx+HPkVX/GNTFhTI/Ic48+d/9iETwu4d0uMHyrX97GDzWt
-72NbBdby16s+Lwp7Gu5WQ2fUwJVagHAD4nrHBP5yjOStf6l8CWSiCUTJCfSYxtR4
-eH3NtnmNE6/E8yodoUJhkNQDcPhP+cbXv5waEYWpoOJQ9G78JeQ+MKI8AEz+19UA
-vAJDrWBjEgxrKK17qqL8+gxm09RzOt5z4QACt8nsJUV80FCENwIxHOlF8ZXc3Nfz
-7wX6+F8LEvDL2Tf4fEELcigHnlf3N5/8iRd0MmAiB+4lRW8tYY3TnSS7fVLTJ/RJ
-C5xdTr80zrM2sgqKbWtPKMSiXWCZGT81FpJ+bne4KAC868sZ71SzG3QiEt72z+On
-fIN0qB31V0wZB+ZCAU0Me138F9BH7rQALVM619f7OUDMEA2Mbnhej4eblqHnc1MY
-/JS4HRa6OnSaQJs2KR2+zqadAa9Z1d3dJhVAZ0bPBJ43xCZDuv+33POv1fXJ21us
-wcy+OrDyEWR27QpWWkOfwvc4txLqxQ4QlNqApIQYV4nWD220ZM9L49KSCqfG2VHN
-vFhjLKTj/oMKJZll/V58Qc3JPj14FKJD5ODfg2LOFst/vA7UhkV1MRar8rlqzIBa
-LGl4zgZCDlFlUmiymXmCSC6LrxD78oHT4EMJFk2fK/lAgW5i4E/qFGHUl8rCqNR3
-Lpo0YYC4hu5hh1aWuxUyMiXQrnCXTbrXj1svTksD/cTCwjRHQ8hpzA==
------END RSA PRIVATE KEY-----
diff --git a/certdir/goodclient.pk8 b/certdir/goodclient.pk8
deleted file mode 100644
index 50af7714af6ef854ec0435bd1e676ee6c1fe30b1..0000000000000000000000000000000000000000
Binary files a/certdir/goodclient.pk8 and /dev/null differ
diff --git a/certdir/goodroot.crt b/certdir/goodroot.crt
deleted file mode 100644
index 09c853dbb915cd1017ebec61ca0b509f543fb1d5..0000000000000000000000000000000000000000
--- a/certdir/goodroot.crt
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIC7zCCAligAwIBAgIJAOjCfnzSGkPLMA0GCSqGSIb3DQEBBQUAMFkxCzAJBgNV
-BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
-aWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMTExMTAyMTQz
-NTdaFw0yMTExMDcyMTQzNTdaMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21l
-LVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNV
-BAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApE4i3cM5
-zVAgfw8juoNN9kh/jiqZexQTUgQUrjQAMStSBVvPeoPcShbXYAZFCkICZlPdRrjY
-rCyJfdFkII5W+CRh5uNPuv30NDMkCdDYvre02EsOhpmuXaJcUPL24vlTe+9+su4U
-Hjy7FxOrQLe4S4kB7CNEE0lqLVDr5gXOKGkCAwEAAaOBvjCBuzAdBgNVHQ4EFgQU
-0Cs8cRK/hNU0+IkSJO+rxuebtmcwgYsGA1UdIwSBgzCBgIAU0Cs8cRK/hNU0+IkS
-JO+rxuebtmehXaRbMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRl
-MSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxv
-Y2FsaG9zdIIJAOjCfnzSGkPLMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD
-gYEATKWuep0dRQdOwO3QSOYZX3bmbgbMX5rIMn8RT3a/SX4ZD5MSZSqgVOjdmj/I
-kRnlGTyexXIXgKxps4WefCuU8uFqEfGE/yKRD1Lxy4AVve9soPddKtxTAbq1TNXr
-A/5bu1Qqf4tSx48qlQkWbj3Okz2yDbWEjYXWoG3ky4CCtfc=
------END CERTIFICATE-----
diff --git a/certdir/server/pg_hba.conf b/certdir/server/pg_hba.conf
deleted file mode 100644
index 27b76497a73a9a968249bea7b02b4cd667e7f092..0000000000000000000000000000000000000000
--- a/certdir/server/pg_hba.conf
+++ /dev/null
@@ -1,82 +0,0 @@
-# PostgreSQL Client Authentication Configuration File
-# ===================================================
-#
-# Refer to the "Client Authentication" section in the
-# PostgreSQL documentation for a complete description
-# of this file. A short synopsis follows.
-#
-# This file controls: which hosts are allowed to connect, how clients
-# are authenticated, which PostgreSQL user names they can use, which
-# databases they can access. Records take one of these forms:
-#
-# local DATABASE USER METHOD [OPTIONS]
-# host DATABASE USER CIDR-ADDRESS METHOD [OPTIONS]
-# hostssl DATABASE USER CIDR-ADDRESS METHOD [OPTIONS]
-# hostnossl DATABASE USER CIDR-ADDRESS METHOD [OPTIONS]
-#
-# (The uppercase items must be replaced by actual values.)
-#
-# The first field is the connection type: "local" is a Unix-domain socket,
-# "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an
-# SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket.
-#
-# DATABASE can be "all", "sameuser", "samerole", a database name, or
-# a comma-separated list thereof.
-#
-# USER can be "all", a user name, a group name prefixed with "+", or
-# a comma-separated list thereof. In both the DATABASE and USER fields
-# you can also write a file name prefixed with "@" to include names from
-# a separate file.
-#
-# CIDR-ADDRESS specifies the set of hosts the record matches.
-# It is made up of an IP address and a CIDR mask that is an integer
-# (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that specifies
-# the number of significant bits in the mask. Alternatively, you can write
-# an IP address and netmask in separate columns to specify the set of hosts.
-#
-# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi", "krb5",
-# "ident", "pam", "ldap" or "cert". Note that "password" sends passwords
-# in clear text; "md5" is preferred since it sends encrypted passwords.
-#
-# OPTIONS are a set of options for the authentication in the format
-# NAME=VALUE. The available options depend on the different authentication
-# methods - refer to the "Client Authentication" section in the documentation
-# for a list of which options are available for which authentication methods.
-#
-# Database and user names containing spaces, commas, quotes and other special
-# characters must be quoted. Quoting one of the keywords "all", "sameuser" or
-# "samerole" makes the name lose its special character, and just match a
-# database or username with that name.
-#
-# This file is read on server startup and when the postmaster receives
-# a SIGHUP signal. If you edit the file on a running system, you have
-# to SIGHUP the postmaster for the changes to take effect. You can use
-# "pg_ctl reload" to do that.
-
-# Put your actual configuration here
-# ----------------------------------
-#
-# If you want to allow non-local connections, you need to add more
-# "host" records. In that case you will also need to make PostgreSQL listen
-# on a non-local interface via the listen_addresses configuration parameter,
-# or via the -i or -h command line switches.
-#
-
-# CAUTION: Configuring the system for local "trust" authentication allows
-# any local user to connect as any PostgreSQL user, including the database
-# superuser. If you do not trust all your local users, use another
-# authentication method.
-
-
-# TYPE DATABASE USER CIDR-ADDRESS METHOD
-
-# "local" is for Unix domain socket connections only
-local all postgres trust
-# IPv4 local connections:
-host all postgres 127.0.0.1/32 trust
-host test all 127.0.0.1/32 md5
-host hostdb all 127.0.0.1/32 md5
-hostnossl hostnossldb all 127.0.0.1/32 md5
-hostssl hostssldb all 127.0.0.1/32 md5 clientcert=0
-hostssl hostsslcertdb all 127.0.0.1/32 md5 clientcert=1
-hostssl certdb all 127.0.0.1/32 cert
diff --git a/certdir/server/root.crt b/certdir/server/root.crt
deleted file mode 100644
index a45ae6c1c75d16700941c5749cb6fec7f5f24b45..0000000000000000000000000000000000000000
--- a/certdir/server/root.crt
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIC3jCCAkegAwIBAgIJAM9GGWA8iSiIMA0GCSqGSIb3DQEBBQUAMFQxCzAJBgNV
-BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
-aWRnaXRzIFB0eSBMdGQxDTALBgNVBAMTBHRlc3QwHhcNMTExMTEwMjE0MTQ3WhcN
-MjExMTA3MjE0MTQ3WjBUMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0
-ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQ0wCwYDVQQDEwR0
-ZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCns68NbjKQAnHCpmN6amR1
-GdtliqiXDaCjoeBPpVXNQ/ZhqinP9gnDyRPXC5kPqw5/6GqNHcYJqg+IIS8G85Rq
-t3Cs5ZL+JlEDAwd0CkD0Ey5h0oJNfN1bDhV2e/yqc831ElBGK6VItGqKopSUV2y/
-pNijOOdeMZ8GuktT+9mbAQIDAQABo4G3MIG0MB0GA1UdDgQWBBTE93pAIzHiFRFw
-IU38WhnwXm03GzCBhAYDVR0jBH0we4AUxPd6QCMx4hURcCFN/FoZ8F5tNxuhWKRW
-MFQxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJ
-bnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDTALBgNVBAMTBHRlc3SCCQDPRhlgPIko
-iDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAKUsXLsp3i9Tsj1wp46R
-4IkIjwWT1bN3+JOjmA9aqwEVcxTRSStAa5kfTQwc4QSAgHK1oFPsA8gsv3sftYmZ
-MtvYrvba8cOPonuaCrvtJQMvKgv3d10S6esUGlW+5o3PVPUq5yQ7OaN5JHCDTZGS
-phuxlq7//rNjvypX2hbKUj6z
------END CERTIFICATE-----
diff --git a/certdir/server/server.crt b/certdir/server/server.crt
deleted file mode 100644
index 09c853dbb915cd1017ebec61ca0b509f543fb1d5..0000000000000000000000000000000000000000
--- a/certdir/server/server.crt
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIC7zCCAligAwIBAgIJAOjCfnzSGkPLMA0GCSqGSIb3DQEBBQUAMFkxCzAJBgNV
-BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
-aWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMTExMTAyMTQz
-NTdaFw0yMTExMDcyMTQzNTdaMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21l
-LVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNV
-BAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApE4i3cM5
-zVAgfw8juoNN9kh/jiqZexQTUgQUrjQAMStSBVvPeoPcShbXYAZFCkICZlPdRrjY
-rCyJfdFkII5W+CRh5uNPuv30NDMkCdDYvre02EsOhpmuXaJcUPL24vlTe+9+su4U
-Hjy7FxOrQLe4S4kB7CNEE0lqLVDr5gXOKGkCAwEAAaOBvjCBuzAdBgNVHQ4EFgQU
-0Cs8cRK/hNU0+IkSJO+rxuebtmcwgYsGA1UdIwSBgzCBgIAU0Cs8cRK/hNU0+IkS
-JO+rxuebtmehXaRbMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRl
-MSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxv
-Y2FsaG9zdIIJAOjCfnzSGkPLMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD
-gYEATKWuep0dRQdOwO3QSOYZX3bmbgbMX5rIMn8RT3a/SX4ZD5MSZSqgVOjdmj/I
-kRnlGTyexXIXgKxps4WefCuU8uFqEfGE/yKRD1Lxy4AVve9soPddKtxTAbq1TNXr
-A/5bu1Qqf4tSx48qlQkWbj3Okz2yDbWEjYXWoG3ky4CCtfc=
------END CERTIFICATE-----
diff --git a/certdir/server/server.key b/certdir/server/server.key
deleted file mode 100644
index f3db7c57ee99f98f8bd79148a32c5d95a96939a6..0000000000000000000000000000000000000000
--- a/certdir/server/server.key
+++ /dev/null
@@ -1,15 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXAIBAAKBgQCkTiLdwznNUCB/DyO6g032SH+OKpl7FBNSBBSuNAAxK1IFW896
-g9xKFtdgBkUKQgJmU91GuNisLIl90WQgjlb4JGHm40+6/fQ0MyQJ0Ni+t7TYSw6G
-ma5dolxQ8vbi+VN7736y7hQePLsXE6tAt7hLiQHsI0QTSWotUOvmBc4oaQIDAQAB
-AoGAXkP1/QVkxEaUXlFxTjDHKeWuSQJnzBVYgFWXB9sNwSf5htmFz+SXHmq8Znsy
-YRA+EDdNXKXwqddjiqv3pjYD7q6TgzF4D32/NwZGfF7VzBDj2fXpVxjSMZpsHixq
-7GIMUTZxzqTlUMmozEFCgHycN84Pw9dmPpJ6FerqsxhPA4ECQQDQfIZuhBhBqinP
-qHs1ttZQ1VIgJvCnjXXovyQF0fo53xhCqBIHAPQk/zbFDEjdH54e2gSYekBSvtwD
-Dy9KmjbjAkEAyb//56WAYY3gFYBVDSyCZF5Afax0KS/eDYKlPiF45BtdxhdNTY6M
-56C1+K3FiAuTMzNUbfXnDq9mZ1lZreX5QwJBAMx1gqS5WMx044Ip2YMI5s7pFRxA
-8/ttiHeTk/E9RmcgubsM9nj133i07PJ7pK1uR3Q8HQunwJMlZ8B8UMWZzT8CQBD7
-zcIlZ4pO1DdbJ03FmnByksFBnEG/WtUOU3TIgpHJT/qWCZbm0ivJlqgJkOBkAQ9F
-We0rzzioQVmf5vHBs1sCQDCEzTU8Ge/BrWtd1EP9JVx7aFY8c5bRvj+3FPp+43Ep
-5kc1lJK8EINevxykfJ4f94S6GPLuSFfIWEys//WrH14=
------END RSA PRIVATE KEY-----
diff --git a/get_PlatForm_str.sh b/get_PlatForm_str.sh
deleted file mode 100644
index 3b3450c68f85fc664b90172d47d94b6bb0e1dd12..0000000000000000000000000000000000000000
--- a/get_PlatForm_str.sh
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/bin/bash
-# *************************************************************************
-# Copyright: (c) Huawei Technologies Co., Ltd. 2019. All rights reserved
-#
-# description: Acording plat form, get the string info, like "redhat6.4_x86_64".
-# return: $plat_form_str : we support the platform and put out $plat_form_str
-# "Failed" : the plat form, not supported
-# date: 2015-8-22
-# version: 1.0
-#
-# *************************************************************************
-set -e
-
-##############################################################################################
-# common paremeters:
-# lsb_release and uname both suit almost all linux platform, including Redhat,CentOS,SuSE,Debian and so on.
-##############################################################################################
-# get os name
-kernel=""
-if [ -f "/etc/euleros-release" ]
-then
- kernel=$(cat /etc/euleros-release | awk -F ' ' '{print $1}' | tr A-Z a-z)
-elif [ -f "/etc/kylin-release" ]
-then
- kernel=$(cat /etc/kylin-release | awk -F ' ' '{print $1}' | tr A-Z a-z)
-else
- kernel=$(lsb_release -d | awk -F ' ' '{print $2}'| tr A-Z a-z)
-fi
-
-## to solve kernel="name=openeuler"
-if echo $kernel | grep -q 'openeuler'
-then
- kernel="openeuler"
-fi
-
-# get cpu bit
-cpu_bit=$(uname -p)
-
-# the result info
-plat_form_str=""
-
-##################################################################################
-# redhat platform
-# the result form like this: redhat6.4_x86_64
-##################################################################################
-if [ "$kernel"x = "red"x ]
-then
- plat_form_str=redhat6.4_"$cpu_bit"
-fi
-
-##################################################################################
-# fedora platform
-# the result form like this: redhat6.4_x86_64
-##################################################################################
-if [ "$kernel"x = "fedora"x ]
-then
- plat_form_str=redhat6.4_"$cpu_bit"
-fi
-
-##################################################################################
-# suse platform
-# the result form like this: suse11_sp1_x86_64
-##################################################################################
-if [ "$kernel"x = "suse"x ]
-then
- version=$(lsb_release -r | awk -F ' ' '{print $2}')
- if [ "$version"x = "12"x ]
- then
- plat_form_str=suse12_"$cpu_bit"
- else
- plat_form_str=suse11_sp1_"$cpu_bit"
- fi
-fi
-
-##################################################################################
-# euler platform
-# the result form like this: euleros2.0_sp8_aarch64
-##################################################################################
-if [ "$kernel"x = "euleros"x ]
-then
- version=$(cat /etc/euleros-release | awk -F '(' '{print $2}'| awk -F ')' '{print $1}' | tr A-Z a-z)
- plat_form_str=euleros2.0_"$version"_"$cpu_bit"
-fi
-
-##################################################################################
-# deepin platform
-# the result form like this: deepin_aarch64
-##################################################################################
-if [ "$kernel"x = "deepin"x ]
-then
- if [ X"$cpu_bit" = X"unknown" ]
- then
- cpu_bit=$(uname -m)
- fi
- plat_form_str=deepin15.2_"$cpu_bit"
-fi
-##################################################################################
-# centos7.6_x86_64 platform
-# centos7.5+aarch64 platform
-# the result form like this: centos7.6_x86_64 or centos_7.5_aarch64
-##################################################################################
-if [ "$kernel"x = "centos"x ]
-then
- if [ X"$cpu_bit" = X"aarch64" ]
- then
- plat_form_str=centos_7.5_aarch64
- else
- plat_form_str=centos7.6_"$cpu_bit"
- fi
-fi
-
-
-##################################################################################
-# openeuler platform
-# the result form like this: openeuler_aarch64
-##################################################################################
-if [ "$kernel"x = "openeuler"x ]
-then
- plat_form_str=openeuler_"$cpu_bit"
-fi
-
-##################################################################################
-# kylin platform
-# the result form like this: kylin_aarch64
-##################################################################################
-if [ "$kernel"x = "kylin"x ]
-then
- plat_form_str=kylin_"$cpu_bit"
-fi
-
-##################################################################################
-#
-# other platform
-#
-##################################################################################
-if [ -z "$plat_form_str" ]
-then
- echo "Failed"
-else
- echo $plat_form_str
-fi
-
diff --git a/pgjdbc/pom.xml b/pgjdbc/pom.xml
index 57274a2bfb3291c8bcacc9c0c5775719f52b25d3..e2ca9a758f25ba2b6534ac3da0cf71f3f719dec0 100644
--- a/pgjdbc/pom.xml
+++ b/pgjdbc/pom.xml
@@ -4,7 +4,7 @@
org.opengaussopengauss-jdbcopenGauss JDBC Driver
- 2.0.0
+ 3.0.0Java JDBC driver for openGausshttps://gitee.com/opengauss/openGauss-connector-jdbc
@@ -14,7 +14,11 @@
https://jdbc.postgresql.org/about/license.html
-
+
+ org.sonatype.oss
+ oss-parent
+ 7
+ openGausshttps://opengauss.org/
@@ -31,17 +35,18 @@
-
- com.huawei
- demo-0.0.1-SNAPSHOT
- 0.0.1
- junitjunit4.12test
+
+ org.slf4j
+ slf4j-api
+ 1.7.30
+ provided
+
@@ -243,6 +248,33 @@
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.8
+ true
+
+
+ sonatype-nexus-staging
+ https://s01.oss.sonatype.org/
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.5
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+ org.apache.maven.pluginsmaven-site-plugin
@@ -297,7 +329,7 @@
-
+
@@ -327,9 +359,11 @@
org.apache.maven.pluginsmaven-javadoc-plugin
- true
+ false
+ false
+
maven-compiler-plugin3.1
@@ -345,16 +379,6 @@
-
-
- ClouldArtifact-central
- http://cmc.centralrepo.rnd.huawei.com/maven/
-
-
- ClouldArtifact-central
- http://cmc.centralrepo.rnd.huawei.com/maven/
-
- REL42.2.5
diff --git a/pgjdbc/src/main/java/org/postgresql/Driver.java b/pgjdbc/src/main/java/org/postgresql/Driver.java
index 5593694d5bf3387c3de862f606730ed569b02844..63a8fa723e2b13f34ab096e87ae276ee887adcd9 100755
--- a/pgjdbc/src/main/java/org/postgresql/Driver.java
+++ b/pgjdbc/src/main/java/org/postgresql/Driver.java
@@ -10,8 +10,8 @@ import org.postgresql.hostchooser.MultiHostChooser;
import org.postgresql.jdbc.PgConnection;
import org.postgresql.log.Logger;
import org.postgresql.log.Log;
+import org.postgresql.log.Tracer;
import org.postgresql.util.DriverInfo;
-import org.postgresql.util.ExpressionProperties;
import org.postgresql.util.GT;
import org.postgresql.util.HostSpec;
import org.postgresql.util.PSQLException;
@@ -20,13 +20,8 @@ import org.postgresql.util.SharedTimer;
import org.postgresql.util.URLCoder;
import org.postgresql.util.WriterHandler;
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@@ -40,35 +35,14 @@ import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Set;
+import java.util.Map;
+import java.util.LinkedHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.SimpleFormatter;
import java.util.logging.StreamHandler;
import java.util.regex.Pattern;
-import javax.net.ssl.SSLContext;
-
-import com.huawei.shade.org.apache.http.Header;
-import com.huawei.shade.org.apache.http.HttpHeaders;
-import com.huawei.shade.org.apache.http.HttpResponse;
-import com.huawei.shade.org.apache.http.client.methods.HttpDelete;
-import com.huawei.shade.org.apache.http.client.methods.HttpGet;
-import com.huawei.shade.org.apache.http.client.methods.HttpHead;
-import com.huawei.shade.org.apache.http.client.methods.HttpPatch;
-import com.huawei.shade.org.apache.http.client.methods.HttpPost;
-import com.huawei.shade.org.apache.http.client.methods.HttpPut;
-import com.huawei.shade.org.apache.http.client.methods.HttpRequestBase;
-import com.huawei.shade.org.apache.http.conn.ssl.AllowAllHostnameVerifier;
-import com.huawei.shade.org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import com.huawei.shade.org.apache.http.conn.ssl.SSLContexts;
-import com.huawei.shade.org.apache.http.conn.ssl.TrustSelfSignedStrategy;
-import com.huawei.shade.org.apache.http.entity.InputStreamEntity;
-import com.huawei.shade.org.apache.http.impl.client.CloseableHttpClient;
-import com.huawei.shade.org.apache.http.impl.client.HttpClients;
-import com.huawei.shade.com.alibaba.fastjson.JSONObject;
-import com.huawei.shade.com.cloud.apigateway.sdk.utils.Request;
-import com.huawei.shade.com.cloud.apigateway.sdk.utils.Client;
-import com.huawei.shade.com.cloud.sdk.http.HttpMethodName;
/**
@@ -90,105 +64,133 @@ import com.huawei.shade.com.cloud.sdk.http.HttpMethodName;
*/
public class Driver implements java.sql.Driver {
- private static Driver registeredDriver;
- private static final java.util.logging.Logger PARENT_LOGGER = java.util.logging.Logger.getLogger("org.postgresql");
-
- private static Log LOGGER = Logger.getLogger("org.postgresql.Driver");
- private static SharedTimer sharedTimer = new SharedTimer();
- private static final String DEFAULT_PORT =
- /*$"\""+mvn.project.property.template.default.pg.port+"\";"$*//*-*/"5431";
- private static CloseableHttpClient client = null;
- private static final String gsVersion = "@GSVERSION@";
- /* generate one log file */
- public static AtomicBoolean isLogFileCreated;
- static {
- try {
- // moved the registerDriver from the constructor to here
- // because some clients call the driver themselves (I know, as
- // my early jdbc work did - and that was based on other examples).
- // Placing it here, means that the driver is registered once only.
- register();
- } catch (SQLException e) {
- throw new ExceptionInInitializerError(e);
- }
- }
+ private static Driver registeredDriver;
+ private static final java.util.logging.Logger PARENT_LOGGER = java.util.logging.Logger.getLogger("org.postgresql");
+
+ private static Log LOGGER = Logger.getLogger("org.postgresql.Driver");
+ private static SharedTimer sharedTimer = new SharedTimer();
+ private static final String DEFAULT_PORT =
+ /*$"\""+mvn.project.property.template.default.pg.port+"\";"$*//*-*/"5431";
+ // Remove iam certification
+ // private static CloseableHttpClient client = null;
+ private static final String gsVersion = "@GSVERSION@";
+ /* generate one log file */
+ public static AtomicBoolean isLogFileCreated;
+ private static final String[] SENSITIVE_CHARACTERS = {"sslpassword", "iamPassword", "password"};
- // Helper to retrieve default properties from classloader resource
- // properties files.
- private Properties defaultProperties;
+ private static Tracer tracer;
+ private static AtomicBoolean tracerInitialized = new AtomicBoolean(false);
- private synchronized Properties getDefaultProperties() throws IOException {
- if (defaultProperties != null) {
- return defaultProperties;
+ static {
+ try {
+ // moved the registerDriver from the constructor to here
+ // because some clients call the driver themselves (I know, as
+ // my early jdbc work did - and that was based on other examples).
+ // Placing it here, means that the driver is registered once only.
+ register();
+ } catch (SQLException e) {
+ throw new ExceptionInInitializerError(e);
+ }
}
- // Make sure we load properties with the maximum possible privileges.
- try {
- defaultProperties =
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Properties run() throws IOException {
- return loadDefaultProperties();
- }
- });
- } catch (PrivilegedActionException e) {
- throw (IOException) e.getException();
+ // Helper to retrieve default properties from classloader resource
+ // properties files.
+ private Properties defaultProperties;
+
+ /**
+ * Obtain the trace id from the implementation class.
+ *
+ * @return trace id
+ */
+ public static String getTracer() {
+ if (tracer == null) {
+ return null;
+ }
+ String traceId = tracer.getTraceId();
+ if (traceId == null) {
+ return null;
+ } else if (traceId.length() > 32) {
+ traceId = traceId.substring(0, 32);
+ LOGGER.warn("When used link trace, the length of trace id should be less or equals than 32, currently " +
+ "truncated to " + traceId + ".");
+ } else if (traceId.length() < 1) {
+ LOGGER.warn("When used link trace, the length of trace id should be greater than 0.");
+ }
+ return traceId;
}
- return defaultProperties;
- }
+ private synchronized Properties getDefaultProperties() throws IOException {
+ if (defaultProperties != null) {
+ return defaultProperties;
+ }
- private Properties loadDefaultProperties() throws IOException {
- Properties merged = new Properties();
+ // Make sure we load properties with the maximum possible privileges.
+ try {
+ defaultProperties =
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Properties run() throws IOException {
+ return loadDefaultProperties();
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (IOException) e.getException();
+ }
- try {
- PGProperty.USER.set(merged, System.getProperty("user.name"));
- } catch (SecurityException se) {
- // We're just trying to set a default, so if we can't
- // it's not a big deal.
+ return defaultProperties;
}
- // If we are loaded by the bootstrap classloader, getClassLoader()
- // may return null. In that case, try to fall back to the system
- // classloader.
- //
- // We should not need to catch SecurityException here as we are
- // accessing either our own classloader, or the system classloader
- // when our classloader is null. The ClassLoader javadoc claims
- // neither case can throw SecurityException.
- ClassLoader cl = getClass().getClassLoader();
- if (cl == null) {
- LOGGER.debug("Can't find our classloader for the Driver; "
- + "attempt to use the system class loader");
- cl = ClassLoader.getSystemClassLoader();
- }
+ private Properties loadDefaultProperties() throws IOException {
+ Properties merged = new Properties();
- if (cl == null) {
- LOGGER.warn("Can't find a classloader for the Driver; not loading driver "
- + "configuration from org/postgresql/driverconfig.properties");
- return merged; // Give up on finding defaults.
- }
+ try {
+ PGProperty.USER.set(merged, System.getProperty("user.name"));
+ } catch (SecurityException se) {
+ // We're just trying to set a default, so if we can't
+ // it's not a big deal.
+ }
+
+ // If we are loaded by the bootstrap classloader, getClassLoader()
+ // may return null. In that case, try to fall back to the system
+ // classloader.
+ //
+ // We should not need to catch SecurityException here as we are
+ // accessing either our own classloader, or the system classloader
+ // when our classloader is null. The ClassLoader javadoc claims
+ // neither case can throw SecurityException.
+ ClassLoader cl = getClass().getClassLoader();
+ if (cl == null) {
+ LOGGER.debug("Can't find our classloader for the Driver; "
+ + "attempt to use the system class loader");
+ cl = ClassLoader.getSystemClassLoader();
+ }
- LOGGER.debug("Loading driver configuration via classloader " + cl);
+ if (cl == null) {
+ LOGGER.warn("Can't find a classloader for the Driver; not loading driver "
+ + "configuration from org/postgresql/driverconfig.properties");
+ return merged; // Give up on finding defaults.
+ }
- // When loading the driver config files we don't want settings found
- // in later files in the classpath to override settings specified in
- // earlier files. To do this we've got to read the returned
- // Enumeration into temporary storage.
- ArrayList urls = new ArrayList();
- Enumeration urlEnum = cl.getResources("org/postgresql/driverconfig.properties");
- while (urlEnum.hasMoreElements()) {
- urls.add(urlEnum.nextElement());
- }
+ LOGGER.debug("Loading driver configuration via classloader " + cl);
- for (int i = urls.size() - 1; i >= 0; i--) {
- URL url = urls.get(i);
- LOGGER.debug("Loading driver configuration from: " + url);
- InputStream is = url.openStream();
- merged.load(is);
- is.close();
- }
+ // When loading the driver config files we don't want settings found
+ // in later files in the classpath to override settings specified in
+ // earlier files. To do this we've got to read the returned
+ // Enumeration into temporary storage.
+ ArrayList urls = new ArrayList();
+ Enumeration urlEnum = cl.getResources("org/postgresql/driverconfig.properties");
+ while (urlEnum.hasMoreElements()) {
+ urls.add(urlEnum.nextElement());
+ }
+
+ for (int i = urls.size() - 1; i >= 0; i--) {
+ URL url = urls.get(i);
+ LOGGER.debug("Loading driver configuration from: " + url);
+ InputStream is = url.openStream();
+ merged.load(is);
+ is.close();
+ }
- return merged;
+ return merged;
}
public static Properties GetProps(Properties defaults, Properties info) throws PSQLException {
@@ -211,878 +213,757 @@ public class Driver implements java.sql.Driver {
}
return newProps;
}
- /**
- *
Try to make a database connection to the given URL. The driver should return "null" if it
- * realizes it is the wrong kind of driver to connect to the given URL. This will be common, as
- * when the JDBC driverManager is asked to connect to a given URL, it passes the URL to each
- * loaded driver in turn.
- *
- *
The driver should raise an SQLException if it is the right driver to connect to the given URL,
- * but has trouble connecting to the database.
- *
- *
The java.util.Properties argument can be used to pass arbitrary string tag/value pairs as
- * connection arguments.
- *
- *
- *
user - (required) The user to connect as
- *
password - (optional) The password for the user
- *
ssl -(optional) Use SSL when connecting to the server
- *
readOnly - (optional) Set connection to read-only by default
- *
charSet - (optional) The character set to be used for converting to/from
- * the database to unicode. If multibyte is enabled on the server then the character set of the
- * database is used as the default, otherwise the jvm character encoding is used as the default.
- * This value is only used when connecting to a 7.2 or older server.
- *
loglevel - (optional) Enable logging of messages from the driver. The value is an integer
- * from 0 to 2 where: OFF = 0, INFO =1, DEBUG = 2 The output is sent to
- * DriverManager.getPrintWriter() if set, otherwise it is sent to System.out.
- *
compatible - (optional) This is used to toggle between different functionality
- * as it changes across different releases of the jdbc driver code. The values here are versions
- * of the jdbc client and not server versions. For example in 7.1 get/setBytes worked on
- * LargeObject values, in 7.2 these methods were changed to work on bytea values. This change in
- * functionality could be disabled by setting the compatible level to be "7.1", in which case the
- * driver will revert to the 7.1 functionality.
- *
- *
- *
Normally, at least "user" and "password" properties should be included in the properties. For a
- * list of supported character encoding , see
- * http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html Note that you will
- * probably want to have set up the Postgres database itself to use the same encoding, with the
- * {@code -E } argument to createdb.
- *
- * @param url the URL of the database to connect to
- * @param info a list of arbitrary tag/value pairs as connection arguments
- * @return a connection to the URL or null if it isnt us
- * @throws SQLException if a database access error occurs
- * @see java.sql.Driver#connect
- */
- @Override
- public Connection connect(String url, Properties info) throws SQLException {
- // get defaults
- Properties defaults, props;
-
- if (!url.startsWith("jdbc:postgresql:") && !url.startsWith("jdbc:dws:iam:")) {
- return null;
- }
- try {
- defaults = getDefaultProperties();
- } catch (IOException ioe) {
- throw new PSQLException(GT.tr("Error loading default settings from driverconfig.properties"), PSQLState.UNEXPECTED_ERROR, ioe);
- }
- props = GetProps(defaults, info);
+ /**
+ *
Try to make a database connection to the given URL. The driver should return "null" if it
+ * realizes it is the wrong kind of driver to connect to the given URL. This will be common, as
+ * when the JDBC driverManager is asked to connect to a given URL, it passes the URL to each
+ * loaded driver in turn.
+ *
+ *
The driver should raise an SQLException if it is the right driver to connect to the given URL,
+ * but has trouble connecting to the database.
+ *
+ *
The java.util.Properties argument can be used to pass arbitrary string tag/value pairs as
+ * connection arguments.
+ *
+ *
+ *
user - (required) The user to connect as
+ *
password - (optional) The password for the user
+ *
ssl -(optional) Use SSL when connecting to the server
+ *
readOnly - (optional) Set connection to read-only by default
+ *
charSet - (optional) The character set to be used for converting to/from
+ * the database to unicode. If multibyte is enabled on the server then the character set of the
+ * database is used as the default, otherwise the jvm character encoding is used as the default.
+ * This value is only used when connecting to a 7.2 or older server.
+ *
loglevel - (optional) Enable logging of messages from the driver. The value is an integer
+ * from 0 to 2 where: OFF = 0, INFO =1, DEBUG = 2 The output is sent to
+ * DriverManager.getPrintWriter() if set, otherwise it is sent to System.out.
+ *
compatible - (optional) This is used to toggle between different functionality
+ * as it changes across different releases of the jdbc driver code. The values here are versions
+ * of the jdbc client and not server versions. For example in 7.1 get/setBytes worked on
+ * LargeObject values, in 7.2 these methods were changed to work on bytea values. This change in
+ * functionality could be disabled by setting the compatible level to be "7.1", in which case the
+ * driver will revert to the 7.1 functionality.
+ *
+ *
+ *
Normally, at least "user" and "password" properties should be included in the properties. For a
+ * list of supported character encoding , see
+ * http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html Note that you will
+ * probably want to have set up the Postgres database itself to use the same encoding, with the
+ * {@code -E } argument to createdb.
+ *
+ * @param url the URL of the database to connect to
+ * @param info a list of arbitrary tag/value pairs as connection arguments
+ * @return a connection to the URL or null if it isnt us
+ * @throws SQLException if a database access error occurs
+ * @see java.sql.Driver#connect
+ */
+ @Override
+ public Connection connect(String url, Properties info) throws SQLException {
+ // get defaults
+ Properties defaults, props;
+
+ String[] legalUrlTags = {"jdbc:postgresql:", "jdbc:dws:iam:"};
+ boolean isUrlLegal = false;
+ for (String urlTag : legalUrlTags) {
+ if (url.startsWith(urlTag)) {
+ isUrlLegal = true;
+ }
+ }
+ if (!isUrlLegal) {
+ return null;
+ }
- // parse URL and add more properties
- if ((props = parseURL(url, props)) == null) {
- return null;
- }
+ try {
+ defaults = getDefaultProperties();
+ } catch (IOException ioe) {
+ throw new PSQLException(GT.tr("Error loading default settings from driverconfig.properties"),
+ PSQLState.UNEXPECTED_ERROR, ioe);
+ }
+ props = GetProps(defaults, info);
+ // parse URL and add more properties
+ if ((props = parseURL(url, props)) == null) {
+ return null;
+ }
- Logger.setLoggerName(props.getProperty("logger"));
+ if (!parseConnectionProperties(props)) {
+ return null;
+ }
- if(Logger.isUsingJDKLogger()) {
- setupLoggerFromProperties(props);
- } else {
- LOGGER = Logger.getLogger("org.postgresql.Driver");
- }
+ try {
+ LOGGER.debug("Connecting with URL: " + filterAuthenticationCredentials(url));
+
+ // Enforce login timeout, if specified, by running the connection
+ // attempt in a separate thread. If we hit the timeout without the
+ // connection completing, we abandon the connection attempt in
+ // the calling thread, but the separate thread will keep trying.
+ // Eventually, the separate thread will either fail or complete
+ // the connection; at that point we clean up the connection if
+ // we managed to establish one after all. See ConnectThread for
+ // more details.
+ long timeout = timeout(props);
+ if (timeout <= 0) {
+ Connection con = makeConnection(url, props);
+ return con;
+ }
- if(PGProperty.PRIORITY_SERVERS.get(props) != null){
- if(!GlobalClusterStatusTracker.isVaildPriorityServers(props)){
- return null;
- }
- GlobalClusterStatusTracker.refreshProperties(props);
+ ConnectThread ct = new ConnectThread(url, props);
+ Thread thread = new Thread(ct, "PostgreSQL JDBC driver connection thread");
+ thread.setDaemon(true); // Don't prevent the VM from shutting down
+ thread.start();
+ return ct.getResult(timeout);
+ } catch (PSQLException ex1) {
+ LOGGER.debug("Connection error: ", ex1);
+ // re-throw the exception, otherwise it will be caught next, and a
+ // org.postgresql.unusual error will be returned instead.
+ throw ex1;
+ } catch (java.security.AccessControlException ace) {
+ throw new PSQLException(GT.tr("Your security policy has prevented the connection from being attempted. " +
+ "You probably need to grant the connect java.net.SocketPermission to the database server host and" +
+ " port that you wish to connect to."), PSQLState.UNEXPECTED_ERROR, ace);
+ } catch (Exception ex2) {
+ LOGGER.debug("Unexpected connection error: ", ex2);
+ throw new PSQLException(GT.tr("Something unusual has occured to cause the driver to fail. Please report " +
+ "this exception."), PSQLState.UNEXPECTED_ERROR, ex2);
+ }
}
- if (MultiHostChooser.isUsingAutoLoadBalance(props)) {
- if(!MultiHostChooser.isVaildPriorityLoadBalance(props)){
- return null;
- }
- QueryCNListUtils.refreshProperties(props);
- }
+ /**
+ * Parse the configuration items in the connection string.
+ *
+ * @param props Connection Properties
+ */
+ private Boolean parseConnectionProperties(Properties props) {
+ Logger.setLoggerName(props.getProperty("logger"));
+ if (Logger.isUsingJDKLogger()) {
+ setupLoggerFromProperties(props);
+ } else {
+ LOGGER = Logger.getLogger("org.postgresql.Driver");
+ }
- try {
- LOGGER.debug("Connecting with URL: " + url);
-
- // Enforce login timeout, if specified, by running the connection
- // attempt in a separate thread. If we hit the timeout without the
- // connection completing, we abandon the connection attempt in
- // the calling thread, but the separate thread will keep trying.
- // Eventually, the separate thread will either fail or complete
- // the connection; at that point we clean up the connection if
- // we managed to establish one after all. See ConnectThread for
- // more details.
- long timeout = timeout(props);
- if (timeout <= 0) {
- Connection con = makeConnection(url, props);
- return con;
- }
-
- ConnectThread ct = new ConnectThread(url, props);
- Thread thread = new Thread(ct, "PostgreSQL JDBC driver connection thread");
- thread.setDaemon(true); // Don't prevent the VM from shutting down
- thread.start();
- return ct.getResult(timeout);
- } catch (PSQLException ex1) {
- LOGGER.debug("Connection error: ",ex1);
- // re-throw the exception, otherwise it will be caught next, and a
- // org.postgresql.unusual error will be returned instead.
- throw ex1;
- } catch (java.security.AccessControlException ace) {
- throw new PSQLException(GT.tr("Your security policy has prevented the connection from being attempted. You probably need to grant the connect java.net.SocketPermission to the database server host and port that you wish to connect to."), PSQLState.UNEXPECTED_ERROR, ace);
- } catch (Exception ex2) {
- LOGGER.debug("Unexpected connection error: ", ex2);
- throw new PSQLException(GT.tr("Something unusual has occured to cause the driver to fail. Please report this exception."), PSQLState.UNEXPECTED_ERROR, ex2);
+ Boolean parseStatus = true;
+ if (PGProperty.PRIORITY_SERVERS.get(props) != null) {
+ if (!GlobalClusterStatusTracker.isVaildPriorityServers(props)) {
+ parseStatus = false;
+ }
+ GlobalClusterStatusTracker.refreshProperties(props);
+ }
+
+ if (MultiHostChooser.isUsingAutoLoadBalance(props)) {
+ if (!MultiHostChooser.isVaildPriorityLoadBalance(props)) {
+ parseStatus = false;
+ }
+ QueryCNListUtils.refreshProperties(props);
+ }
+ return parseStatus;
}
- }
-
- // Used to check if the handler file is the same
- private static String loggerHandlerFile;
-
- /**
- *
Setup java.util.logging.Logger using connection properties.
- *
- *
See {@link PGProperty#LOGGER_FILE} and {@link PGProperty#LOGGER_FILE}
- *
- * @param props Connection Properties
- */
- private Boolean initLoggerProperties(String driverLogLevel) {
- if (driverLogLevel == null) {
- return false; // Don't mess with Logger if not set
+
+ // Used to check if the handler file is the same
+ private static String loggerHandlerFile;
+
+ /**
+ *
Setup java.util.logging.Logger using connection properties.
+ *
+ *
See {@link PGProperty#LOGGER_FILE} and {@link PGProperty#LOGGER_FILE}
+ *
+ * @param driverLogLevel Connection Properties
+ */
+ private Boolean initLoggerProperties(String driverLogLevel) {
+ if (driverLogLevel == null) {
+ return false; // Don't mess with Logger if not set
}
if (!"OFF".equalsIgnoreCase(driverLogLevel) && !isLogFileCreated.compareAndSet(false, true)) {
return false;
}
if ("OFF".equalsIgnoreCase(driverLogLevel)) {
- PARENT_LOGGER.setLevel(Level.OFF);
- return false; // Don't mess with Logger if set to OFF
+ PARENT_LOGGER.setLevel(Level.OFF);
+ return false; // Don't mess with Logger if set to OFF
} else if ("DEBUG".equalsIgnoreCase(driverLogLevel)) {
- PARENT_LOGGER.setLevel(Level.FINE);
+ PARENT_LOGGER.setLevel(Level.FINE);
} else if ("TRACE".equalsIgnoreCase(driverLogLevel)) {
- PARENT_LOGGER.setLevel(Level.FINEST);
+ PARENT_LOGGER.setLevel(Level.FINEST);
} else if ("INFO".equalsIgnoreCase(driverLogLevel)) {
PARENT_LOGGER.setLevel(Level.INFO);
} else {
- PARENT_LOGGER.setLevel(Level.OFF);
+ PARENT_LOGGER.setLevel(Level.OFF);
}
return true;
- }
- /**
- *
Setup java.util.logging.Logger using connection properties.
- *
- *
See {@link PGProperty#LOGGER_FILE} and {@link PGProperty#LOGGER_FILE}
- *
- * @param props Connection Properties
- */
- private void setupLoggerFromProperties(final Properties props) {
- final String driverLogLevel = PGProperty.LOGGER_LEVEL.get(props);
- if (!initLoggerProperties(driverLogLevel)) {
- return;
}
- ExpressionProperties exprProps = new ExpressionProperties(props, System.getProperties());
- final String driverLogFile = PGProperty.LOGGER_FILE.get(exprProps);
- if (driverLogFile != null && driverLogFile.equals(loggerHandlerFile)) {
- return; // Same file output, do nothing.
- }
+ /**
+ *
Setup java.util.logging.Logger using connection properties.
+ *
+ *
See {@link PGProperty#LOGGER_FILE} and {@link PGProperty#LOGGER_FILE}
+ *
+ * @param props Connection Properties
+ */
+ private void setupLoggerFromProperties(final Properties props) {
+ final String driverLogLevel = PGProperty.LOGGER_LEVEL.get(props);
+ if (!initLoggerProperties(driverLogLevel)) {
+ return;
+ }
- for (java.util.logging.Handler handlers : PARENT_LOGGER.getHandlers()) {
- // Remove previously set Handlers
- handlers.close();
- PARENT_LOGGER.removeHandler(handlers);
- loggerHandlerFile = null;
- }
+ final String driverLogFile = PGProperty.LOGGER_FILE.getDefaultValue();
+ if (driverLogFile != null && driverLogFile.equals(loggerHandlerFile)) {
+ return; // Same file output, do nothing.
+ }
- java.util.logging.Handler handler = null;
- if (driverLogFile != null) {
- try {
- handler = new java.util.logging.FileHandler(driverLogFile);
- loggerHandlerFile = driverLogFile;
- } catch (Exception ex) {
- System.err.println("Cannot enable FileHandler, fallback to ConsoleHandler.");
- }
- }
+ for (java.util.logging.Handler handlers : PARENT_LOGGER.getHandlers()) {
+ // Remove previously set Handlers
+ handlers.close();
+ PARENT_LOGGER.removeHandler(handlers);
+ loggerHandlerFile = null;
+ }
- Formatter formatter = new SimpleFormatter();
-
- if ( handler == null ) {
- if (DriverManager.getLogWriter() != null) {
- handler = new WriterHandler(DriverManager.getLogWriter());
- } else if ( DriverManager.getLogStream() != null) {
- handler = new StreamHandler(DriverManager.getLogStream(), formatter);
- } else {
- handler = new StreamHandler(System.err, formatter);
- }
- } else {
- handler.setFormatter(formatter);
- }
+ java.util.logging.Handler handler = null;
+ if (driverLogFile != null) {
+ try {
+ handler = new java.util.logging.FileHandler(driverLogFile);
+ loggerHandlerFile = driverLogFile;
+ } catch (Exception ex) {
+ System.err.println("Cannot enable FileHandler, fallback to ConsoleHandler.");
+ }
+ }
+
+ Formatter formatter = new SimpleFormatter();
+
+ if (handler == null) {
+ if (DriverManager.getLogWriter() != null) {
+ handler = new WriterHandler(DriverManager.getLogWriter());
+ } else if (DriverManager.getLogStream() != null) {
+ handler = new StreamHandler(DriverManager.getLogStream(), formatter);
+ } else {
+ handler = new StreamHandler(System.err, formatter);
+ }
+ } else {
+ handler.setFormatter(formatter);
+ }
- handler.setLevel(PARENT_LOGGER.getLevel());
- PARENT_LOGGER.setUseParentHandlers(false);
- PARENT_LOGGER.addHandler(handler);
- }
-
- /**
- * Perform a connect in a separate thread; supports getting the results from the original thread
- * while enforcing a login timeout.
- */
- private static class ConnectThread implements Runnable {
- ConnectThread(String url, Properties props) {
- this.url = url;
- this.props = props;
+ handler.setLevel(PARENT_LOGGER.getLevel());
+ PARENT_LOGGER.setUseParentHandlers(false);
+ PARENT_LOGGER.addHandler(handler);
}
- public void run() {
- Connection conn;
- Throwable error;
-
- try {
- conn = makeConnection(url, props);
- error = null;
- } catch (Throwable t) {
- conn = null;
- error = t;
- }
-
- synchronized (this) {
- if (abandoned) {
- if (conn != null) {
+ /**
+ * Perform a connect in a separate thread; supports getting the results from the original thread
+ * while enforcing a login timeout.
+ */
+ private static class ConnectThread implements Runnable {
+ ConnectThread(String url, Properties props) {
+ this.url = url;
+ this.props = props;
+ }
+
+ public void run() {
+ Connection conn;
+ Throwable error;
+
try {
- conn.close();
- } catch (SQLException e) {
+ conn = makeConnection(url, props);
+ error = null;
+ } catch (Throwable t) {
+ conn = null;
+ error = t;
+ }
+
+ synchronized (this) {
+ if (abandoned) {
+ if (conn != null) {
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ }
+ }
+ } else {
+ result = conn;
+ resultException = error;
+ notify();
+ }
}
- }
- } else {
- result = conn;
- resultException = error;
- notify();
}
- }
+
+ /**
+ * Get the connection result from this (assumed running) thread. If the timeout is reached
+ * without a result being available, a SQLException is thrown.
+ *
+ * @param timeout timeout in milliseconds
+ * @return the new connection, if successful
+ * @throws SQLException if a connection error occurs or the timeout is reached
+ */
+ public Connection getResult(long timeout) throws SQLException {
+ long expiry = System.currentTimeMillis() + timeout;
+ synchronized (this) {
+ while (true) {
+ if (result != null) {
+ return result;
+ }
+
+ if (resultException != null) {
+ if (resultException instanceof SQLException) {
+ resultException.fillInStackTrace();
+ throw (SQLException) resultException;
+ } else {
+ throw new PSQLException(
+ GT.tr(
+ "Something unusual has occured to cause the driver to fail. Please report" +
+ " this exception."),
+ PSQLState.UNEXPECTED_ERROR, resultException);
+ }
+ }
+
+ long delay = expiry - System.currentTimeMillis();
+ if (delay <= 0) {
+ abandoned = true;
+ throw new PSQLException(GT.tr("Connection attempt timed out."),
+ PSQLState.CONNECTION_UNABLE_TO_CONNECT);
+ }
+
+ try {
+ wait(delay);
+ } catch (InterruptedException ie) {
+
+ // reset the interrupt flag
+ Thread.currentThread().interrupt();
+ abandoned = true;
+
+ // throw an unchecked exception which will hopefully not be ignored by the calling code
+ throw new RuntimeException(GT.tr("Interrupted while attempting to connect."));
+ }
+ }
+ }
+ }
+
+ private final String url;
+ private final Properties props;
+ private Connection result;
+ private Throwable resultException;
+ private boolean abandoned;
}
/**
- * Get the connection result from this (assumed running) thread. If the timeout is reached
- * without a result being available, a SQLException is thrown.
+ * Create a connection from URL and properties. Always does the connection work in the current
+ * thread without enforcing a timeout, regardless of any timeout specified in the properties.
*
- * @param timeout timeout in milliseconds
- * @return the new connection, if successful
- * @throws SQLException if a connection error occurs or the timeout is reached
+ * @param url the original URL
+ * @param props the parsed/defaulted connection properties
+ * @return a new connection
+ * @throws SQLException if the connection could not be made
*/
- public Connection getResult(long timeout) throws SQLException {
- long expiry = System.currentTimeMillis() + timeout;
- synchronized (this) {
- while (true) {
- if (result != null) {
- return result;
- }
-
- if (resultException != null) {
- if (resultException instanceof SQLException) {
- resultException.fillInStackTrace();
- throw (SQLException) resultException;
- } else {
- throw new PSQLException(
- GT.tr(
- "Something unusual has occured to cause the driver to fail. Please report this exception."),
- PSQLState.UNEXPECTED_ERROR, resultException);
- }
- }
-
- long delay = expiry - System.currentTimeMillis();
- if (delay <= 0) {
- abandoned = true;
- throw new PSQLException(GT.tr("Connection attempt timed out."),
- PSQLState.CONNECTION_UNABLE_TO_CONNECT);
- }
-
- try {
- wait(delay);
- } catch (InterruptedException ie) {
-
- // reset the interrupt flag
- Thread.currentThread().interrupt();
- abandoned = true;
-
- // throw an unchecked exception which will hopefully not be ignored by the calling code
- throw new RuntimeException(GT.tr("Interrupted while attempting to connect."));
- }
+ private static Connection makeConnection(String url, Properties props) throws SQLException {
+ PgConnection pgConnection = new PgConnection(hostSpecs(props), user(props), database(props), props, url);
+ GlobalConnectionTracker.possessConnectionReference(pgConnection.getQueryExecutor(), props);
+ return pgConnection;
+ }
+
+ /**
+ * Returns true if the driver thinks it can open a connection to the given URL. Typically, drivers
+ * will return true if they understand the subprotocol specified in the URL and false if they
+ * don't. Our protocols start with jdbc:postgresql:
+ *
+ * @param url the URL of the driver
+ * @return true if this driver accepts the given URL
+ * @throws PSQLException
+ * @see java.sql.Driver#acceptsURL
+ */
+ @Override
+ public boolean acceptsURL(String url) throws PSQLException {
+ return parseURL(url, null) != null;
+ }
+
+ /**
+ *
The getPropertyInfo method is intended to allow a generic GUI tool to discover what properties
+ * it should prompt a human for in order to get enough information to connect to a database.
+ *
+ *
Note that depending on the values the human has supplied so far, additional values may become
+ * necessary, so it may be necessary to iterate through several calls to getPropertyInfo
+ *
+ * @param url the Url of the database to connect to
+ * @param info a proposed list of tag/value pairs that will be sent on connect open.
+ * @return An array of DriverPropertyInfo objects describing possible properties. This array may
+ * be an empty array if no properties are required
+ * @throws PSQLException
+ * @see java.sql.Driver#getPropertyInfo
+ */
+ @Override
+ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws PSQLException {
+ Properties copy = new Properties(info);
+ Properties parse = parseURL(url, copy);
+ if (parse != null) {
+ copy = parse;
+ }
+
+ PGProperty[] knownProperties = PGProperty.values();
+ DriverPropertyInfo[] props = new DriverPropertyInfo[knownProperties.length];
+ for (int i = 0; i < props.length; ++i) {
+ props[i] = knownProperties[i].toDriverPropertyInfo(copy);
}
- }
+
+ return props;
+ }
+
+ @Override
+ public int getMajorVersion() {
+ return org.postgresql.util.DriverInfo.MAJOR_VERSION;
}
- private final String url;
- private final Properties props;
- private Connection result;
- private Throwable resultException;
- private boolean abandoned;
- }
-
- /**
- * Create a connection from URL and properties. Always does the connection work in the current
- * thread without enforcing a timeout, regardless of any timeout specified in the properties.
- *
- * @param url the original URL
- * @param props the parsed/defaulted connection properties
- * @return a new connection
- * @throws SQLException if the connection could not be made
- */
- private static Connection makeConnection(String url, Properties props) throws SQLException {
- PgConnection pgConnection = new PgConnection(hostSpecs(props), user(props), database(props), props, url);
- GlobalConnectionTracker.possessConnectionReference(pgConnection.getQueryExecutor(), props);
- return pgConnection;
- }
-
- /**
- * Returns true if the driver thinks it can open a connection to the given URL. Typically, drivers
- * will return true if they understand the subprotocol specified in the URL and false if they
- * don't. Our protocols start with jdbc:postgresql:
- *
- * @param url the URL of the driver
- * @return true if this driver accepts the given URL
- * @throws PSQLException
- * @see java.sql.Driver#acceptsURL
- */
- @Override
- public boolean acceptsURL(String url) throws PSQLException {
- return parseURL(url, null) != null;
- }
-
- /**
- *
The getPropertyInfo method is intended to allow a generic GUI tool to discover what properties
- * it should prompt a human for in order to get enough information to connect to a database.
- *
- *
Note that depending on the values the human has supplied so far, additional values may become
- * necessary, so it may be necessary to iterate through several calls to getPropertyInfo
- *
- * @param url the Url of the database to connect to
- * @param info a proposed list of tag/value pairs that will be sent on connect open.
- * @return An array of DriverPropertyInfo objects describing possible properties. This array may
- * be an empty array if no properties are required
- * @throws PSQLException
- * @see java.sql.Driver#getPropertyInfo
- */
- @Override
- public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws PSQLException {
- Properties copy = new Properties(info);
- Properties parse = parseURL(url, copy);
- if (parse != null) {
- copy = parse;
+ @Override
+ public int getMinorVersion() {
+ return org.postgresql.util.DriverInfo.MINOR_VERSION;
}
- PGProperty[] knownProperties = PGProperty.values();
- DriverPropertyInfo[] props = new DriverPropertyInfo[knownProperties.length];
- for (int i = 0; i < props.length; ++i) {
- props[i] = knownProperties[i].toDriverPropertyInfo(copy);
+ /**
+ * Returns the server version series of this driver and the specific build number.
+ *
+ * @return JDBC driver version
+ * @deprecated use {@link #getMajorVersion()} and {@link #getMinorVersion()} instead
+ */
+ @Deprecated
+ public static String getVersion() {
+ return DriverInfo.DRIVER_FULL_NAME;
}
- return props;
- }
-
- @Override
- public int getMajorVersion() {
- return org.postgresql.util.DriverInfo.MAJOR_VERSION;
- }
-
- @Override
- public int getMinorVersion() {
- return org.postgresql.util.DriverInfo.MINOR_VERSION;
- }
-
- /**
- * Returns the server version series of this driver and the specific build number.
- *
- * @return JDBC driver version
- * @deprecated use {@link #getMajorVersion()} and {@link #getMinorVersion()} instead
- */
- @Deprecated
- public static String getVersion() {
- return DriverInfo.DRIVER_FULL_NAME;
- }
-
- /**
- *
Report whether the driver is a genuine JDBC compliant driver. A driver may only report "true"
- * here if it passes the JDBC compliance tests, otherwise it is required to return false. JDBC
- * compliance requires full support for the JDBC API and full support for SQL 92 Entry Level.
- *
- *
For PostgreSQL, this is not yet possible, as we are not SQL92 compliant (yet).
- */
- @Override
- public boolean jdbcCompliant() {
- return false;
- }
-
- public static String parseIPValid(String address) {
- if (address == "" || address == null) {
- return address;
- }
- String regex = "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\."
- + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
- + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
- + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$";
- Pattern pattern = Pattern.compile(regex);
- if (!pattern.matcher(address).matches()) {
- LOGGER.debug("JDBC URL invalid ip address: " + address);
- }
- return address;
- }
-
- /**
- * Constructs a new DriverURL, splitting the specified URL into its component parts.
- *
- * @param url JDBC URL to parse
- * @param defaults Default properties
- * @return Properties with elements added from the url
- * @throws PSQLException
- */
- public static Properties parseURL(String url, Properties defaults) throws PSQLException {
- Properties urlProps = new Properties(defaults);
- String l_urlServer = url;
- String l_urlArgs = "";
-
- int l_qPos = url.indexOf('?');
- if (l_qPos != -1) {
- l_urlServer = url.substring(0, l_qPos);
- l_urlArgs = url.substring(l_qPos + 1);
+ /**
+ *
Report whether the driver is a genuine JDBC compliant driver. A driver may only report "true"
+ * here if it passes the JDBC compliance tests, otherwise it is required to return false. JDBC
+ * compliance requires full support for the JDBC API and full support for SQL 92 Entry Level.
+ *
+ *
For PostgreSQL, this is not yet possible, as we are not SQL92 compliant (yet).
+ */
+ @Override
+ public boolean jdbcCompliant() {
+ return false;
}
- if (!l_urlServer.startsWith("jdbc:postgresql:") && !l_urlServer.startsWith("jdbc:dws:iam:")) {
- LOGGER.debug("JDBC URL must start with \"jdbc:postgresql:\" or \"jdbc:dws:iam:\" but was: " + url);
- return null;
+ public static String parseIPValid(String address) {
+ if (address == "" || address == null) {
+ return address;
+ }
+ String regex = "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\."
+ + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
+ + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
+ + "(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$";
+ Pattern pattern = Pattern.compile(regex);
+ if (!pattern.matcher(address).matches()) {
+ LOGGER.debug("JDBC URL invalid ip address: " + address);
+ }
+ return address;
}
- if(l_urlServer.startsWith("jdbc:postgresql:")) {
- l_urlServer = l_urlServer.substring("jdbc:postgresql:".length());
-
- if (l_urlServer.startsWith("//")) {
- l_urlServer = l_urlServer.substring(2);
- int slash = l_urlServer.indexOf('/');
- if (slash == -1) {
- LOGGER.warn("JDBC URL must contain a / at the end of the host or port: " + url);
- return null;
+
+ /**
+ * Constructs a new DriverURL, splitting the specified URL into its component parts.
+ *
+ * @param url JDBC URL to parse
+ * @param defaults Default properties
+ * @return Properties with elements added from the url
+ * @throws PSQLException
+ */
+ public static Properties parseURL(String url, Properties defaults) throws PSQLException {
+ Properties urlProps = new Properties(defaults);
+ String l_urlServer = url;
+ String l_urlArgs = "";
+ boolean isUrlLegal = false;
+ String[] legalUrlTags = {"jdbc:postgresql:", "jdbc:dws:iam:"};
+
+ int l_qPos = url.indexOf('?');
+ if (l_qPos != -1) {
+ l_urlServer = url.substring(0, l_qPos);
+ l_urlArgs = url.substring(l_qPos + 1);
+ }
+
+ for (String urlTag : legalUrlTags) {
+ if (l_urlServer.startsWith(urlTag)) {
+ isUrlLegal = true;
}
- urlProps.setProperty("PGDBNAME", URLCoder.decode(l_urlServer.substring(slash + 1)));
-
- // Save the ip and port configured in the url
- String[] addresses = l_urlServer.substring(0, slash).split(",");
- StringBuilder hosts = new StringBuilder();
- StringBuilder ports = new StringBuilder();
- for (String address : addresses) {
- int portIdx = address.lastIndexOf(':');
- if (portIdx != -1 && address.lastIndexOf(']') < portIdx) {
- String portStr = address.substring(portIdx + 1);
- try {
- int port = Integer.parseInt(portStr);
- if (port < 1 || port > 65535) {
- LOGGER.warn("JDBC URL port: " + portStr + " not valid (1:65535) ");
+ }
+
+ if (!isUrlLegal) {
+ LOGGER.debug("JDBC URL must start with \"jdbc:postgresql:\" or \"jdbc:dws:iam:\" but was: "
+ + filterAuthenticationCredentials(url));
+ return null;
+ }
+
+ //if (l_urlServer.startsWith("jdbc:postgresql:")) {
+ l_urlServer = l_urlServer.substring("jdbc:postgresql:".length());
+
+ if (l_urlServer.startsWith("//")) {
+ l_urlServer = l_urlServer.substring(2);
+ int slash = l_urlServer.indexOf('/');
+ if (slash == -1) {
+ LOGGER.warn("JDBC URL must contain a / at the end of the host or port: "
+ + filterAuthenticationCredentials(url));
+ return null;
+ }
+ urlProps.setProperty("PGDBNAME", URLCoder.decode(l_urlServer.substring(slash + 1)));
+
+ // Save the ip and port configured in the url
+ String[] addresses = l_urlServer.substring(0, slash).split(",");
+ StringBuilder hosts = new StringBuilder();
+ StringBuilder ports = new StringBuilder();
+ for (String address : addresses) {
+ int portIdx = address.lastIndexOf(':');
+ if (portIdx != -1 && address.lastIndexOf(']') < portIdx) {
+ String portStr = address.substring(portIdx + 1);
+ try {
+ int port = Integer.parseInt(portStr);
+ if (port < 1 || port > 65535) {
+ LOGGER.warn("JDBC URL port: " + portStr + " not valid (1:65535) ");
+ return null;
+ }
+ } catch (NumberFormatException ignore) {
+ LOGGER.warn("JDBC URL invalid port number: " + portStr);
return null;
}
- } catch (NumberFormatException ignore) {
- LOGGER.warn("JDBC URL invalid port number: " + portStr);
- return null;
+ ports.append(portStr);
+ hosts.append(parseIPValid((String) address.subSequence(0, portIdx)));
+ } else {
+ ports.append(DEFAULT_PORT);
+ hosts.append(parseIPValid(address));
}
- ports.append(portStr);
- hosts.append(parseIPValid((String) address.subSequence(0, portIdx)));
- } else {
- ports.append(DEFAULT_PORT);
- hosts.append(parseIPValid(address));
+ ports.append(',');
+ hosts.append(',');
}
- ports.append(',');
- hosts.append(',');
- }
- ports.setLength(ports.length() - 1);
- hosts.setLength(hosts.length() - 1);
+ ports.setLength(ports.length() - 1);
+ hosts.setLength(hosts.length() - 1);
- urlProps.setProperty("PGHOST", hosts.toString());
- urlProps.setProperty("PGPORT", ports.toString());
+ urlProps.setProperty("PGHOST", hosts.toString());
+ urlProps.setProperty("PGPORT", ports.toString());
- //The first connection, put the host and port in the url into the props
- urlProps.setProperty("PGHOSTURL", hosts.toString());
- urlProps.setProperty("PGPORTURL", ports.toString());
- } else {
+ //The first connection, put the host and port in the url into the props
+ urlProps.setProperty("PGHOSTURL", hosts.toString());
+ urlProps.setProperty("PGPORTURL", ports.toString());
+ } else {
/*
if there are no defaults set or any one of PORT, HOST, DBNAME not set
then set it to default
*/
- if (defaults == null || !defaults.containsKey("PGPORT")) {
- urlProps.setProperty("PGPORT", DEFAULT_PORT);
+ if (defaults == null || !defaults.containsKey("PGPORT")) {
+ urlProps.setProperty("PGPORT", DEFAULT_PORT);
+ }
+ if (defaults == null || !defaults.containsKey("PGHOST")) {
+ urlProps.setProperty("PGHOST", "localhost");
+ }
+ if (defaults == null || !defaults.containsKey("PGDBNAME")) {
+ urlProps.setProperty("PGDBNAME", URLCoder.decode(l_urlServer));
+ }
+ }
+
+ // parse the args part of the url
+ urlProps.putAll(praseParam(l_urlArgs));
+ if (urlProps.getProperty("enable_ce") != null && urlProps.getProperty("enable_ce").equals("1")) {
+ urlProps.setProperty("CLIENTLOGIC", "1");
}
- if (defaults == null || !defaults.containsKey("PGHOST")) {
- urlProps.setProperty("PGHOST", "localhost");
+ return urlProps;
+ }
+
+ /**
+ * Shield sensitive information in the connection string, such as password, sslpassword, iamPassword
+ *
+ * @param url Connection string.
+ * @return Connection string without sensitive information
+ */
+ private static String filterAuthenticationCredentials(String url) {
+ String notSensitiveUrl = url;
+ int paramStartIndex = notSensitiveUrl.indexOf("?");
+ if (paramStartIndex != -1) {
+ LinkedHashMap paramsMap = praseParam(notSensitiveUrl.substring(paramStartIndex + 1));
+ StringBuilder stringBuilder = new StringBuilder(notSensitiveUrl.substring(0, paramStartIndex) + "?");
+ for (Map.Entry entry : paramsMap.entrySet()) {
+ boolean isKeyword = false;
+ for (String sensitiveCharacter : SENSITIVE_CHARACTERS) {
+ if (entry.getKey().equals(sensitiveCharacter)) {
+ isKeyword = true;
+ break;
+ }
+ }
+ if (!isKeyword) {
+ stringBuilder.append(entry.getKey() + "=" + entry.getValue() + "&");
+ }
}
- if (defaults == null || !defaults.containsKey("PGDBNAME")) {
- urlProps.setProperty("PGDBNAME", URLCoder.decode(l_urlServer));
+ notSensitiveUrl = stringBuilder.toString();
+ if (notSensitiveUrl.endsWith("?") || notSensitiveUrl.endsWith("&")) {
+ notSensitiveUrl = notSensitiveUrl.substring(0, notSensitiveUrl.length() - 1);
}
}
+ return notSensitiveUrl;
+ }
- // parse the args part of the url
- String[] args = l_urlArgs.split("&");
+ /**
+ * @param urlArgs The parameter part in the connection string
+ * @return parameter map
+ */
+ private static LinkedHashMap praseParam(String urlArgs) {
+ LinkedHashMap paramsMap = new LinkedHashMap<>();
+ String[] args = urlArgs.split("&");
for (String token : args) {
if (token.isEmpty()) {
continue;
}
int l_pos = token.indexOf('=');
if (l_pos == -1) {
- urlProps.setProperty(token, "");
+ paramsMap.put(token, "");
} else {
- urlProps.setProperty(token.substring(0, l_pos), URLCoder.decode(token.substring(l_pos + 1)));
+ paramsMap.put(token.substring(0, l_pos), URLCoder.decode(token.substring(l_pos + 1)));
}
}
- if(urlProps.getProperty("enable_ce") != null && urlProps.getProperty("enable_ce").equals("1")) {
- urlProps.setProperty("CLIENTLOGIC", "1");
- }
- return urlProps;
- }else {
- StringBuffer tmp = new StringBuffer();
- l_urlServer = l_urlServer.substring("jdbc:dws:iam:".length());
- String ClusterIdentifier="", region="", DbUser="", AutoCreate="", AccessKeyID="", SecretAccessKey="";
- if (l_urlServer.startsWith("//")) {
- l_urlServer = l_urlServer.substring(2);
- int slash = l_urlServer.indexOf('/');
- if (slash == -1) {
- return null;
- }
- urlProps.setProperty("PGDBNAME", l_urlServer.substring(slash + 1));
-
- String serverurl = l_urlServer.substring(0, slash);
- String[] clusterurl = serverurl.split(":");
- if(clusterurl.length != 2){
- return null;
- }
- ClusterIdentifier = clusterurl[0];
- region = clusterurl[1];
+ return paramsMap;
+ }
+ /* public method */
+ public static HostSpec[] GetHostSpecs(Properties props) {
+ return hostSpecs(props);
+ }
+
+ /**
+ * @param props Connection properties
+ * @return the address portion of the orgin URL
+ */
+ public static HostSpec[] getURLHostSpecs(Properties props) {
+ return urlHostSpecs(props);
+ }
+
+ public static String GetUser(Properties props) {
+ return user(props);
+ }
+
+ public static String GetDatabase(Properties props) {
+ return database(props);
+ }
+
+ private static HostSpec[] urlHostSpecs(Properties props) {
+ String[] ports = props.getProperty("PGPORTURL").split(",");
+ String[] hosts = props.getProperty("PGHOSTURL").split(",", ports.length);
+ HostSpec[] hostSpecs = new HostSpec[hosts.length];
+ for (int i = 0; i < hostSpecs.length; ++i) {
+ hostSpecs[i] = new HostSpec(hosts[i], Integer.parseInt(ports[i]));
}
-
- //parse the args part of the url
- String[] args = l_urlArgs.split("&");
- for (int i = 0; i < args.length; ++i)
- {
- String token = args[i];
- if (token.length() == 0) {
- continue;
- }
- int l_pos = token.indexOf('=');
- if (l_pos == -1)
- {
- urlProps.setProperty(token, "");
- }
- else
- {
- if(token.substring(0, l_pos).equals("AccessKeyID")){
- AccessKeyID = token.substring(l_pos + 1);
- }else if(token.substring(0, l_pos).equals("SecretAccessKey")){
- SecretAccessKey = token.substring(l_pos + 1);
- }else if(token.substring(0, l_pos).equals("DbUser")){
- DbUser = token.substring(l_pos + 1);
- }else if(token.substring(0, l_pos).equals("AutoCreate")){
- AutoCreate = token.substring(l_pos + 1);
- }else{
- tmp.append("&"+token.substring(0, l_pos)+"="+token.substring(l_pos + 1));
- }
- }
- }
- StringBuffer jdbcUrl = new StringBuffer();
- if(region.equals("") || ClusterIdentifier.equals("") || DbUser.equals("") || AccessKeyID.equals("")
- || SecretAccessKey.equals("")){
- throw new PSQLException(GT.tr("Please confirm that all the parameters needed is added to the url."), PSQLState.CONNECTION_REJECTED);
- }
- InputStream in = null;
- Properties props = new Properties();
- String domainName = "";
- try {
- File f = new File(Driver.class.getClassLoader().getResource("").getPath());
- String filePath = f.getParent() + File.separator + "config" + File.separator + "jdbcconfig.properties";
- in = new BufferedInputStream(new FileInputStream(filePath));
- props = new Properties();
- props.load(in);
- domainName = props.getProperty(region);
- in.close();
- } catch (Exception e) {
- if (in != null) {
- try {
- in.close();
- } catch (IOException ioe) {
- LOGGER.warn(ioe.getMessage());
- }
- }
- try {
- props = new Properties();
- in = Driver.class.getResourceAsStream("/org/postgresql/jdbcconfig.properties");
- props.load(in);
- domainName = props.getProperty(region);
- in.close();
- } catch (Exception e1) {
- if (in != null) {
- try {
- in.close();
- } catch (IOException ioe) {
- LOGGER.warn(ioe.getMessage());
- }
- }
- throw new PSQLException(GT.tr("Parse jdbcconfig.properties failed."),
- PSQLState.CONNECTION_UNABLE_TO_CONNECT, e1);
- }
- }
- if(domainName == null || domainName.equals("")) {
- throw new PSQLException(GT.tr("Unrecognized region name."), PSQLState.CONNECTION_REJECTED);
- }
- jdbcUrl.append("https://" + domainName + "/credentials?");
- jdbcUrl.append("clusterName="+ClusterIdentifier);
- jdbcUrl.append("&dbUser="+DbUser);
- if(!AutoCreate.equals("")) {
- jdbcUrl.append("&autoCreate="+AutoCreate);
+ return hostSpecs;
+ }
+
+ /**
+ * @return the address portion of the URL
+ */
+ private static HostSpec[] hostSpecs(Properties props) {
+ String[] ports = props.getProperty("PGPORT").split(",");
+ String[] hosts = props.getProperty("PGHOST").split(",", ports.length);
+ HostSpec[] hostSpecs = new HostSpec[hosts.length];
+ for (int i = 0; i < hostSpecs.length; ++i) {
+ hostSpecs[i] = new HostSpec(hosts[i], Integer.parseInt(ports[i]));
}
- jdbcUrl.append(tmp.toString());
+ return hostSpecs;
+ }
- String jsonstr="";
- jsonstr = getReturn(AccessKeyID, SecretAccessKey, jdbcUrl.toString(), region);
- try {
- JSONObject jsonObj = JSONObject.parseObject(jsonstr);
- if(jsonObj.get("cluster_credentials") != null){
- jsonstr = jsonObj.get("cluster_credentials").toString();
- jsonObj = JSONObject.parseObject(jsonstr);
- if(jsonObj.get("db_user")!=null){
- urlProps.setProperty("user", jsonObj.get("db_user").toString());
- }
- if(jsonObj.get("db_endpoint")!=null){
- urlProps.setProperty("PGHOST", jsonObj.get("db_endpoint").toString());
- }
- if(jsonObj.get("db_port")!=null){
- urlProps.setProperty("PGPORT", jsonObj.get("db_port").toString());
- }
- if(jsonObj.get("db_password")!=null){
- urlProps.setProperty("password", jsonObj.get("db_password").toString());
- }
+ /**
+ * @return the username of the URL
+ */
+ private static String user(Properties props) {
+ return props.getProperty("user", "");
+ }
- //The first connection, put the host and port in the url into the clusters
- urlProps.setProperty("PGHOSTURL", urlProps.getProperty("PGHOST"));
- urlProps.setProperty("PGPORTURL", urlProps.getProperty("PGPORT"));
- } else if(jsonObj.get("externalMessage") != null) {
- throw new PSQLException (GT.tr(jsonObj.get("externalMessage").toString()), PSQLState.CONNECTION_UNABLE_TO_CONNECT);
- } else {
- throw new PSQLException (GT.tr("The format of Token is not as expected."), PSQLState.CONNECTION_UNABLE_TO_CONNECT);
+ /**
+ * @return the database name of the URL
+ */
+ private static String database(Properties props) {
+ return props.getProperty("PGDBNAME", "");
+ }
+
+ /**
+ * @return the timeout from the URL, in milliseconds
+ */
+ private static long timeout(Properties props) {
+ String timeout = PGProperty.LOGIN_TIMEOUT.get(props);
+ if (timeout != null) {
+ try {
+ return (long) (Float.parseFloat(timeout) * 1000);
+ } catch (NumberFormatException e) {
+ LOGGER.warn("Couldn't parse loginTimeout value: " + timeout);
}
- } catch (Exception e) {
- throw new PSQLException (GT.tr("Parse the token failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT, e);
- }
- if(urlProps.getProperty("ssl") == null && urlProps.getProperty("sslmode") == null) {
- urlProps.setProperty("sslmode", "require");
- }
- if(urlProps.getProperty("enable_ce") != null && urlProps.getProperty("enable_ce").equals("1")) {
- urlProps.setProperty("CLIENTLOGIC", "1");
}
- return urlProps;
+ return (long) DriverManager.getLoginTimeout() * 1000;
}
- }
-
-private static Request getRequest(URL url, String ak, String sk) throws Exception {
- Request request = new Request();
- request.setUrl(url.toString());
- request.setKey(ak);
- request.setSecret(sk);
- return request;
- }
- private static String getReturn(String ak, String sk, String requestUrl,String region) throws PSQLException {
- try {
- URL url = new URL(requestUrl);
- HttpMethodName httpMethod = HttpMethodName.GET;
- Request request = getRequest(url, ak, sk);
- request.setMethod(httpMethod.toString());
- request.addHeader("X-Language", "en-us");
- request.addHeader("Content-Type", "application/json");
- request.addHeader("Accept", "application/json");
-
- HttpRequestBase signedRequest = Client.sign(request);
- HttpResponse response = null;
-
- SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null,
- new TrustSelfSignedStrategy()).useTLS().build();
- SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext,
- new AllowAllHostnameVerifier());
-
- client = HttpClients.custom().setSSLSocketFactory(sslSocketFactory).build();
-
- response = client.execute(signedRequest);
- return convertStreamToString(response.getEntity().getContent());
- } catch (Exception e) {
- throw new PSQLException (GT.tr("Get the token failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT, e);
- } finally {
- try {
- if (client != null) {
- client.close();
- }
- }
- catch (IOException e) {
- LOGGER.warn("Catch IOException, client close failed.");
- }
- }
- }
-
- private static String convertStreamToString(InputStream is) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- StringBuilder sb = new StringBuilder();
- String line = null;
- try {
- while ((line = reader.readLine()) != null) {
- sb.append(line + "\n");
- }
- } catch (IOException ioEX) {
- throw ioEX ;
- } finally {
- is.close();
- }
- return sb.toString();
- }
-
- /* public method */
- public static HostSpec[] GetHostSpecs(Properties props) {
- return hostSpecs(props);
- }
- /**
- * @param props Connection properties
- * @return the address portion of the orgin URL
- */
- public static HostSpec[] getURLHostSpecs(Properties props) {
- return urlHostSpecs(props);
- }
- public static String GetUser(Properties props) {
- return user(props);
- }
- public static String GetDatabase(Properties props) {
- return database(props);
- }
- private static HostSpec[] urlHostSpecs(Properties props) {
- String[] ports = props.getProperty("PGPORTURL").split(",");
- String[] hosts = props.getProperty("PGHOSTURL").split(",", ports.length);
- HostSpec[] hostSpecs = new HostSpec[hosts.length];
- for (int i = 0; i < hostSpecs.length; ++i) {
- hostSpecs[i] = new HostSpec(hosts[i], Integer.parseInt(ports[i]));
+
+ /**
+ * This method was added in v6.5, and simply throws an SQLException for an unimplemented method. I
+ * decided to do it this way while implementing the JDBC2 extensions to JDBC, as it should help
+ * keep the overall driver size down. It now requires the call Class and the function name to help
+ * when the driver is used with closed software that don't report the stack strace
+ *
+ * @param callClass the call Class
+ * @param functionName the name of the unimplemented function with the type of its arguments
+ * @return PSQLException with a localized message giving the complete description of the
+ * unimplemeted function
+ */
+ public static SQLFeatureNotSupportedException notImplemented(Class> callClass,
+ String functionName) {
+ return new SQLFeatureNotSupportedException(
+ GT.tr("Method {0} is not yet implemented.", callClass.getName() + "." + functionName),
+ PSQLState.NOT_IMPLEMENTED.getState());
}
- return hostSpecs;
- }
- /**
- * @return the address portion of the URL
- */
- private static HostSpec[] hostSpecs(Properties props) {
- String[] ports = props.getProperty("PGPORT").split(",");
- String[] hosts = props.getProperty("PGHOST").split(",", ports.length);
- HostSpec[] hostSpecs = new HostSpec[hosts.length];
- for (int i = 0; i < hostSpecs.length; ++i) {
- hostSpecs[i] = new HostSpec(hosts[i], Integer.parseInt(ports[i]));
+
+ public java.util.logging.Logger getParentLogger() {
+ if (Logger.isUsingJDKLogger()) {
+ return PARENT_LOGGER;
+ } else {
+ return null;
+ }
}
- return hostSpecs;
- }
-
- /**
- * @return the username of the URL
- */
- private static String user(Properties props) {
- return props.getProperty("user", "");
- }
-
- /**
- * @return the database name of the URL
- */
- private static String database(Properties props) {
- return props.getProperty("PGDBNAME", "");
- }
-
- /**
- * @return the timeout from the URL, in milliseconds
- */
- private static long timeout(Properties props) {
- String timeout = PGProperty.LOGIN_TIMEOUT.get(props);
- if (timeout != null) {
- try {
- return (long) (Float.parseFloat(timeout) * 1000);
- } catch (NumberFormatException e) {
- LOGGER.warn("Couldn't parse loginTimeout value: " + timeout);
- }
+
+ public static SharedTimer getSharedTimer() {
+ return sharedTimer;
}
- return (long) DriverManager.getLoginTimeout() * 1000;
- }
-
- /**
- * This method was added in v6.5, and simply throws an SQLException for an unimplemented method. I
- * decided to do it this way while implementing the JDBC2 extensions to JDBC, as it should help
- * keep the overall driver size down. It now requires the call Class and the function name to help
- * when the driver is used with closed software that don't report the stack strace
- *
- * @param callClass the call Class
- * @param functionName the name of the unimplemented function with the type of its arguments
- * @return PSQLException with a localized message giving the complete description of the
- * unimplemeted function
- */
- public static SQLFeatureNotSupportedException notImplemented(Class> callClass,
- String functionName) {
- return new SQLFeatureNotSupportedException(
- GT.tr("Method {0} is not yet implemented.", callClass.getName() + "." + functionName),
- PSQLState.NOT_IMPLEMENTED.getState());
- }
-
- public java.util.logging.Logger getParentLogger()
- {
- if(Logger.isUsingJDKLogger()) {
- return PARENT_LOGGER;
- } else {
- return null;
+
+ /**
+ * Register the driver against {@link DriverManager}. This is done automatically when the class is
+ * loaded. Dropping the driver from DriverManager's list is possible using {@link #deregister()}
+ * method.
+ *
+ * @throws IllegalStateException if the driver is already registered
+ * @throws SQLException if registering the driver fails
+ */
+ public static void register() throws SQLException {
+ if (isRegistered()) {
+ throw new IllegalStateException(
+ "Driver is already registered. It can only be registered once.");
+ }
+ registeredDriver = new Driver();
+ DriverManager.registerDriver(registeredDriver);
+ Driver.registeredDriver = registeredDriver;
+
+ isLogFileCreated = new AtomicBoolean(false);
}
- }
-
- public static SharedTimer getSharedTimer() {
- return sharedTimer;
- }
-
- /**
- * Register the driver against {@link DriverManager}. This is done automatically when the class is
- * loaded. Dropping the driver from DriverManager's list is possible using {@link #deregister()}
- * method.
- *
- * @throws IllegalStateException if the driver is already registered
- * @throws SQLException if registering the driver fails
- */
- public static void register() throws SQLException {
- if (isRegistered()) {
- throw new IllegalStateException(
- "Driver is already registered. It can only be registered once.");
+
+ /**
+ * According to JDBC specification, this driver is registered against {@link DriverManager} when
+ * the class is loaded. To avoid leaks, this method allow unregistering the driver so that the
+ * class can be gc'ed if necessary.
+ *
+ * @throws IllegalStateException if the driver is not registered
+ * @throws SQLException if deregistering the driver fails
+ */
+ public static void deregister() throws SQLException {
+ if (!isRegistered()) {
+ throw new IllegalStateException(
+ "Driver is not registered (or it has not been registered using Driver.register() method)");
+ }
+ DriverManager.deregisterDriver(registeredDriver);
+ registeredDriver = null;
}
- registeredDriver = new Driver();
- DriverManager.registerDriver(registeredDriver);
- Driver.registeredDriver = registeredDriver;
-
- isLogFileCreated = new AtomicBoolean(false);
- }
-
- /**
- * According to JDBC specification, this driver is registered against {@link DriverManager} when
- * the class is loaded. To avoid leaks, this method allow unregistering the driver so that the
- * class can be gc'ed if necessary.
- *
- * @throws IllegalStateException if the driver is not registered
- * @throws SQLException if deregistering the driver fails
- */
- public static void deregister() throws SQLException {
- if (!isRegistered()) {
- throw new IllegalStateException(
- "Driver is not registered (or it has not been registered using Driver.register() method)");
+
+ /**
+ * @return {@code true} if the driver is registered against {@link DriverManager}
+ */
+ public static boolean isRegistered() {
+ return registeredDriver != null;
}
- DriverManager.deregisterDriver(registeredDriver);
- registeredDriver = null;
- }
-
- /**
- * @return {@code true} if the driver is registered against {@link DriverManager}
- */
- public static boolean isRegistered() {
- return registeredDriver != null;
- }
-
- public static String getGSVersion()
- {
+
+ public static String getGSVersion() {
return gsVersion;
}
}
diff --git a/pgjdbc/src/main/java/org/postgresql/PGProperty.java b/pgjdbc/src/main/java/org/postgresql/PGProperty.java
index 309ceb9f557d3b8d2a960cd3494606ed2b18a316..5f2e216ba793fd9d4fc393daf60f2cadf46f6528 100644
--- a/pgjdbc/src/main/java/org/postgresql/PGProperty.java
+++ b/pgjdbc/src/main/java/org/postgresql/PGProperty.java
@@ -458,9 +458,13 @@ public enum PGProperty {
* Supported TLS cipher suites
*/
TLS_CIPHERS_SUPPERTED("TLSCiphersSupperted",
- "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,"
- + "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,",
- "Supported TLS cipher suites"),
+ "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,"
+ + "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,"
+ + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,"
+ + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,"
+ + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,"
+ + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
+ "Supported TLS cipher suites"),
/**
* Factory class to instantiate factories for XML processing.
@@ -641,20 +645,20 @@ public enum PGProperty {
return getSetString(properties) != null;
}
- /**
- * Convert this connection parameter and the value read from the given {@code Properties} into a
- * {@code DriverPropertyInfo}.
- *
- * @param properties properties to take actual value from
- * @return a DriverPropertyInfo representing this connection parameter
- */
- public DriverPropertyInfo toDriverPropertyInfo(Properties properties) {
- DriverPropertyInfo propertyInfo = new DriverPropertyInfo(_name, get(properties));
- propertyInfo.required = _required;
- propertyInfo.description = _description;
- propertyInfo.choices = _choices;
- return propertyInfo;
- }
+ /**
+ * Convert this connection parameter and the value read from the given {@code Properties} into a
+ * {@code DriverPropertyInfo}.
+ *
+ * @param properties properties to take actual value from
+ * @return a DriverPropertyInfo representing this connection parameter
+ */
+ public DriverPropertyInfo toDriverPropertyInfo(Properties properties) {
+ DriverPropertyInfo propertyInfo = new DriverPropertyInfo(_name, get(properties));
+ propertyInfo.required = _required;
+ propertyInfo.description = _description;
+ propertyInfo.choices = _choices;
+ return propertyInfo;
+ }
public static PGProperty forName(String name) {
for (PGProperty property : PGProperty.values()) {
diff --git a/pgjdbc/src/main/java/org/postgresql/core/CachedQuery.java b/pgjdbc/src/main/java/org/postgresql/core/CachedQuery.java
index 23ac4cd05aa09c9d74d361b6ac20fc674dc76774..afd96023d36ad6331156c82faa727375eaa6136c 100644
--- a/pgjdbc/src/main/java/org/postgresql/core/CachedQuery.java
+++ b/pgjdbc/src/main/java/org/postgresql/core/CachedQuery.java
@@ -18,16 +18,18 @@ public class CachedQuery implements CanEstimateSize {
public final Object key;
public final Query query;
public final boolean isFunction;
-
+ public final boolean isACompatibilityFunction;
private int executeCount;
- public CachedQuery(Object key, Query query, boolean isFunction) {
+ public CachedQuery(Object key, Query query, boolean isFunction, boolean isACompatibilityFunction) {
assert key instanceof String || key instanceof CanEstimateSize
: "CachedQuery.key should either be String or implement CanEstimateSize."
+ " Actual class is " + key.getClass();
this.key = key;
this.query = query;
this.isFunction = isFunction;
+ this.isACompatibilityFunction = isACompatibilityFunction;
+ this.query.setIsFunction(isFunction);
}
public void increaseExecuteCount() {
diff --git a/pgjdbc/src/main/java/org/postgresql/core/CachedQueryCreateAction.java b/pgjdbc/src/main/java/org/postgresql/core/CachedQueryCreateAction.java
index df74aa2b62c5787f4c60d04168804e12cf549047..b77a6f237e302b5eb512679eb3ffd3538da75df2 100644
--- a/pgjdbc/src/main/java/org/postgresql/core/CachedQueryCreateAction.java
+++ b/pgjdbc/src/main/java/org/postgresql/core/CachedQueryCreateAction.java
@@ -41,14 +41,17 @@ class CachedQueryCreateAction implements LruCache.CreateAction