MySQL Insert/Update custom table from plugin

Jonathan Kernan January 28, 2015

Hi there,

I have a non-JIRA table in the JIRA database and I'm trying to insert/update rows into this custom table through a custom plugin. I would use active objects but there is already populated with crucial data.

 I'm using the SQLProcessor class to run queries.  When I run SELECT statments I can get what I want but when I try to persist data to the table, a locking issue seems to appear. Is this the best way about inserting/updating rows in the custom table.

I've already initialised the sqlProcessor with 

sqlProcessor = new SQlProcessor("defaultDS");

private void executeUpdate(String sqlStmt) {
		try {
			sqlProcessor.prepareStatement(sqlStmt);
			sqlProcessor.executeUpdate();
		} catch (GenericEntityException ){
			e.printStackTrace();
		}
	}

An exception is not thrown but whenever I look at the database, the table has not been updated and when I manually run a query i get the following error:

“Lock wait timeout exceeded; try restarting transaction” 

JIRA seems to have a lock on the row/table and I then need to restart JIRA.

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Jonathan Kernan January 28, 2015

Adding the sqlProcessor.commit() did the trick. Can anyone explain why I need to have this? I thought the previous execute statement  was enough to persist the data.

private void executeUpdate(String sqlStmt) {
    try {
        sqlProcessor.prepareStatement(sqlStmt);
        sqlProcessor.executeUpdate();
		sqlProcessor.commit()
    } catch (GenericEntityException ){
        e.printStackTrace();
    }
}
TAGS
AUG Leaders

Atlassian Community Events