I´ve succesfully set up a Postgres datasource on Wildfly 10.1 final. The application that uses the datasource is still under development and therefore not really in use yet.
Wildfly and postgres each are running in their own VM but on the same host machine.
About once a day, the connection apparently gets lost, and only a restart of wildfly will suffice to re-establish it.
In wildfly´s server.log I can´t find any message related to my datasource. Here is the datasource configuration from standalone.xml
<datasource jta="true" jndi-name="java:/JMPostgres" pool-name="PostgresDS" enabled="true" use-ccm="false">
<connection-url>jdbc:postgresql://10.66.1.102:5432/jm10</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgresql-42.1.4.jar</driver>
<pool>
<min-pool-size>5</min-pool-size>
<initial-pool-size>5</initial-pool-size>
<max-pool-size>50</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>jm10</user-name>
<password>Ba4aeng$eeth0iog.ee2zohB</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
<check-valid-connection-sql>SELECT 1 FROM DUAL;</check-valid-connection-sql>
<validate-on-match>true</validate-on-match>
<background-validation>true</background-validation>
<background-validation-millis>60000</background-validation-millis>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.StaleConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
</validation>
<timeout>
<allocation-retry>5</allocation-retry>
<allocation-retry-wait-millis>10000</allocation-retry-wait-millis>
</timeout>
</datasource>
Related
Using the below jboss configuration while fetching the data from resultset it takes more time but using standalone application it's executed quickly.
it takes 20 seconds in jboss and 0.98 seconds in standalone application
I am using database SQL Server 2019
configuration:
<datasource jta="true" jndi-name="java:jboss/datasources/FXDS" pool-name="FXDS" enabled="true" spy="false" statistics-enabled="true">
<connection-url>jdbc:sqlserver://10.10.10.10:1433;DatabaseName=SQLDB;</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<driver>sqlserver</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>200</max-pool-size>
<prefill>true</prefill>
<flush-strategy>Gracefully</flush-strategy>
</pool>
<security>
<user-name>SA</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"/>
<background-validation>true</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLExceptionSorter"/>
</validation>
<timeout>
<set-tx-query-timeout>true</set-tx-query-timeout>
<query-timeout>1800</query-timeout>
</timeout>
</datasource>
Previously I provided with user name and password and it was working fine. Now The Db side provided access with username only. I mean Username alone I can able to db server and not require password..
Fyr:
jboss path :
\jboss-eap-6.2\standalone\configuration\standalone.xml
<user-name>prabhu</user-name>
<password>x1234</password>
Now If try to provide only username, I am unable to connect Db. your help highly appreciated.
<datasource jta="true" jndi-name="java:/repdb" pool-name="db2_pool_repdb_amlinst" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:db2://01.83.42.122:50000/PRODDB:currentSchema=XYZ;</connection-url>
<driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
<driver>db2</driver>
<security>
<user-name>prabhu</user-name>
<password>x1234</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
I want to implement Connection and Session pooling in jboss-eap-6.2 server to improve the transaction rate. As of now application has to open and close connection each time while sending the message to MQ. Please let me know what should be the configuration in jboss server.
When you set up your data sources there is a pool tag that you can use in the standalone config file
<datasources>
<datasource jta="true" jndi-name="java:/jndiname" pool-name="Datasourcepoolname" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>//connection_string</connection-url>
<driver>MYSQL</driver>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>125</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<timeout>
<blocking-timeout-millis>30000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>
</datasource>
<datasources>
Here is more on JBoss Datasource configuration:
https://docs.jboss.org/author/display/AS71/DataSource+configuration
I have JBoss, and I am using JNDI to connect to database, but when database restarts, I have to restart JBoss to take new connection pool, are there any properties to do reconnection?, please help
<subsystem xmlns="urn:jboss:domain:datasources:1.2">
<datasources>
<datasource jta="false" jndi-name="java:jboss/datasources/ams" pool-name="OracleDS" enabled="true" use-ccm="false">
<connection-url>jdbc:oracle:thin:#rhhqrac01scant:1521/testingenv</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>oracle</driver>
<pool>
<min-pool-size>100</min-pool-size>
<max-pool-size>150</max-pool-size>
<prefill>true</prefill>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>ams</user-name>
<password>testpassword</password>
</security>
<validation>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>0</blocking-timeout-millis>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>0</query-timeout>
<use-try-lock>0</use-try-lock>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>0</allocation-retry-wait-millis>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="oracle" module="com.oracle.ojdbc6">
<xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
You can add that under your datasource tag
<check-valid-connection-sql>select 1</check-valid-connection-sql>
Try this
<validate-on-match>true </validate-on-match>
knowing that this recovers connection, but unfortunately, it will put more load on the database because it validates the connection each time the connection is checked out from the pool.
I have been looking at several examples for configuring a datasource for MySQL in Jboss 7. All references i have seen for the element looks like this:
<driver name="com.mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
I know what the <driver-class> is but what exactly is the <xa-datasource-class> what is its purpose?
When i configured a datasource on Tomcat before i did not need to specify the xa-datasource for any database. Why is it different here?
Thanks
According to jdbc 4.0 specification (12.2): XA datasources produces XA connections capable to be used in global/distributed transactions. You might need such a connection if you need a transaction to span more than one database or a JMS calls. You can find a clear explanation of the concept here: http://www.theserverside.com/discussions/thread.tss?thread_id=21385#95346
If you don't have such a distributed transactions scenario you don't need to specify a xa-datasource, a simple datasource configuration is enough. So, if you use a simple datasource there is no need to specify a xa-datasource-class when you declare your driver.
<datasources>
<datasource jndi-name="java:/myDatasource" pool-name="MyDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:mysql://localhost:3306/mydb
</connection-url>
<driver>
mysql
</driver>
<transaction-isolation>
TRANSACTION_READ_COMMITTED
</transaction-isolation>
<pool>
<min-pool-size>
5
</min-pool-size>
<max-pool-size>
10
</max-pool-size>
<prefill>
true
</prefill>
<use-strict-min>
false
</use-strict-min>
<flush-strategy>
FailingConnectionOnly
</flush-strategy>
</pool>
<security>
<user-name>
username
</user-name>
<password>
password
</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql"/>
</drivers>
</datasources>