Missed Team ’24? Catch up on announcements here.

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

Do I have to close the connection that I got via new DefaultOfBizConnectionFactory().getConnection()?

Nabil Sayegh
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 18, 2013

Hi,

my calculated custom field needs to query the database and therefore gets a database connection via DefaultOfBizConnectionFactory().getConnection(). Do I have to close that connection explicitly and the end of my plugin's method?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Nabil Sayegh
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.
April 7, 2013

If I close the Connection explicitly, I get the following errors, so I assume you must not close the connection:

java.lang.IllegalStateException: The OpTimer has been re-used.  end() can only be called once!
	at com.atlassian.instrumentation.operations.SimpleOpTimer.end(SimpleOpTimer.java:142)
	at com.atlassian.instrumentation.operations.SimpleOpTimer.end(SimpleOpTimer.java:99)
	at com.atlassian.instrumentation.operations.SimpleOpTimer.end(SimpleOpTimer.java:117)
	at com.atlassian.jira.ofbiz.InstrumentedSQLInterceptor.onConnectionReplaced(InstrumentedSQLInterceptor.java:38)
	at com.atlassian.jira.ofbiz.ChainedSQLInterceptor.onConnectionReplaced(ChainedSQLInterceptor.java:75)
	at org.ofbiz.core.entity.jdbc.interceptors.connection.ConnectionTracker$ConnectionWithSQLInterceptorImpl.close(ConnectionTracker.java:96)
	at com.example.jira.customfields.SprintField.close(SprintField.java:106)
...

Closing the ResultSet and Statement should be done nevertheless.

0 votes
reyes hernandez January 12, 2016

We have the same problem. Do you finally find the correct way to do it?

 

Nabil Sayegh
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.
January 13, 2016

IIRC, we only closed the ResultSet and the Statement.

TAGS
AUG Leaders

Atlassian Community Events