diff --git a/README_cn.md b/README_cn.md index a5db3ace61901b3c982816a4eccc636400d438d0..67ee3439d8d70e884ea332b631b7c0880c2d0441 100644 --- a/README_cn.md +++ b/README_cn.md @@ -53,6 +53,7 @@ openGauss JDBC 驱动的生成支持以下操作系统: - CentOS 7.6(x86架构) - openEuler-20.03-LTS(aarch64架构) - Windows +- macOS 适配其他系统,参照博客[openGauss数据库编译指导](https://opengauss.org/zh/blogs/blogs.html?post/xingchen/opengauss_compile/) @@ -212,6 +213,62 @@ openGauss-connector-jdbc中的build.sh是编译过程中的重要脚本工具。 构建成功后会出现两个jar包,分别是opengauss-jdbc-${version}.jar与original-opengauss-jdbc-${version}.jar。jar包路径为/sda/openGauss-connector-jdbc/pgjdbc/target/。 +#### 使用mvn命令生成jar包(macOS) + +1. 准备 Java 与 Maven环境。 + +2. 执行如下命令进入到代码目录: + + ``` + [user@linux sda]$ cd /sda/openGauss-connector-jdbc + ``` + + +3. 使用maven准备脚本: + + ``` + [user@linux openGauss-connector-jdbc]$ sh prepare_macos_maven.sh + ``` + +4. 使用demo准备脚本: + + ``` + [user@linux openGauss-connector-jdbc]$ sh prepare_demo.sh + ``` + +5. 修改根目录下的pom.xml: + + 将modules部分的module由jdbc改为pgjdbc, 如下所示。 + + ``` + + pgjdbc + + ``` + +6. 执行mvn命令: + + ``` + [user@linux openGauss-connector-jdbc]$ mvn clean install -Dmaven.test.skip=true + ``` + + macOS系统下构建成功后会显示如下结果: + + ``` + [INFO] Reactor Summary: + [INFO] + [INFO] openGauss JDBC Driver 2.0.0 ........................ SUCCESS [ 8.486 s] + [INFO] PostgreSQL JDBC Driver aggregate 42.2.5 ............ SUCCESS [ 0.005 s] + [INFO] ------------------------------------------------------------------------ + [INFO] BUILD SUCCESS + [INFO] ------------------------------------------------------------------------ + [INFO] Total time: 8.620 s + [INFO] Finished at: 2021-12-30T19:31:13+08:00 + [INFO] ------------------------------------------------------------------------ + ``` + + 构建成功后会出现两个jar包,分别是opengauss-jdbc-${version}.jar与original-opengauss-jdbc-${version}.jar。jar包路径为/sda/openGauss-connector-jdbc/pgjdbc/target/。 + ## JDBC的使用 diff --git a/README_en.md b/README_en.md index aa66f0c1b36da964a41c62669cb32ddc12bb04df..5dcf375beb026ece0d625dc7abc50ab57ec07c56 100644 --- a/README_en.md +++ b/README_en.md @@ -73,6 +73,7 @@ Remember: Once you have compiled the driver, it will work on ALL platforms that - CentOS 7.6(x86 architecture) - openEuler-20.03-LTS(aarch64 architecture) - Windows +- macOS The following table lists the software requirements for compiling the openGauss-connector-jdbc. @@ -224,6 +225,61 @@ Now you know the usage of build.sh, so you can compile the openGauss-connector-j 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/. +#### Getting jar packages using the mvn command (macOS) + +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. Preparing scripts with Maven: + + ``` + [user@linux openGauss-connector-jdbc]$ sh prepare_macos_maven.sh + ``` + +4. Preparing scripts with demos: + + ``` + [user@linux openGauss-connector-jdbc]$ sh prepare_demo.sh + ``` + +5. Modify the pom.xml in the root directory: + + Change the module from jdbc to pgjdbc, as shown below: + + ``` + + pgjdbc + + ``` + +6. Execute the mvn command: + + ``` + [user@linux openGauss-connector-jdbc]$ mvn clean install -Dmaven.test.skip=true + ``` + + A successful build on a macOS system will display the following result: + + ``` + [INFO] Reactor Summary: + [INFO] + [INFO] openGauss JDBC Driver 2.0.0 ........................ SUCCESS [ 8.486 s] + [INFO] PostgreSQL JDBC Driver aggregate 42.2.5 ............ SUCCESS [ 0.005 s] + [INFO] ------------------------------------------------------------------------ + [INFO] BUILD SUCCESS + [INFO] ------------------------------------------------------------------------ + [INFO] Total time: 8.620 s + [INFO] Finished at: 2021-12-30T19:31:13+08:00 + [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/. + ## Using JDBC diff --git a/prepare_macos_maven.sh b/prepare_macos_maven.sh new file mode 100644 index 0000000000000000000000000000000000000000..82be6fb8163db542786aafc534e47c098a254df4 --- /dev/null +++ b/prepare_macos_maven.sh @@ -0,0 +1,22 @@ +echo begin run +mkdir libs +for src in `find open_source -name '*.jar'` +do + cp $src ./libs/ +done +JDBC_DIR=$(cd "$(dirname "$0")";pwd) +cd ${JDBC_DIR} +rm -rf "${JDBC_DIR}/jdbc" +cp -R "${JDBC_DIR}/pgjdbc" "${JDBC_DIR}/jdbc" + +mvn install:install-file -Dfile=./libs/commons-logging-1.2.jar -DgroupId=commons-logging -DartifactId=commons-logging -Dversion=1.2 -Dpackaging=jar +mvn install:install-file -Dfile=./libs/commons-codec-1.11.jar -DgroupId=commons-codec -DartifactId=commons-codec -Dversion=1.11 -Dpackaging=jar +mvn install:install-file -Dfile=./libs/httpclient-4.5.13.jar -DgroupId=org.apache.httpcomponents -DartifactId=httpclient -Dversion=4.5.13 -Dpackaging=jar +mvn install:install-file -Dfile=./libs/httpcore-4.4.13.jar -DgroupId=org.apache.httpcomponents -DartifactId=httpcore -Dversion=4.4.13 -Dpackaging=jar +mvn install:install-file -Dfile=./libs/fastjson-1.2.70.jar -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.2.70 -Dpackaging=jar +mvn install:install-file -Dfile=./libs/joda-time-2.10.6.jar -DgroupId=joda-time -DartifactId=joda-time -Dversion=2.10.6 -Dpackaging=jar +mvn install:install-file -Dfile=./libs/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=./libs/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=./libs/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=./libs/slf4j-api-1.7.30.jar -DgroupId=org.slf4j -DartifactId=slf4j-api -Dversion=1.7.30 -Dpackaging=jar +mvn install:install-file -Dfile=./libs/java-sdk-core-3.0.12.jar -DgroupId=com.huawei.apigateway -DartifactId=hw-java-sdk-core -Dversion=3.0.12 -Dpackaging=jar