Giter Club home page Giter Club logo

jtatest's Introduction

1.データベース環境作成

※環境構築はRHEL7である
1)dockerのインストール
     $sudo yum install yum-utils
     $sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
     $sudo yum repolist -v
     $yum list docker-ce --showduplicates | sort -r
     $sudo yum install docker-ce
     $sudo systemctl enable --now docker 
     $systemctl is-active docker  #active確認
2)docker-composeのインストール
     $curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o docker-compose
     $sudo mv docker-compose /usr/local/bin && sudo chmod +x /usr/local/bin/docker-compose
3)Mysql用docker VM作成
     $cd docker_mysql
     $docker-compose up &
4)Mysql コンテナ のIPアドレス確認
      $docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' コンテナID   #自分の場合には172.18.0.2

2 glassfishにおけるJDBC環境作成

  1. MySQL :: Download Connector/J zip(oracle offical site)ファイルに同梱されているmysql-connector-java-XXX.jarをdomains/domain1/lib/extにコピー
  2. bin/asadmin start-domainでglassfishサーバ起動する
  3. http://IPアドレス:4848で管理画面に入って、左メニューからJDBC→JDBC Connection Poolを選択する。「New...」ボタンを押下し、接続情報入力
  • Pool Name: 任意(今回はmypoolにしておく)
  • Resource Type: javax.sql.DataSource
  • Database Driver Vendor: MySQL

    basic 

  1. Additional Propertiesには以下の情報を入力

※ddocker-compose.yml と同じよにpasswordとuserrを設定する

  • password:MYSQL
  • user: MYSQL
  • URL: jdbc:mysql://172.18.0.2/MYSQL?allowPublicKeyRetrieval=true&useSSL=false

additional 

  1. pingでデータベースにアクセス確認

    ping 

  2. JDBC Resources新規作成

下図のようなjdbc/mypoolを作成する

JDBC Resources 

3 検証用war作成、配備

     $mvn clean install

target配下にJTATest-1.warが作られたことを確認

glassfishの作業ディレクトリに移動する

     $bin/asadmin deploy 格納先/JTATest-1.war

4 結果確認

glassfishサーバログに以下の出力を確認する

Starting top-level transaction.]]
Adding entries to table 1.]]
Inspecting table 1.]]
 Column 1: 1]]
 Column 2: 2]]
Adding entries to table 2.]]
Inspecting table 2.]]
 Column 1: 3]]
 Column 2: 4]]
 
Now attempting to rollback changes.]]
Now checking state of table 1.]]
Now checking state of table 2.]]

JTATest-1 was successfully deployed in 339 milliseconds.]]

jtatest's People

Contributors

141801 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.