JBoss 7.x : Retrieve Datasource properties ( username, database name, password) at runtime, using JMX

Introduction

Working with database connections, on enterprise application servers like JBoss, is in 99.9% very simple and well standardized. After configuring your environment, you can use JPA in order to handle all database interactions. In that way, you do not need to create any database connections or bother what is the name of: database, username/password as well as datasource name. However, there is this 0.1% of cases in which your application is extraordinary (been there ;-) ) and you need to have some more information and control over your database connections. If you do, in this post you will find how to retrieve properties describing predefined Datasources and will also get idea how to call mbeans methods or get other attributes.

If you just need a list of available datasources, without their properties, you can read this post: list available datasources on JBoss 7. 
If you work on JBoss 6, then follow this article: Datasource Properties on JBoss 6.x

Read more of this post

Advertisements

Free JBoss/Tomcat hosting on OpenShift

Introduction

Lately I was looking for free hosting on application servers such as JBoss or Tomcat. I have found some options, among wich I have decided to try OpenShift and I am really happy with it. If you are looking for a place where you can test out your project or show it to the public ( student project, open source project, enterprise examples ) it could be nice solution.

Read more of this post

JBoss 7: Retrieve list of configured datasources at runtime

Introduction

Working with database connections on enterprise application servers like JBoss is in 99.9% very simple and well standardized. After configuring your environment, you can use JPA in order to handle all database interactions. In that way, during coding, you do not need to create any database connections or bother what is the name of database as well as datasource name. However, there is this 0.1% of cases in which your application is extraordinary (been there ;-) ) and you need to have some more information and control over your database connections. If you do, in this post you will find how to retrieve a list of available datasources.
Read more of this post

JBoss 6.x : Retrieve Datasource properties ( username, database name, password) at runtime, using JMX

Introduction

Working with database connections on enterprise application servers like JBoss is in 99.9% very simple and well standardized. After configuring your environment, you can use JPA in order to handle all database interactions. In that way, you do not need to create any database connections or bother what is the name of: database, username/password as well as datasource name. However, there is this 0.1% of cases in which your application is extraordinary (been there ;-) ) and you need to have some more information and control over your database connections. If you do, in this post you will find how to retrieve properties describing predefined Datasources.

If you just need a list of available datasources, without their properties, you can read this post: list available datasources on JBoss 6.

Read more of this post

JBoss 6 : Retrieve list of configured datasources at runtime

Introduction

Working with database connections on enterprise application servers like JBoss is in 99.9% very simple and well standardized. What one needs to do is:

  1. Configure datasources (*-DS.xml files)
  2. Configure persistence units in persistence.xml file
  3. Use dependency injection (@PersistenceContext(unitName=”pUnit”)) in order to obtain EntityManager

, and voilà: you are ready to work with defined databases. In your code you do not need to create any database connections or bother what is the name of database, username/password as well as datasource name. However, there is this 0.1% of cases in which your application is  extraordinary (been there 😉 ) and you need to have some more information and control over db-layers or you just simply need it for some reason I cannot even imagine 🙂 If you do, in this post you will find how to retrieve a list of available datasources.

Read more of this post