jboss jndi配置部分参数详解

时间:2023-03-08 17:45:57
jboss jndi配置部分参数详解

使用的是jboss7.1.1, jndi的配置在$JBOSS_HOME/standalone/configuration/standalone.xml中进行配置。配置jndi时有很多参数,解释下用到的一些参数:

jndi-name
The JNDI name under which the Datasource should be bound.
datasource需要绑定的JNDI名称。
use-java-context
Boolean value indicating whether the jndi-name should be prefixed with java:. This prefix causes the Datasource to only be accessible from within the JBoss Enterprise Platform virtual machine. Defaults toTRUE.
布尔值表明是否在JNDI名称前加上前缀 "java:",默认值为"TRUE",也就是添加前缀"java:"
user-name
The user name used to create the connection to the datasource.
创建链接连接数据源的时候使用的用户名
password
The password used to create the connection to the datasource.
创建链接连接数据源的时候使用的密码
connection-url
The JDBC driver connection URL string
连接数据源的URL字符串
min-pool-size
The minimum number of connections maintained in the pool. Unless is TRUE, the pool remains empty until the first use, at which point the pool is filled to the . When the pool size drops below the due to idle timeouts, the pool is refilled to the . Defaults to 0.
数据库连接池保留的最小连接数。除非参数值为"TRUE",否则连接池在第一次使用前都将保持空连接数,当第一次使用后,数据库连接池会自动将连接数填满为所配置的最小连接数。当因为闲置而超时时,连接池将删除连接至最小连接数以下,但之后连接池会重新将连接数填为所配置的最小连接数。默认值为0.
max-pool-size
The maximum number of connections allowed in the pool. Defaults to 20.
数据库连接池允许的最大连接数。默认值为20
prefill
Whether to attempt to prefill the connection pool to the minimum number of connections. Only supporting pools (OnePool) support this feature. A warning is logged if the pool does not support prefilling. Defaults to TRUE.
是否在一开始的时候就尝试将连接池的连接数预先增加为配置的最小连接个数;否则在第一次获取连接时才启动创建最小连接个数。只有支持的连接池支持这个特性。如果连接池不支持预先填满,那么会有一个警告被打印。默认值为"TRUE"
blocking-timeout-millis
The length of time, in milliseconds, to wait for a connection to become available when all the connections are checked out. Defaults to 30000, which is 30 seconds.
当所有的连接都被占用后,从连接池中等待一个连接变为可用的时间;如果超过该时间,则超时。单位是毫秒。默认是30000毫秒,也就是30秒。
idle-timeout-minutes
The maximum time, in minutes, before an idle connection is closed. A value of 0 disables timeout. Defaults to 15 minutes.
一个连接最大的空闲时间,超过这个时间,连接就会被关闭。如果值设置为0则禁用这个功能,默认为15分钟。后台程序会定时清理过度空闲的连接来节省数据库的连接资源。
valid-connection-checker
A class that checks whether a connection is valid using a vendor-specific mechanism.
使用一个厂商的机制来检查一个连接是否有效。
check-valid-connection-sql
An SQL statement that is executed before the connection is checked out from the pool to make sure it is still valid. If the SQL statement fails, the connection is closed and a new one is created.
在连接从连接池中被占用前会执行该SQL,来确保连接仍然有效。如果SQL执行失败,那么连接会被关闭并且同时会创建一个新的连接。
exception-sorter
A class that parses vendor-specific messages to determine whether SQL errors are fatal, and destroys the connection if so. If empty, no errors are treated as fatal.
默认情况下,jboss不会对无效的连接进行销毁,如果我们需要对异常列表中的连接进行销毁,则需要在设置该配置。该类解析每个厂商不同的应答来决定SQL执行的错误是否是致命的,如果是的话就会销毁该连接。如果为空的话,那么任何错误都不会被认为是致命的。