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.
Community moderators have prevented the ability to post new answers.
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(); } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.