天天看點

WildFly配置連接配接GBase 8s

簡介:

WildFly,原名 JBoss AS(JBoss Application Server) 或者 JBoss,是一套應用程式伺服器,屬于開源的企業級 Java 中間件軟體,用于實作基于 SOA 架構的 Web 應用和服務。 WildFly 包含一組可獨立運作的軟體。

GBase 8s(南大通用安全資料庫管理系統),是具有完全自主知識産權的資料庫産品,産品符合SQL92、ODBC、OLEDB、JDBC、ADO.NET等國際資料庫規範和開發接口,參照國際主流資料庫産品定義,提供完備的資料存儲和資料管理功能

前置要求:

  1. 作業系統已經安裝JDK(至少1.8版本),環境變量中配置JAVA_HOME
  2. 作業系統可以是Linux,也可以是windows
  3. 可用浏覽器,如firefox、chrome

安裝配置步驟

以下以windows為例,安裝wildfly以及配置GBase 8s資料庫連接配接

1, 下載下傳并解壓WildFly安裝包

此次使用的版本是19.1.0.Final,下載下傳位址:https://www.wildfly.org/downloads/

解壓至D盤的wildfly-19.1.0.Final目錄下

WildFly配置連接配接GBase 8s

2, 為防止端口沖突,可以更改監聽端口

修改D:\wildfly-19.1.0.Final\standalone\configuration路徑下的配置檔案standalone.xml,在socket-binding-group塊中,按實際情況修改相應的端口。

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <!-- 按實際情況修改相應的端口 -->
        <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
        <socket-binding name="http" port="${jboss.http.port:8080}"/>
        <socket-binding name="https" port="${jboss.https.port:8443}"/>
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>
           

3, 添加管理者使用者

執行D:\wildfly-19.1.0.Final\bin目錄下的add-user.bat。Linux環境下執行add-user.sh。增加的使用者名為webadmin,密碼是GBase123

D:\wildfly-19.1.0.Final\bin>add-user.bat

What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a): <回車>   # 管理使用者

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : webadmin  # 管理使用者的使用者名
Password recommendations are listed below. To modify these restrictions edit the
 add-user.properties configuration file.
 - The password should be different from the username
 - The password should not be one of the following restricted values {root, admin, administrator}
 - The password should contain at least 8 characters, 1 alphabetic character(s),1 digit(s), 1 non-alphanumeric symbol(s)
Password : GBase123  # 管理使用者的密碼
WFLYDM0102: Password should have at least 1 non-alphanumeric symbol.
Are you sure you want to use the password entered yes/no? yes # 接受密碼
Re-enter Password : GBase123 # 管理使用者的密碼
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: <回車> # 預設
About to add user 'webadmin' for realm 'ManagementRealm'
Is this correct yes/no? yes # 确認
Added user 'webadmin' to file 'D:\wildfly-19.1.0.Final\standalone\configuration\mgmt-users.properties'
Added user 'webadmin' to file 'D:\wildfly-19.1.0.Final\domain\configuration\mgmt-users.properties'
Added user 'webadmin' with groups  to file 'D:\wildfly-19.1.0.Final\standalone\configuration\mgmt-groups.properties'
Added user 'webadmin' with groups  to file 'D:\wildfly-19.1.0.Final\domain\configuration\mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
yes/no? yes # 确認
To represent the user add the following to the server-identities definition <secret value="R0Jhc2UxMjM=" />

請按任意鍵繼續. . .
           

4, 為WildFly添加連接配接GBase 8s的jar包依賴

進入目錄D:\wildfly-19.1.0.Final\modules,建立gbasedbt\main目錄,之後将Gbase 8s的JDBC包dbtjdbc_2.0.1a2_1p_all.jar (該名稱按實際的修改,預設是ifxjdbc.jar)複制到該檔案夾,然後再在目前目錄下建立配置檔案module.xml ,内容如下:

<!-- name與目錄名稱對應 -->
<module xmlns="urn:jboss:module:1.1" name="gbasedbt" slot="main">
<resources>
    <!-- 按實際情況修改該jdbc的jar封包件名 -->
    <resource-root path="dbtjdbc_2.0.1a2_1p_all.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
    </dependencies>
</module>
           

5, 執行D:\wildfly-19.1.0.Final\bin目錄下standalone.bat啟動服務

WildFly配置連接配接GBase 8s

管理端url位址http://127.0.0.1:9990/console,使用第3步設定的使用者名密碼登入(webadmin/GBase123)。

1)增加JDBC驅動

在Configuration – Subsystems – Datasource & Drivers – JDBC Drivers 中Add JDBC Driver

WildFly配置連接配接GBase 8s
WildFly配置連接配接GBase 8s

2)增加資料源

在Configuration – Subsystems – Datasource & Drivers –Datasources 中Add Datasource

WildFly配置連接配接GBase 8s

使用自定義模闆

WildFly配置連接配接GBase 8s

指定Name及JNDI Name,其中JNDI Name使用java:jboss/ 與 name的字元串組合

WildFly配置連接配接GBase 8s

指定驅動類型

WildFly配置連接配接GBase 8s

指定資料庫連接配接的URL,USER,PASSWORD

URL示例:

jdbc:gbasedbt-sqli://192.168.80.101:9088/testdb:GBASEDBTSERVER=gbase01;DB_LOCALE=zh_CN.utf8;CLIENT_LOCALE=zh_CN.utf8
           
WildFly配置連接配接GBase 8s

測試連接配接

WildFly配置連接配接GBase 8s
WildFly配置連接配接GBase 8s

重新檢視資料源配置

WildFly配置連接配接GBase 8s

6, 詳細配置修改。

在Configuration – Subsystems – Datasource & Drivers –Datasources 中,選擇gbasedbt資料庫,view檢視具體配置,并根據需要修改

WildFly配置連接配接GBase 8s

如:修改連接配接池的配置頁面

WildFly配置連接配接GBase 8s