wildfly配置PostgreSQL数据源
1 下载postgresql jdbc driver
我把postgresql jdbc driver放到了$HOME/devel/lib目录下,因此:
wget http://jdbc.postgresql.org/download/postgresql-9.4.1212.jar
ln -s postgresql-9.4.1212.jar postgresql.jar
2 启动wildfly
3 添加postgresql支持到wildfly
[standalone@localhost:9990 /] module add –name=org.postgresql –slot=main –resources=/home/subaochen/devel/lib/postgresql.jar –dependencies=javax.api,javax.transaction.api
[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=postgres:add(driver-name=”postgres”,driver-module-name=”org.postgresql”,driver-class-name=org.postgresql.Driver)
4 增加wildfly数据源
继续在jboss-cli命令行下执行(替换为你的数据源名称、用户名和密码即可):
[standalone@localhost:9990 /] data-source add –name=labDS –jndi-name=java:jboss/labDS –driver-name=postgres –connection-url=jdbc:postgresql://localhost:5432/lab –user-name=postgres –password=111111 –validate-on-match=true –background-validation=false –valid-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker –exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter
[standalone@localhost:9990 /] /subsystem=datasources:installed-drivers-list
“driver-name” => “postgres”,
“deployment-name” => undefined,
“driver-module-name” => “org.postgresql”,
“driver-datasource-class-name” => “”,
“driver-xa-datasource-class-name” => “”,
“driver-class-name” => “org.postgresql.Driver”,
“driver-major-version” => 9,
“driver-minor-version” => 4,
“jdbc-compliant” => false
“deployment-name” => undefined,
“driver-module-name” => “com.h2database.h2”,
“driver-datasource-class-name” => “”,
“driver-xa-datasource-class-name” => “org.h2.jdbcx.JdbcDataSource”,
“driver-class-name” => “org.h2.Driver”,
“driver-major-version” => 1,
“driver-minor-version” => 3,
参考资料