Datasource command line 등록
https://wildfly.org/downloads/ 에서 download
unzip 아무 디렉토리나
cd ~
vi .bash_profile
export JBOSS_HOME=<<아무 디렉토리나>>
만약에 java 가 없다면 JDK를 install하고 JAVA_HOME 을 이와 같이 설정해야 한다.
source .bash_profile
https://jdbc.postgresql.org/download.html 에서 최신 드라이버 다운
<<아무 디렉토리나>>/bin 으로 이동
jdbc driver 등록
stevenucBookPro:bin steven$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect
[standalone@localhost:9990 /] module add --name=org.postgres --resources=/<<다운로드받은 디렉토리 Path>>/postgresql-42.2.6.jar --dependencies=javax.api,javax.transaction.api
[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)
{"outcome" => "success"}
[standalone@localhost:9990 /] data-source add --jndi-name=java:jboss/jndiName --name=poolName --connection-url=jdbc:postgresql://url/databaseName --driver-name=postgres --user-name=userId --password=userPassword
[standalone@localhost:9990 /] exit
상위와 같이 작성 완료 후 다음 파일들이 추가 되었는지 확인 한다.
<<jboss디렉토리>>/modules/org/postgres/main
stevenucBookPro:main steven$ ls -al total 1656 drwxr-xr-x 4 steven admin 128 7 19 17:03 . drwxr-xr-x 3 steven admin 96 7 19 16:47 .. -rw-r--r-- 1 steven admin 317 7 19 16:47 module.xml -rw-r--r-- 1 steven admin 842825 7 19 16:47 postgresql-42.2.6.
<<jboss디렉토리>>/standalone/configuration
.... <subsystem xmlns="urn:jboss:domain:bean-validation:1.0"/> <subsystem xmlns="urn:jboss:domain:core-management:1.0"/> <subsystem xmlns="urn:jboss:domain:datasources:5.0"> <datasources> <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}"> <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url> <driver>h2</driver> <security> <user-name>sa</user-name> <password>sa</password> </security> </datasource> <datasource jndi-name="java:jboss/<<jndiName>>" pool-name="<<poolName>>"> <connection-url>jdbc:postgresql://url/databaseName</connection-url> ....
Datasource wildfly console
https://jdbc.postgresql.org/download.html?source=post_page---------------------------
여기에서 드라이버 링크 복사
[root@localhost deployments]# pwd
/root/wildfly/wildfly/standalone/deployments
root@localhost deployments]# wget https://jdbc.postgresql.org/download/postgresql-42.2.6.jar
--2019-07-25 18:04:54-- https://jdbc.postgresql.org/download/postgresql-42.2.6.jar
Resolving jdbc.postgresql.org (jdbc.postgresql.org)... 72.32.157.228, 2001:4800:3e1:1::228
Connecting to jdbc.postgresql.org (jdbc.postgresql.org)|72.32.157.228|:443... connected.
HTTP request sent, awaiting responseㅔㅈㅇ... 200 OK
Length: 842825 (823K) [application/java-archive]
Saving to: ‘postgresql-42.2.6.jar’
100%[=================================================================================================>] 842,825 818KB/s in 1.0s
2019-07-25 18:04:56 (818 KB/s) - ‘postgresql-42.2.6.jar’ saved [842825/842825]
[root@localhost deployments]# ls
README.txt postgresql-42.2.6.jar
[root@localhost deployments]# systemctl restart wildfly.service
서비스 재 실행 이후
http://<
접근 이후
Homepage > Configuration > Datasource&Driver > JDBC Driver
를 확인 해보면 해당 드라이버가 존재 하는 것을 확인 가능
이경우는 deployments에서 삭제할 경우 드라이버도 같이 삭제 됨으로 비추
728x90
반응형
'Software활용' 카테고리의 다른 글
Jenkins with tomcat (0) | 2020.03.27 |
---|---|
Jenkins on centos7 (0) | 2020.03.27 |
Jenkins Basic (0) | 2020.03.27 |
Docker 이것저것 (0) | 2020.03.27 |
Redis & Jedis (0) | 2020.03.27 |