我们如何从JBOSS配置数据库连接? [英] How can we configure database connection from JBOSS?
本文介绍了我们如何从JBOSS配置数据库连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以配置来自JBOSS的数据库连接吗?如果可能,那么JBOSS中是否有任何配置文件可以配置来自JBOSS的数据库连接?
Can we configure database connection from JBOSS? If it is possible, than is there any configuration file in JBOSS to configure database connection from JBOSS?
推荐答案
您需要两件事:
- 使JDBC驱动程序可用于您的应用服务器
- 写入数据源配置
对于#1,您可以下载包含JDBC驱动程序的JAR并将其放在以下目录中:
For #1, you can download the JAR containing JDBC driver and put it in the following directory:
$JBOSS_HOME/server/default/lib
假设$JBOSS_HOME
指向您的JBoss安装,并且您正在使用default
安装.
Assuming that $JBOSS_HOME
points to your JBoss installation, and you are using default
installation.
对于#2,您会在这里找到很多示例:
For #2, you will find a lot of examples here:
$JBOSS_HOME/docs/examples/jca
周围有大多数数据库产品的示例.这是PostgreSQL的:
There are examples for most of database products around. Here's PostgreSQL's:
<datasources>
<local-tx-datasource>
<jndi-name>PostgresDS</jndi-name>
<connection-url>jdbc:postgresql://[servername]:[port]/[database name]</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<user-name>x</user-name>
<password>y</password>
<!-- sql to call when connection is created. Can be anything, select 1 is valid for PostgreSQL
<new-connection-sql>select 1</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool. Can be anything, select 1 is valid for PostgreSQL
<check-valid-connection-sql>select 1</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>PostgreSQL 7.2</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
这篇关于我们如何从JBOSS配置数据库连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文