-
1. Re: How to add PostgreSql driver with pooled datasource in JBoss 7?
sfcoy Jun 20, 2013 9:49 PM (in response to breakpoint)Have a look at Install and Configure the PostgreSQL Database from the JBoss AS Quickstarts documentation.
-
2. Re: How to add PostgreSql driver with pooled datasource in JBoss 7?
breakpoint Jun 21, 2013 1:44 AM (in response to sfcoy)Ok, thanks. However, the article still doesn't show how to add a datasource for pooled connections. I was using this class on Glassfish: http://jdbc.postgresql.org/documentation/publicapi/org/postgresql/ds/PGConnectionPoolDataSource.html
That isn't XA. Is it required on JBoss to use the XA datasource from PostgreSql since all tutorials/articles use that?
-
3. Re: How to add PostgreSql driver with pooled datasource in JBoss 7?
sfcoy Jun 21, 2013 3:04 AM (in response to breakpoint)A non-XA DataSource is always pooled in JBossAS/WildFly.
This fragment shows a Postgresql datasource that I've used in the past:
{code:xml}<datasource jta="true" jndi-name="java:jboss/myDS" pool-name="MyDSPool" enabled="true" use-ccm="false">
<connection-url>jdbc:postgresql://localhost:5432/mydb</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgresql91</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>...</user-name>
<password>...</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>{code}
-
4. Re: How to add PostgreSql driver with pooled datasource in JBoss 7?
breakpoint Jun 21, 2013 3:17 AM (in response to sfcoy)But doesn't this have a driver registration element like the XADatasource? I mean in the drivers element tag? I see you have the driver-class in the code you posted though. I don't get it, when are you supposed to use the drivers element, and the datasource-class element? From the XSD for datasource I found xa-datasource-class, datasource-class and driver-class.
-
5. Re: How to add PostgreSql driver with pooled datasource in JBoss 7?
sfcoy Jun 21, 2013 3:40 AM (in response to breakpoint)I think the driver-class element is actually redundant in this case, because it's specified by the META-INF/services/java.sql.driver file in the postgresql-nnn.jdbc4.jar.
I also have the following "drivers" configured:
{code:xml}
<drivers>
<driver name="postgresql91" module="org.postgresql.jdbc">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
</drivers>
{code}
This is referenced by the "driver" element of the datasource.
The datasource definition is not provided in the Quickstart article because it is embedded in the applications where needed. Note that my module name is different from the article too.
-
6. Re: How to add PostgreSql driver with pooled datasource in JBoss 7?
breakpoint Jun 21, 2013 4:05 AM (in response to sfcoy)What do you mean by embedded in the application?
-
7. Re: How to add PostgreSql driver with pooled datasource in JBoss 7?
sfcoy Jun 21, 2013 4:29 AM (in response to breakpoint)The sample apps sometimes contain a *-ds.xml file that defines the datasource.
I'm not sure why as I think we're trying discourage people from doing it that way.
-
8. Re: How to add PostgreSql driver with pooled datasource in JBoss 7?
sgilda Jun 24, 2013 3:00 PM (in response to sfcoy)The '*-ds.xml' files should only be used in a development environment. In a production environment, you need runtime management of your datasources, so you configure the datasources in the server configuration file using the management console or jboss-cli scripts.
The quickstarts are meant to be somewhat self-contained. They provide the '*-ds.xml' files for ease of use and demonstration purposes only.