How to add PostgreSQL datasource to WildFly 9.0?

后端 未结 6 1504
刺人心
刺人心 2020-12-03 15:23

I\'ve tried tutorial at mastertheboss.com:

  1. ./jboss-cli.sh
  2. module add --name=org.postgres --resources=/tmp/postgresql-9.3-1101.jdbc4
6条回答
  •  旧时难觅i
    2020-12-03 16:14

    Put your Postgres JDBC driver into deployment folder (just deploy). Now use CLI console and enter this command:

    data-source add --name=PostgresqlDS --jndi-name=java:jboss/datasources/PostgresqlDS --driver-name=postgresql-9.4-1201.jdbc41.jar --connection-url=jdbc:postgresql://localhost:5432/test --user-name=USER --password=PASSWORD
    

    Check if your driver is jdbc4.

    I don't know why but adding datasources by web console doesn't work. By CLI works.

    The right solution for extending JDBC drivers is add driver as module to server. In WildFly 9 you can do it using cli console. You can't do this by copy JDBC jar file (with xml) to "module" folder like in WildFly 8.

    Execute commands:

    module add --name=org.postgres --resources=postgresql-9.4-1201.jdbc41.jar --dependencies=javax.api,javax.transaction.api    
    
    /subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)
    

    To list instaled drivers enter:

    /subsystem=datasources:installed-drivers-list
    

    With driver creating datasources will be easy.

    Please use 9.0 Final version. In CR are bugs.

    Regards, Pawel M

提交回复
热议问题