Commit cb3b0f8e authored by 李振振's avatar 李振振

测试informix北向,高斯南向数据库解析

parents
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.2.0
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "$(uname)" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
else
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=$(java-config --jre-home)
fi
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="$(which javac)"
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=$(which readlink)
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
if $darwin ; then
javaHome="$(dirname "\"$javaExecutable\"")"
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
else
javaExecutable="$(readlink -f "\"$javaExecutable\"")"
fi
javaHome="$(dirname "\"$javaExecutable\"")"
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=$(cd "$wdir/.." || exit 1; pwd)
fi
# end of workaround
done
printf '%s' "$(cd "$basedir" || exit 1; pwd)"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
# Remove \r in case we run on Windows within Git Bash
# and check out the repository with auto CRLF management
# enabled. Otherwise, we may read lines that are delimited with
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
# splitting rules.
tr -s '\r\n' ' ' < "$1"
fi
}
log() {
if [ "$MVNW_VERBOSE" = true ]; then
printf '%s\n' "$1"
fi
}
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
log "$MAVEN_PROJECTBASEDIR"
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
if [ -r "$wrapperJarPath" ]; then
log "Found $wrapperJarPath"
else
log "Couldn't find $wrapperJarPath, downloading it ..."
if [ -n "$MVNW_REPOURL" ]; then
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
else
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
fi
while IFS="=" read -r key value; do
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
safeValue=$(echo "$value" | tr -d '\r')
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
esac
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
log "Downloading from: $wrapperUrl"
if $cygwin; then
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
fi
if command -v wget > /dev/null; then
log "Found wget ... using wget"
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
log "Found curl ... using curl"
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
else
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
fi
else
log "Falling back to using Java to download"
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaSource=$(cygpath --path --windows "$javaSource")
javaClass=$(cygpath --path --windows "$javaClass")
fi
if [ -e "$javaSource" ]; then
if [ ! -e "$javaClass" ]; then
log " - Compiling MavenWrapperDownloader.java ..."
("$JAVA_HOME/bin/javac" "$javaSource")
fi
if [ -e "$javaClass" ]; then
log " - Running MavenWrapperDownloader.java ..."
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
wrapperSha256Sum=""
while IFS="=" read -r key value; do
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
esac
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
if [ -n "$wrapperSha256Sum" ]; then
wrapperSha256Result=false
if command -v sha256sum > /dev/null; then
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
wrapperSha256Result=true
fi
elif command -v shasum > /dev/null; then
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
wrapperSha256Result=true
fi
else
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
exit 1
fi
if [ $wrapperSha256Result = false ]; then
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
exit 1
fi
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
# shellcheck disable=SC2086 # safe args
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.2.0
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %WRAPPER_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
SET WRAPPER_SHA_256_SUM=""
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
)
IF NOT %WRAPPER_SHA_256_SUM%=="" (
powershell -Command "&{"^
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
" exit 1;"^
"}"^
"}"
if ERRORLEVEL 1 goto error
)
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.beagle</groupId>
<artifactId>data-computing-informix</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>data-computing-informix</name>
<description>data-computing-informix</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.ibm.informix/jdbc -->
<dependency>
<groupId>com.ibm.informix</groupId>
<artifactId>jdbc</artifactId>
<version>4.50.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.15</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
<version>3.5.3.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.1</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<!-- 指定jdk版本,和指定编码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- maven 打包时跳过测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- 打包源码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.beagle.informix;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableTransactionManagement(order = 2)
public class BaseApplication {
public static void main(String[] args) {
SpringApplication.run(BaseApplication.class, args);
}
}
//package com.beagle.informix.config.jpa;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.orm.jpa.JpaTransactionManager;
//import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
//import org.springframework.transaction.PlatformTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//
///**
// * @author lzz
// * date 2023/5/31
// * @version 1.0
// * description:
// */
//@Configuration
//@EnableTransactionManagement
//public class PersistJPAConfig {
// @Bean
// public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
//
// }
// @Bean
// public PlatformTransactionManager transactionManager() {
// JpaTransactionManager transactionManager = new JpaTransactionManager();
// transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
// return transactionManager;
// }
//}
package com.beagle.informix.entity.jpa;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Blob;
/**
* @author lzz
* date 2023/5/30
* @version 1.0
* description:
*/
@Data
@Table(name = "cti_vccinfo_new")
@Entity
public class Vccinfo implements Serializable {
private static final long serialVersionUID = 1L;
@Id
// todo 这个id自动生成方式还需测试
@Column(name = "vccid")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer vId;
@Column(name = "vccname")
private String vName;
@Column(name = "effective")
private Integer effective;
@Column(name = "agentmax")
private Integer agentMax;
@Column(name = "ivrmax")
private Integer ivrMax;
@Column(name = "updatekey")
private String updateKey;
@Column(name = "tclob")
@Basic(fetch = FetchType.LAZY)
private String tClob;
@Lob
@Basic(fetch = FetchType.LAZY)
@Column(name = "tblob", columnDefinition = "longblob", nullable = true)
private byte[] tBlob;
}
package com.beagle.informix.entity.mybatis;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.sql.Blob;
/**
* @author lzz
* date 2023/5/30
* @version 1.0
* description:
*/
@Data
@TableName(value = "cti_vccinfo_new")
public class Vccinfo implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "vccid", type = IdType.AUTO )
private Integer vId;
@TableField(value = "vccname")
private String vName;
@TableField(value = "effective")
private Integer effective;
@TableField(value = "agentmax")
private Integer agentMax;
@TableField(value = "ivrmax")
private Integer ivrMax;
@TableField(value = "updatekey")
private String updateKey;
@TableField(value = "tclob")
private String tClob;
/**
* 如果是pg等数据库,字段声明为bytea,则不需要BlobTypeHandler转换,如果声明为blob,则需要转换
*/
// @TableField(value = "tblob", typeHandler = org.apache.ibatis.type.BlobTypeHandler.class)
@TableField(value = "tblob")
private byte[] tBlob;
}
package com.beagle.informix.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.beagle.informix.entity.mybatis.Vccinfo;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface VccinfoMapper extends BaseMapper<Vccinfo> {
@Results(
@Result(column = "tblob",property = "tBlobStr")
)
@Select("SELECT * FROM cti_vccinfo_new where vccid = #{vId}")
List<Vccinfo> queryList(@Param("vId") Integer vId);
/**
* 必须使用org.apache.ibatis.type.BlobTypeHandler转换后,才能保存到数据库
* @param vccinfo
*/
void insertData(@Param("vccinfo") Vccinfo vccinfo);
}
package com.beagle.informix.repository;
import com.beagle.informix.entity.jpa.Vccinfo;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
/**
* @author lzz
* date 2023/5/30
* @version 1.0
* description:
*/
public interface VccinfoDao {
Vccinfo getVccInfoById(Integer vId);
List<Vccinfo> getAllVccInfo();
void addVccinfo(Vccinfo vccinfo);
void updateVccinfo(Vccinfo vccinfo);
void deleteVccinfo(Integer vId);
}
package com.beagle.informix.repository.impl;
import com.beagle.informix.entity.jpa.Vccinfo;
import com.beagle.informix.repository.VccinfoDao;
import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.transaction.Transactional;
import java.util.List;
/**
* @author lzz
* date 2023/5/30
* @version 1.0
* description:
*/
@Repository
public class VccinfoDaoImpl implements VccinfoDao {
@PersistenceContext
private EntityManager entityManager;
@Override
public Vccinfo getVccInfoById(Integer vId) {
return entityManager.find(Vccinfo.class, vId);
}
@Override
public List<Vccinfo> getAllVccInfo() {
String sql = "FROM Vccinfo as vInfo ORDER BY vInfo.effective";
return (List<Vccinfo>) entityManager.createQuery(sql).getResultList();
}
@Override
public void addVccinfo(Vccinfo vccinfo) {
entityManager.persist(vccinfo);
// entityManager.createNativeQuery("insert into cti_vccinfo_new (vccid ,vccname, effective, agentmax,ivrmax,updatekey,tclob,tblob)\n" +
// " VALUES(?,?,?,?,?,?,?,?")
// .setParameter(1, vccinfo.getVId())
// .setParameter(2, vccinfo.getVName())
// .setParameter(3, vccinfo.getEffective())
// .setParameter(4, vccinfo.getAgentMax())
// .setParameter(5, vccinfo.getIvrMax())
// .setParameter(6, vccinfo.getUpdateKey())
// .setParameter(7, vccinfo.getTClob())
// .setParameter(8, vccinfo.getTBlob()).executeUpdate();
}
@Override
@Transactional
public void updateVccinfo(Vccinfo vccinfo) {
// 提示异常 Caused by: java.sql.SQLException: Code-set conversion function failed due to illegal sequence or invalid value.
/*Vccinfo old = entityManager.find(Vccinfo.class, "jpa");
old.setVName("informix—name");
entityManager.merge(old);*/
// 第一步:准备好jpql
// ?1表示第一个参数,?2表示第二个参数
String jpql = "update Vccinfo s set s.vName = ?1 where s.vId = ?2";
EntityTransaction transaction = null;
try {
// transaction = entityManager.getTransaction();
// transaction.begin();
// 第二步:设置jpql的参数
Query query = entityManager.createQuery(jpql);
query.setParameter(1, "赵六666999");
query.setParameter(2, "%jpa%");
// 第三步:执行jpql
int rows = query.executeUpdate();
System.out.println("影响的行数:" + rows);
transaction.commit();
} catch (Exception e) {
e.printStackTrace();
// transaction.rollback();
} finally {
entityManager.close();
}
}
@Override
public void deleteVccinfo(Integer vId) {
entityManager.remove(getVccInfoById(vId));
}
}
package com.beagle.informix.service;
/**
* informix(IBM)数据库测试(jdbc、hibernate、ibatis、mybatis)
*/
public interface InformixService {
void doConnectJob() throws Exception;
}
package com.beagle.informix.service.impl;
import cn.hutool.json.JSONUtil;
import com.beagle.informix.entity.jpa.Vccinfo;
import com.beagle.informix.repository.VccinfoDao;
import com.beagle.informix.service.InformixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;
/**
* Caused by: java.sql.SQLException: Transactions not supported
* ifx事务默认不开启,需要使用命令 通过ontape -s -B dbname来设置,注意不是服务名,而是数据库名
*
* Code-set conversion function failed due to illegal sequence or invalid value.
* 启动失败字符集错误,暂时还未找到解决办法
* @author lzz
* date 2023/5/29
* @version 1.0
* description:
*/
@Slf4j
@Service("informixHibernateService")
public class InformixHibernateServiceImpl implements InformixService {
@Resource
private VccinfoDao vccinfoDao;
@Resource
private ResourceLoader resourceLoader;
@Override
@Transactional
public void doConnectJob() throws Exception{
insert();
// update();
// query();
// delete();
}
private void insert() throws Exception{
Vccinfo vccinfo = new Vccinfo();
// vccinfo.setVId(23);
vccinfo.setEffective(1);
vccinfo.setVName("hibernate");
vccinfo.setIvrMax(1);
vccinfo.setAgentMax(1);
vccinfo.setUpdateKey("jpa key");
// 组装clob
vccinfo.setTClob("@Ddsfsdferewr");
// 组装blob数据
// 处理blob字段
// proxy 处理blob字段时,存放二进制文件(exe),打开异常,存放文本时正常
org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:test1.doc");
File inputStream = resource.getFile();
try (FileInputStream fis = new FileInputStream(inputStream)){
vccinfo.setTBlob(fis.readAllBytes());
}
// insert
vccinfoDao.addVccinfo(vccinfo);
}
private void update(int id) {
Vccinfo vccinfo = new Vccinfo();
vccinfo.setVId(id);
vccinfoDao.updateVccinfo(vccinfo);
}
private void query(int id) {
List<Vccinfo> vccinfoList = vccinfoDao.getAllVccInfo();
log.info("queryAll:{}",JSONUtil.toJsonStr(vccinfoDao.getAllVccInfo()));
log.info("queryById:{}",JSONUtil.toJsonStr(vccinfoDao.getVccInfoById(id)));
}
private void delete(int id) {
vccinfoDao.deleteVccinfo(id);
}
}
package com.beagle.informix.service.impl;
import com.beagle.informix.service.InformixService;
import org.springframework.stereotype.Service;
/**
* @author lzz
* date 2023/5/29
* @version 1.0
* description:
*/
@Service("informixIbatisService")
public class InformixIbatisServiceImpl implements InformixService {
@Override
public void doConnectJob() {
// 手写连接jdbc驱动
}
}
package com.beagle.informix.service.impl;
import com.beagle.informix.service.InformixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.sql.*;
import java.util.Properties;
/**
* @author lzz
* date 2023/5/29
* @version 1.0
* description:
*/
@Slf4j
@Service("informixJdbcProxyService")
public class InformixJdbcProxyServiceImpl implements InformixService {
private ResourceLoader resourceLoader;
public InformixJdbcProxyServiceImpl(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
/**
* informix.url=jdbc:informix-sqli://localhost:9088/sysadmin:INFORMIXSERVER=informix
* informix.driverClassName=com.informix.jdbc.IfxDriver
* informix.user=informix
* informix.password=in4mix
* 进入容器,使用dbaccess 进入informix
* 问题: Invalid default sbspace name (sbspace).
* 解决: onspaces -c -S sbspace -p /opt/ibm/data/spaces/sbspace.000 -o 100 -s 20000 -Df "LOGGING=ON"
* @throws Exception
*/
@Override
public void doConnectJob() throws Exception{
// todo 使用jdbc连接proxy,对应的query(clob、blob字段)存在jdbc 类型转换mysql异常的问题
// Unknown exception: Can not find JDBC type `2005` in column type
Driver driver = getDriver();
Connection conn = getConnection(driver);
insert(conn);
// update(conn);
// query(conn);
// delete(conn);
closeConnection(conn);
deregisterDriver(driver);
}
private Driver getDriver() throws Exception{
// 定义informix的驱动信息
String driverUrl = "com.mysql.cj.jdbc.Driver";
// 还需要加入informix的jdbc驱动jar包
Class<?> driverClass = Class.forName(driverUrl);
return (Driver) driverClass.getConstructor().newInstance();
}
private void deregisterDriver(Driver driver) throws Exception{
// 卸载驱动
DriverManager.deregisterDriver(driver);
}
private void insert(Connection conn) throws Exception{
// 创建testdb数据库、my_test_create_table表
// 现在模拟插入、更新、删除、查询等sql
// 插入
String insertSql = "insert into cti_vccinfo_new (vccid ,vccname, effective, agentmax,ivrmax,updatekey,tclob,tblob) values (?, ? , ?, ?, ? , ?,?,? )";
PreparedStatement stat = conn.prepareStatement(insertSql);
stat.setObject(1, "123456");
stat.setObject(2, "vname");
stat.setObject(3, 1);
stat.setObject(4, 2);
stat.setObject(5, 3);
stat.setObject(6, "updatekey");
String clobContent = "This is a very very long string";
// 处理clob字段
StringReader reader = new StringReader(clobContent);
stat.setClob(7, reader, clobContent.length());
// 处理blob字段
Resource resource = resourceLoader.getResource("classpath:EnableLoopback.exe");
File inputStream = resource.getFile();
FileInputStream fis = new FileInputStream(inputStream);
stat.setBlob(8, fis);
stat.executeUpdate();
}
private void update(Connection conn) throws Exception{
// 创建testdb数据库、my_test_create_table表
// 现在模拟插入、更新、删除、查询等sql
// 插入
String updateSql = "update cti_vccinfo_new set vccname = 'informix_name' where vccid = '123456'";
PreparedStatement stat = conn.prepareStatement(updateSql);
stat.executeUpdate();
}
private void query(Connection conn) throws Exception {
String querySQL = "select * from cti_vccinfo_new where vccid = '123456' ";
PreparedStatement stat = conn.prepareStatement(querySQL);
ResultSet resultSet = stat.executeQuery();
if (resultSet != null) {
while (resultSet.next()) {
log.info("vccid =>" + resultSet.getString("vccid"));
Clob clob = resultSet.getClob("tclob");
BufferedReader reader = new BufferedReader(clob.getCharacterStream());
String clobStr = "";
String finalClobStr = "";
while ((clobStr = reader.readLine())!= null) {
finalClobStr += clobStr;
}
log.info("tclob =>" + finalClobStr);
Blob blob = resultSet.getBlob("tblob");
BufferedInputStream bins= new BufferedInputStream(blob.getBinaryStream());
byte [] bytes = bins.readAllBytes();
String blobStr= new String(bytes, StandardCharsets.UTF_8);
log.info("tblob =>" + blobStr);
}
}
}
private void delete(Connection conn) throws Exception{
String deleteSql = "delete from cti_vccinfo_new where vccid = '123456' ";
conn.createStatement().executeUpdate(deleteSql);
}
private Connection getConnection(Driver driver) throws Exception{
DriverManager.registerDriver(driver);
Properties properties = new Properties();
// 组装连接数据库信息
// jdbc:informix-sqli://<server>:<port1526>/<database>:informixserver=<dbservername>
StringBuilder jdbcBuilder = new StringBuilder("jdbc:mysql://localhost:3307")
.append("/")
.append("testdb").append("?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&useServerPrepStmts=true");
DriverManager.setLoginTimeout(10);
properties.put("user", "root");
properties.put("password", "Apurelove9014");
return DriverManager.getConnection(jdbcBuilder.toString(), properties);
}
private void closeConnection(Connection connection) throws Exception {
connection.close();
}
}
package com.beagle.informix.service.impl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import com.beagle.informix.service.InformixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.sql.*;
import java.util.Properties;
/**
* @author lzz
* date 2023/5/29
* @version 1.0
* description:
*/
@Slf4j
@Service("informixJdbcService")
public class InformixJdbcServiceImpl implements InformixService {
private ResourceLoader resourceLoader;
public InformixJdbcServiceImpl(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
/**
* informix.url=jdbc:informix-sqli://localhost:9088/sysadmin:INFORMIXSERVER=informix
* informix.driverClassName=com.informix.jdbc.IfxDriver
* informix.user=informix
* informix.password=in4mix
* 进入容器,使用dbaccess 进入informix
* 问题: Invalid default sbspace name (sbspace).
* 解决: onspaces -c -S sbspace -p /opt/ibm/data/spaces/sbspace.000 -o 100 -s 20000 -Df "LOGGING=ON"
* @throws Exception
*/
@Override
public void doConnectJob() throws Exception{
Driver driver = getDriver();
Connection conn = getConnection(driver);
insert(conn);
update(conn);
query(conn);
delete(conn);
deregisterDriver(driver);
closeConnection(conn);
}
private void insert(Connection conn) throws Exception{
// 创建testdb数据库、my_test_create_table表
// 现在模拟插入、更新、删除、查询等sql
// 插入
String insertSql = "insert into cti_vccinfo_new (vccid ,vccname, effective, agentmax,ivrmax,updatekey,tclob,tblob) values (?, ? , ?, ?, ? , ?,?,? )";
PreparedStatement stat = conn.prepareStatement(insertSql);
stat.setObject(1, "123456");
stat.setObject(2, "vname");
stat.setObject(3, 1);
stat.setObject(4, 2);
stat.setObject(5, 3);
stat.setObject(6, "updatekey");
String clobContent = "This is a very very long string";
// 处理clob字段
StringReader reader = new StringReader(clobContent);
stat.setClob(7, reader, clobContent.length());
// 处理blob字段
Resource resource = resourceLoader.getResource("classpath:translator.bak2.yaml");
File inputStream = resource.getFile();
FileInputStream fis = new FileInputStream(inputStream);
stat.setBlob(8, fis);
stat.executeUpdate();
}
private void update(Connection conn) throws Exception{
// 创建testdb数据库、my_test_create_table表
// 现在模拟插入、更新、删除、查询等sql
// 插入
String updateSql = "update cti_vccinfo_new set vccname = 'informix_name' where vccid = '123456'";
PreparedStatement stat = conn.prepareStatement(updateSql);
stat.executeUpdate();
}
private void query(Connection conn) throws Exception {
String querySQL = "select * from cti_vccinfo_new where vccid = '123456' ";
PreparedStatement stat = conn.prepareStatement(querySQL);
ResultSet resultSet = stat.executeQuery();
if (resultSet != null) {
while (resultSet.next()) {
log.info("vccid =>" + resultSet.getString("vccid"));
Clob clob = resultSet.getClob("tclob");
BufferedReader reader = new BufferedReader(clob.getCharacterStream());
String clobStr = "";
String finalClobStr = "";
while ((clobStr = reader.readLine())!= null) {
finalClobStr += clobStr;
}
log.info("tclob =>" + finalClobStr);
Blob blob = resultSet.getBlob("tblob");
BufferedInputStream bins= new BufferedInputStream(blob.getBinaryStream());
byte [] bytes = bins.readAllBytes();
String blobStr= new String(bytes, StandardCharsets.UTF_8);
log.info("tblob =>" + blobStr);
}
}
}
private void delete(Connection conn) throws Exception{
String deleteSql = "delete from cti_vccinfo_new where vccid = '123456' ";
conn.createStatement().executeUpdate(deleteSql);
}
private Connection getConnection(Driver driver) throws Exception{
DriverManager.registerDriver(driver);
Properties properties = new Properties();
// 组装连接数据库信息
// jdbc:informix-sqli://<server>:<port1526>/<database>:informixserver=<dbservername>
StringBuilder jdbcBuilder = new StringBuilder("jdbc:informix-sqli://")
.append("localhost:9088")
.append("/")
.append("testdb")
.append(":INFORMIXSERVER=informix");
DriverManager.setLoginTimeout(10);
properties.put("user", "informix");
properties.put("password", "in4mix");
return DriverManager.getConnection(jdbcBuilder.toString(), properties);
}
private Driver getDriver() throws Exception{
// 定义informix的驱动信息
String driverUrl = "com.informix.jdbc.IfxDriver";
// 还需要加入informix的jdbc驱动jar包
Class<?> driverClass = Class.forName(driverUrl);
return (Driver) driverClass.getConstructor().newInstance();
}
private void deregisterDriver(Driver driver) throws Exception{
// 卸载驱动
DriverManager.deregisterDriver(driver);
}
private void closeConnection(Connection connection) throws Exception {
connection.close();
}
}
package com.beagle.informix.service.impl;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beagle.informix.entity.mybatis.Vccinfo;
import com.beagle.informix.mapper.VccinfoMapper;
import com.beagle.informix.service.InformixService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;
/**
* @author lzz
* date 2023/5/29
* @version 1.0
* description:
*/
@Service("informixMybatisService")
@Slf4j
public class InformixMybatisServiceImpl extends ServiceImpl<VccinfoMapper, Vccinfo> implements InformixService {
@Resource
private ResourceLoader resourceLoader;
@Resource
private VccinfoMapper vccinfoMapper;
@Override
@Transactional
public void doConnectJob() throws Exception{
insertMethod();
// updateMethod();
// queryMethod();
// delete();
}
private void insertMethod() throws Exception{
Vccinfo vccinfo = new Vccinfo();
vccinfo.setVId(3);
vccinfo.setEffective(1);
vccinfo.setVName("mybatis");
vccinfo.setIvrMax(1);
vccinfo.setAgentMax(1);
vccinfo.setUpdateKey("mybatis key");
// 组装clob
vccinfo.setTClob("测试clob数据!@#@Ddsfsdferewr");
// 组装blob数据
// 处理blob字段
org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:EnableLoopback.exe");
File inputStream = resource.getFile();
try (FileInputStream fis = new FileInputStream(inputStream)){
vccinfo.setTBlob(fis.readAllBytes());
}
// insert
// 如果使用实体保存,则需要在blob字段上新增BlobTypeHandler转换
// 如果使用xml的insert保存,也需要在属性上设置BlobTypeHandler转换
baseMapper.insertData(vccinfo);
}
private void updateMethod() throws Exception {
LambdaQueryWrapper<Vccinfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Vccinfo::getVId, "ibatis");
Vccinfo vccinfo = new Vccinfo();
vccinfo.setVName("mybatis-update");
baseMapper.update(vccinfo, queryWrapper);
}
private void queryMethod() {
List<Vccinfo> vccinfoList = vccinfoMapper.queryList(1);
log.info("queryAll:{}", JSONUtil.toJsonStr(vccinfoList));
}
private void delete() {
LambdaQueryWrapper<Vccinfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Vccinfo::getVId, "ibatis");
baseMapper.delete(queryWrapper);
}
}
spring:
datasource:
druid:
# url: jdbc:informix-sqli://localhost:9088/testdb:INFORMIXSERVER=informix
#&useServerPrepStmts=true
# url: jdbc:mysql://localhost:3307/testdb?useUnicode=true&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://localhost:3307/testdb?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai
# url: jdbc:mysql://localhost:3307/testdb?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&useServerPrepStmts=true
username: root
# username: informix
# password: in4mix
password: Apurelove9014
# max-active: 20
# max-wait: 60000
# initial-size: 5
# connect-timeout: 30
# min-idle: 5
# min-evictable-idle-time-millis: 300000
# validation-query: select 1
# test-on-borrow: false
# test-on-return: false
# test-while-idle: false
# time-between-eviction-runs-millis: 60000
# driver-class-name: com.informix.jdbc.IfxDriver
driver-class-name: com.mysql.jdbc.Driver # com.mysql.cj.jdbc.Driver
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.InformixDialect
format_sql: true
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
\ No newline at end of file
-- serial 代表自增,本质上也是个int类型
create table cti_vccinfo_new
(
vccid serial not null,
vccname VARCHAR(255),
effective INTEGER default 0 not null,
agentmax INTEGER default 0 not null,
ivrmax INTEGER default 0 not null,
updatekey VARCHAR(30),
tclob clob null,
tblob blob null,
primary key (vccid) constraint PK_CTI_VI_new
);
-- 对接proxy,现在 dml 的 crud的sql都能正常识别并运行
-- ddl语句还在测试中
authority:
privilege:
type: ALL_PRIVILEGES_PERMITTED
users:
- user: root
password: Apurelove9014
props:
proxy-default-port: 3307
sql-show: true
proxy-frontend-database-protocol-type: MySQL
max-connections-size-per-query: 1
mode:
type: Standalone
sqlTranslator:
type: Custom
useOriginalSQLWhenTranslatingFailed: true
rules:
- !SQL_MONITOR_CONFIG
handles:
- type: OpenSearch
enable: true
props:
uris: "http://opensearch-cluster-master.opensearch:9201"
username: ""
password: ""
- !TRANSLATOR_CONFIG
compatibleV1: true
\ No newline at end of file
package com.beagle.informix.service.impl;
import com.beagle.informix.BaseApplication;
import com.beagle.informix.service.InformixService;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = BaseApplication.class)
class InformixServiceTest {
// @Resource(name = "informixJdbcService")
// private InformixService informixJdbcService;
@Resource(name = "informixJdbcProxyService")
private InformixService informixJdbcProxyService;
@Resource(name = "informixHibernateService")
private InformixService informixHibernateService;
// @Resource(name = "informixIbatisService")
// private InformixService informixIbatisService;
@Resource(name = "informixMybatisService")
private InformixService informixMybatisService;
// @Test
// void testJdbcInfo() {
// try {
// informixJdbcService.doConnectJob();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
@Test
void testJdbcProxyInfo() {
try {
informixJdbcProxyService.doConnectJob();
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
void testHibernateInfo() {
try {
informixHibernateService.doConnectJob();
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
void testMybatisInfo() {
try {
informixMybatisService.doConnectJob();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment