{"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":3,"created_at":"2016-02-24T15:34:50Z","updated_at":"2016-03-17T15:23:29Z","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/197930419","html_url":"https://github.com/SQLDroid/SQLDroid/issues/54#issuecomment-197930419","issue_url":"https://api.github.com/repos/SQLDroid/SQLDroid/issues/54","id":197930419,"user":{"login":"Dunemaster","id":6681790,"avatar_url":"https://avatars.githubusercontent.com/u/6681790?v=3","gravatar_id":"","url":"https://api.github.com/users/Dunemaster","html_url":"https://github.com/Dunemaster","followers_url":"https://api.github.com/users/Dunemaster/followers","following_url":"https://api.github.com/users/Dunemaster/following{/other_user}","gists_url":"https://api.github.com/users/Dunemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/Dunemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dunemaster/subscriptions","organizations_url":"https://api.github.com/users/Dunemaster/orgs","repos_url":"https://api.github.com/users/Dunemaster/repos","events_url":"https://api.github.com/users/Dunemaster/events{/privacy}","received_events_url":"https://api.github.com/users/Dunemaster/received_events","type":"User","site_admin":false},"created_at":"2016-03-17T15:23:28Z","updated_at":"2016-03-17T15:23:28Z","body":"There is another issue with autocommit mode.\r\nIf autocommit is set to false, connections are not released from android sqllite connection pool even when the JDBC connection is properly closed. \r\n\r\nIn logcat there are messages like this: \r\n**The connection pool for /data/data/dev.xx.xx/databases/XX has been closed but there are still 1 connections in use.  They will be closed as they are released back to the pool. "}}