{"action":"created","issue":{"url":"https://api.github.com/repos/SQLDroid/SQLDroid/issues/54","repository_url":"https://api.github.com/repos/SQLDroid/SQLDroid","labels_url":"https://api.github.com/repos/SQLDroid/SQLDroid/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/SQLDroid/SQLDroid/issues/54/comments","events_url":"https://api.github.com/repos/SQLDroid/SQLDroid/issues/54/events","html_url":"https://github.com/SQLDroid/SQLDroid/issues/54","id":136095257,"number":54,"title":"Please setAutoCommit(true) after commit or rollback","user":{"login":"jhannes","id":18310,"avatar_url":"https://avatars.githubusercontent.com/u/18310?v=3","gravatar_id":"","url":"https://api.github.com/users/jhannes","html_url":"https://github.com/jhannes","followers_url":"https://api.github.com/users/jhannes/followers","following_url":"https://api.github.com/users/jhannes/following{/other_user}","gists_url":"https://api.github.com/users/jhannes/gists{/gist_id}","starred_url":"https://api.github.com/users/jhannes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhannes/subscriptions","organizations_url":"https://api.github.com/users/jhannes/orgs","repos_url":"https://api.github.com/users/jhannes/repos","events_url":"https://api.github.com/users/jhannes/events{/privacy}","received_events_url":"https://api.github.com/users/jhannes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-24T15:34:50Z","updated_at":"2016-02-26T08:12:23Z","closed_at":null,"body":"When running transactions in separate threads, the connections are not released. The result is that all but the first thread will get messages like this:\r\n\r\n    02-24 10:29:24.614 13689-13724/XXXXX W/SQLiteConnectionPool: The connection pool for database '/data/data/XXXXX.db' has been unable to grant a connection to thread 323 (pool-1-thread-1) with flags 0x2 for 2430.154 seconds.\r\n                                                                           Connections: 0 active, 1 idle, 0 available.\r\n\r\n\r\nFor example - running this in more than one thread will result in the lock:\r\n\r\n        try (Connection connection = DriverManager.getConnection(jdbcUrl)) {\r\n            connection.setAutoCommit(false);\r\n            try (PreparedStatement stmt = connection.prepareStatement(\"insert into test_table (name) values (?)\")) {\r\n                stmt.setString(1, name);\r\n                stmt.executeUpdate();\r\n            }\r\n            System.err.println(\"Wrote data to database\");\r\n            try (PreparedStatement stmt = connection.prepareStatement(\"select * from test_table\")) {\r\n                try (ResultSet rs = stmt.executeQuery()) {\r\n                    while(rs.next()) {\r\n                        System.err.println(\"Database row: \" + rs.getString(\"name\"));\r\n                    }\r\n                }\r\n            }\r\n            connection.commit();\r\n            // Including the following will resolve the problem\r\n            //connection.setAutoCommit(true);\r\n        } catch (SQLException e) {\r\n            throw rethrowUnchecked(e);\r\n        }\r\n\r\nEven though this probably was my fault, I think this should be changed in SQLDroid to avoid this headache (I spend several hours chasing down the problem)!\r\n\r\nThanks for a great library in SQLDroid!\r\n"},"comment":{"url":"https://api.github.com/repos/SQLDroid/SQLDroid/issues/comments/189156666","html_url":"https://github.com/SQLDroid/SQLDroid/issues/54#issuecomment-189156666","issue_url":"https://api.github.com/repos/SQLDroid/SQLDroid/issues/54","id":189156666,"user":{"login":"jhannes","id":18310,"avatar_url":"https://avatars.githubusercontent.com/u/18310?v=3","gravatar_id":"","url":"https://api.github.com/users/jhannes","html_url":"https://github.com/jhannes","followers_url":"https://api.github.com/users/jhannes/followers","following_url":"https://api.github.com/users/jhannes/following{/other_user}","gists_url":"https://api.github.com/users/jhannes/gists{/gist_id}","starred_url":"https://api.github.com/users/jhannes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhannes/subscriptions","organizations_url":"https://api.github.com/users/jhannes/orgs","repos_url":"https://api.github.com/users/jhannes/repos","events_url":"https://api.github.com/users/jhannes/events{/privacy}","received_events_url":"https://api.github.com/users/jhannes/received_events","type":"User","site_admin":false},"created_at":"2016-02-26T08:12:23Z","updated_at":"2016-02-26T08:12:23Z","body":"I see your point. But I haven't seen any other database that run into the same lock problem before and I expect others may run into the same headache. Isolating the the the problem was extremely time consuming. \r\n\r\nAs an aside, I think the jdbc transaction model is very poorly designed."}}