--- title: IDBDatabase.close slug: Web/API/IDBDatabase/close tags: - API - Database - IDBDatabase - IndexedDB - Method - Storage - close translation_of: Web/API/IDBDatabase/close --- <p>{{ APIRef("IDBDatabase") }}</p> <div> <p>{{domxref("IDBDatabase")}}インターフェイスの<code>close()は、</code>ただちに戻り、別スレッドで接続を閉じます。</p> </div> <p>実際には、この接続を使用していて生成されたすべてのトランザクションが完了するまで、接続は閉じられません。一度このメソッドが呼び出されたら、この接続では、新しいトランザクションを生成することはできません。終了処理がペンディングされている場合は、トランザクションを生成するメソッドは、例外を発生させます。</p> <h2 id="構文">構文</h2> <pre class="brush: js">db.close();</pre> <h3 id="戻り値">戻り値</h3> <p>Void。</p> <h2 id="例">例</h2> <pre class="brush: js;highlight:[16]">// Let us open our database var DBOpenRequest = window.indexedDB.open("toDoList", 4); // these two event handlers act on the database being opened successfully, or not DBOpenRequest.onerror = function(event) { note.innerHTML += '<li>Error loading database.</li>'; }; DBOpenRequest.onsuccess = function(event) { note.innerHTML += '<li>Database initialised.</li>'; // store the result of opening the database in the db variable. db = DBOpenRequest.result; // now let's close the database again! db.close(); }</pre> <h2 id="仕様">仕様</h2> <table class="standard-table"> <tbody> <tr> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> <tr> <td>{{SpecName('IndexedDB', '#widl-IDBDatabase-close-void', 'close()')}}</td> <td>{{Spec2('IndexedDB')}}</td> <td> </td> </tr> </tbody> </table> <h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザ実装状況</h2> <p>{{Compat("api.IDBDatabase.close")}}</p> <h2 id="関連項目">関連項目</h2> <ul> <li><a href="/ja/docs/Web/API/IndexedDB_API/Using_IndexedDB">Using IndexedDB</a></li> <li>Starting transactions: {{domxref("IDBDatabase")}}</li> <li>Using transactions: {{domxref("IDBTransaction")}}</li> <li>Setting a range of keys: {{domxref("IDBKeyRange")}}</li> <li>Retrieving and making changes to your data: {{domxref("IDBObjectStore")}}</li> <li>Using cursors: {{domxref("IDBCursor")}}</li> <li>Reference example: <a class="external" href="https://github.com/mdn/to-do-notifications/tree/gh-pages">To-do Notifications</a> (<a class="external" href="http://mdn.github.io/to-do-notifications/">view example live</a>.)</li> </ul>