Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to find out type of underlying database

Shailesh Shailesh February 27, 2012

I need to know the type of underlying database (not the actual connection object). So, far I could only find following way

String className = new DefaultOfBizConnectionFactory().getDatasourceInfo().getJdbcDatasource().getUri();

if(uri.indexOf("postgres"){

doSomething()

}

Is there a better way in JIRA 5?

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Sometimes it's needed, when you have raw sql and haven't yet moved to AO.

Personally I do it like this:

session.connection().getMetaData().getDatabaseProductName()

0 votes
Shailesh Shailesh February 28, 2012

I would hate to put any database specific code, but we are running into AO-296.

I found an alternative way do get the database metada

new SystemInfoUtilsImpl().getDatabaseType().

I dont like it as it fails in UT with NullPointerException.

0 votes
Samuel Le Berrigaud
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 28, 2012

I'm curious as to why you need to find the type of the database? One of the goal of Active Objects is actually to abstract the type of the database away.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events