2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
19 * @brief This is the header file for the %Database class.
21 * This header file contains the declarations of the %Database class.
24 #ifndef _FIO_DATABASE_H_
25 #define _FIO_DATABASE_H_
27 #include <FBaseObject.h>
28 #include <FBaseString.h>
29 #include <FBaseColArrayList.h>
30 #include <FBaseRtMutex.h>
32 namespace Tizen { namespace Base
37 namespace Tizen { namespace Io
45 * @brief This class provides the basic database and database entry management methods.
49 * @final This class is not intended for extension.
51 * The %Database class provides the basic database and database entry management methods.
52 * All members of this class are guaranteed to be thread-safe.
54 * For more information on the class features,
55 * see <a href="../org.tizen.native.appprogramming/html/guide/io/database_operations.htm">Database Operations</a>.
57 * @see Tizen::Io::DbStatement
58 * @see Tizen::Io::DbEnumerator
60 * The following example demonstrates how to use the %Database class.
66 using namespace Tizen::Io;
67 using namespace Tizen::App;
70 MyTest::UsingDatabase(void)
76 String sql, sql2, sql3;
81 dbName = App::GetInstance()->GetAppDataPath() + L"sample.db");
83 pDatabase = new Database();
89 r = pDatabase->Construct(dbName, "a+");
95 AppLog("Create database table:");
96 sql.Append(L"CREATE TABLE IF NOT EXISTS myTable1 ( column0 INTEGER PRIMARY KEY, column1 DOUBLE, column2 TEXT )");
98 r = pDatabase->ExecuteSql(sql, true);
104 AppLog("Insert rows:");
105 pDatabase->BeginTransaction();
107 statement.Append(L"INSERT INTO myTable1 (column0, column1, column2) VALUES (?, ?, ?)");
108 pStmt = pDatabase->CreateStatementN(statement);
110 stringItem.Append(L"Initial Data");
111 for (int i = 0; i < 10; i++)
113 pStmt->BindInt(0, i);
114 pStmt->BindDouble(1, i * 0.1);
115 pStmt->BindString(2, stringItem);
117 pEnum = pDatabase->ExecuteStatementN(*pStmt);
121 pDatabase->CommitTransaction();
125 AppLog("Select query using Database::QueryN() wrapper API:");
126 pEnum = pDatabase->QueryN(L"SELECT * FROM myTable1 WHERE column0 < 5");
133 while (pEnum->MoveNext() == E_SUCCESS)
135 r = pEnum->GetIntAt(0, iVal);
141 r = pEnum->GetDoubleAt(1, fVal);
147 r = pEnum->GetStringAt(2, strVal);
153 AppLog("[%d] column0=%d, column1=%f, column2=%ls", nRows++, iVal, fVal, strVal.GetPointer());
158 AppLog("Select query using statement:");
159 pStmt = pDatabase->CreateStatementN(L"SELECT * FROM myTable1 WHERE column0 > ? AND column0 < ?");
167 r = pStmt->BindInt(0, 3);
173 r = pStmt->BindInt(1, 8);
179 pEnum = pDatabase->ExecuteStatementN(*pStmt);
192 while (pEnum->MoveNext() == E_SUCCESS)
194 r = pEnum->GetIntAt(0, iVal);
200 r = pEnum->GetDoubleAt(1, fVal);
206 r = pEnum->GetStringAt(2, strVal);
212 AppLog("[%d] column0=%d, column1=%f, column2=%ls", nRows++, iVal, fVal, strVal.GetPointer());
217 AppLog("Delete rows:");
218 pDatabase->BeginTransaction();
220 sql2.Append(L"DELETE FROM myTable1 WHERE column0 = 1");
221 r = pDatabase->ExecuteSql(sql2, true);
228 pDatabase->CommitTransaction();
230 AppLog("Update rows:");
231 pDatabase->BeginTransaction();
233 sql3.Append(L"UPDATE myTable1 SET column2 = 'Converted Data' WHERE column2 = 'Initial Data'");
234 r = pDatabase->ExecuteSql(sql3, true);
241 pDatabase->CommitTransaction();
247 r = Database::Delete(dbName);
253 AppLog("Finished successfully...");
263 if (Database::Exists(dbName))
265 Database::Delete(dbName);
273 class _OSP_EXPORT_ Database
274 : public Tizen::Base::Object
279 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
286 * This destructor overrides Tizen::Base::Object::~Object().
290 virtual ~Database(void);
294 * Initializes this instance of %Database with the specified parameters. @n
295 * This method creates a new database file or opens an existing database file in the read-write mode.
298 * @brief <i> [Deprecated] [Compatibility] </i>
300 * @deprecated This method is deprecated. Instead of using this method, use Directory::Create(const Tizen::Base::String &dirPath,
301 * bool createParentDirectories=false) and Database::Construct(const Tizen::Base::String& dbPath, const Tizen::Base::String& openMode).
304 * @compatibility This method has compatibility issues with OSP compatible applications. @n
305 * For more information, see @ref CompIoPathPage "here".
308 * @return An error code
309 * @param[in] dbPath The path of the database file to open
310 * @param[in] createIfNotExist Set to @c true to create a database file, @n
311 * else @c false to open an existing database file
312 * @exception E_SUCCESS The method is successful.
313 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
314 * - The length of the specified @c dbPath is invalid. @n
315 * - The specified @c dbPath is invalid or the path ends with '/'. @n
316 * - The directory name path is missing. @n
317 * - The parent directory does not exist. @n
318 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
319 * @exception E_FILE_ALREADY_EXIST The specified database file already exists. @n
320 * Creation of database file has failed because the destination file already exists. @n
321 * Creation of the database file is attempted if the file does not exist and
322 * the specified @c createIfNotExist is @c true.
323 * However, at this moment another thread has been already created the database file
324 * with the same file path.
325 * This is a rare case, however, it is possible if a race condition is present between several threads.
326 * @exception E_FILE_NOT_FOUND The specified database file cannot be found or accessed.
327 * @exception E_DATABASE Either of the following conditions has occurred: @n
328 * - The method has failed to open or create a file. @n
329 * - An unexpected device failure has occurred as the media ejected suddenly. @n
330 * - %File corruption is detected.
331 * @remarks To open the database file in the read-only mode,
332 * use the Database::Construct(const Tizen::Base::String& dbPath, const char* pOpenMode) method
333 * with "r" as the value for the open mode flag.
336 result Construct(const Tizen::Base::String& dbPath, bool createIfNotExist);
340 * Initializes this instance of %Database with the specified parameters. @n
341 * This method creates a new database file or opens an existing database file in the read-only or the read-write mode.
344 * @brief <i> [Deprecated] [Compatibility] </i>
346 * @deprecated This method is deprecated. Instead of using this method, use Directory::Create(const Tizen::Base::String &dirPath,
347 * bool createParentDirectories=false) and Database::Construct(const Tizen::Base::String& dbPath, const Tizen::Base::String& openMode).
350 * @compatibility This method has compatibility issues with OSP compatible applications. @n
351 * For more information, see @ref CompIoPathPage "here".
354 * @return An error code
355 * @param[in] dbPath The path of the database file to open
356 * @param[in] openMode An open mode flag @n
357 * Currently, the following flags can be used in combination with the logical OR operator: @n
358 * (1) DB_OPEN_READ_ONLY @n
359 * (2) DB_OPEN_READ_WRITE @n
360 * (3) DB_OPEN_READ_WRITE | DB_OPEN_CREATE
361 * @param[in] option This argument is reserved for further use
362 * @exception E_SUCCESS The method is successful.
363 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
364 * - The length of the specified @c dbPath is invalid. @n
365 * - The specified @c openMode is invalid. @n
366 * - The specified @c dbPath is invalid or the path ends with '/'. @n
367 * - The directory name path is missing. @n
368 * - The parent directory does not exist. @n
369 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
370 * @exception E_FILE_ALREADY_EXIST The specified database file already exists.
371 * @exception E_FILE_NOT_FOUND The specified database file cannot be found or accessed.
372 * @exception E_DATABASE Either of the following conditions has occurred: @n
373 * - The method has failed to open or create a file. @n
374 * - An unexpected device failure has occurred as the media ejected suddenly. @n
375 * - %File corruption is detected.
378 result Construct(const Tizen::Base::String& dbPath, long openMode, long option);
381 * Initializes this instance of %Database with the specified parameters. @n
382 * This method opens an existing database file or creates a new database file according to the specified file opening mode.
386 * @return An error code
387 * @param[in] dbPath The path of the database file to open or create
388 * @param[in] pOpenMode The file opening mode @n
389 * It can be one of the following:
390 * - r : Open for reading.
391 * - r+: Open for reading and writing.
392 * - a+: Open for writing and reading. The database file is created if it does not exist.
393 * @exception E_SUCCESS The method is successful.
394 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
395 * - The overall length of the specified @c dbPath is equal to @c 0 or
396 * exceeds system limitations. @n
397 * - The specified @c dbPath ends with '/'. @n
398 * - The combination of the specified @c pOpenMode is not allowed. @n
399 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
400 * @exception E_FILE_NOT_FOUND The specified @c dbPath cannot be found.
401 * @exception E_INVALID_FORMAT The specified @c dbPath is not a database.
402 * @exception E_STORAGE_FULL The disk space is full.
403 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
404 * @exception E_IO Either of the following conditions has occurred: @n
405 * - An unexpected device failure has occurred as the media ejected suddenly. @n
406 * - %File corruption is detected. @n
408 result Construct(const Tizen::Base::String& dbPath, const char* pOpenMode);
411 * Initializes this instance of %Database with the specified parameters. @n
412 * This method opens an existing secure database file or creates a new one according to the specified file opening mode.
413 * The contents written to the secure database file is automatically encrypted and the contents read from the secure database
414 * file is automatically decrypted by the platform. @n
415 * Applications using this method can access the same secure database files that are created by other applications with the
416 * identical key value in same device. However, the secure files created by this method cannot be accessed in other devices.
419 * @feature %http://tizen.org/feature/database.encryption
421 * @return An error code
422 * @param[in] dbPath The path of the database file to open or create
423 * @param[in] pOpenMode The file opening mode @n
424 * It can be one of the following: @n
425 * - r : Open for reading @n
426 * - r+: Open for reading and writing @n
427 * - a+: Open for writing and reading. The database file is created if it does not exist. @n
428 * @param[in] secretKey A key used to encrypt data of a database file or decrypt a secure database file @n
429 * If a secure database file is created with a specific key value,
430 * other applications can access the same secure database file with the identical key value.
431 * @exception E_SUCCESS The method is successful.
432 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
433 * - The overall length of the specified @c dbPath is equal to @c 0 or
434 * exceeds system limitations. @n
435 * - The specified @c dbPath ends with '/'. @n
436 * - The combination of the specified @c pOpenMode is not allowed. @n
437 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
438 * @exception E_FILE_NOT_FOUND The specified @c dbPath cannot be found.
439 * @exception E_INVALID_FORMAT The specified @c dbPath is not a database.
440 * @exception E_STORAGE_FULL The disk space is full.
441 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
442 * @exception E_IO Either of the following conditions has occurred: @n
443 * - An unexpected device failure has occurred as the media ejected suddenly. @n
444 * - %File corruption is detected. @n
445 * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature. For more information, see
446 * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">Application Filtering</a>.
447 * @remarks Before calling this method, check whether the feature is supported by Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
449 result Construct(const Tizen::Base::String& dbPath, const char* pOpenMode, const Tizen::Base::ByteBuffer& secretKey);
452 * Creates a SQL statement for the current database.
455 * @brief <i> [Compatibility] </i>
459 * @compatibility This method has compatibility issues with OSP compatible applications. @n
460 * For more information, see @ref CompDatabaseExceptionPage "here".
463 * @return A pointer to the DbStatement instance, @n
464 * else @c null if an exception occurs
465 * @param[in] sqlStatement The SQL statement to compile
466 * @exception E_SUCCESS The method is successful.
467 * @exception E_INVALID_ARG The specified @c sqlStatement is invalid SQL.
468 * @exception E_OBJECT_LOCKED The database instance is locked.
469 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
470 * @remarks The specific error code can be accessed using the GetLastResult() method.
471 * @see ExecuteStatementN()
473 DbStatement* CreateStatementN(const Tizen::Base::String& sqlStatement);
476 * Executes a statement in the calling %Database instance. @n
477 * If an application opens a database file using Database::Construct(const Tizen::Base::String& dbPath,
478 * const char* pOpenMode, const Tizen::Base::ByteBuffer& secretKey),
479 * the data set written by INSERT/UPDATE is automatically encrypted by the Tizen platform and
480 * the data set read by SELECT is also decrypted by itself.
483 * @brief <i> [Compatibility] </i>
487 * @compatibility This method has compatibility issues with OSP compatible applications. @n
488 * For more information, see @ref CompDatabaseExceptionPage "here".
491 * @return A pointer to the DbEnumerator instance, @n
492 * else @c null if an exception occurs, if no result set is generated after the successful execution of the
493 * SELECT query, or if one of INSERT, UPDATE, and DELETE queries is executed.
494 * @param[in] dbStatement The DbStatement instance to execute
495 * @exception E_SUCCESS The method is successful.
496 * @exception E_INVALID_ARG The specified @c dbStatement includes invalid SQL.
497 * @exception E_OBJECT_LOCKED The database instance is locked.
498 * @exception E_INVALID_FORMAT The database file is malformed.
499 * @exception E_STORAGE_FULL The disk space or database image is full.
500 * @exception E_IO Either of the following conditions has occurred: @n
501 * - An unexpected device failure has occurred as the media ejected suddenly. @n
502 * - %File corruption is detected.
503 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
504 * @remarks If @c dbStatement contains the SELECT query, the Reset() method of the DbEnumerator instance returned
505 * from this method should be called. The Reset() method should be called before re-binding the dbStatement
506 * with the bind methods of the DbStatement class.
507 * This method returns an enumerator if the result set is generated by the SELECT query.
508 * @c null is returned if no result set is available after the successful execution of the SELECT query.
509 * Note that, a return value of @c null does not mean that the statement execution has failed.
510 * The enumerator returned by the SELECT query does not indicate any row before it calls DbEnumerator::MoveNext().
511 * The specific error code can be accessed using the GetLastResult() method.
513 DbEnumerator* ExecuteStatementN(const DbStatement& dbStatement);
516 * Executes SQL statement in this %Database instance. @n
517 * Any SQL statement that does not give a result set can be run using this method; for example, CREATE, INSERT, UPDATE, DELETE.
518 * The SELECT query cannot be executed using this method. @n
519 * If an application opens a database file using Database::Construct(const Tizen::Base::String& dbPath,
520 * const char* pOpenMode, const Tizen::Base::ByteBuffer& key),
521 * the data set written by INSERT/UPDATE is automatically encrypted by the Tizen platform.
524 * @brief <i> [Compatibility] </i>
528 * @compatibility This method has compatibility issues with OSP compatible applications. @n
529 * For more information, see @ref CompDatabaseExceptionPage "here".
532 * @return An error code
533 * @param[in] sqlStatement The SQL statement to execute
534 * @param[in] option This argument is reserved for further use.
535 * @exception E_SUCCESS The method is successful.
536 * @exception E_INVALID_ARG The specified @c sqlStatement is invalid SQL.
537 * @exception E_INVALID_OPERATION The specified @c sqlStatement is a SELECT query.
538 * @exception E_OBJECT_LOCKED The database instance is locked.
539 * @exception E_INVALID_FORMAT The database file is malformed.
540 * @exception E_STORAGE_FULL The disk space or database image is full.
541 * @exception E_IO Either of the following conditions has occurred: @n
542 * - An unexpected device failure has occurred as the media ejected suddenly. @n
543 * - %File corruption is detected.
544 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
545 * @remarks Use QueryN() to execute SELECT query.
548 result ExecuteSql(const Tizen::Base::String& sqlStatement, bool option);
551 * Executes a SELECT query in the calling %Database instance. @n
552 * If an application opens a database file using Database::Construct(const Tizen::Base::String& dbPath,
553 * const char* pOpenMode, const Tizen::Base::ByteBuffer& key),
554 * the data set read by SELECT is automatically decrypted by the Tizen platform.
557 * @brief <i> [Compatibility] </i>
561 * @compatibility This method has compatibility issues with OSP compatible applications. @n
562 * For more information, see @ref CompDatabaseExceptionPage "here".
565 * @return A pointer to the %DbEnumerator instance, @n
566 * else @c null if an exception occurs or if no result set is generated after the successful execution of the SELECT query
567 * @param[in] sqlStatement The SQL statement to execute
568 * @exception E_SUCCESS The method is successful.
569 * @exception E_INVALID_ARG The specified @c sqlStatement is invalid SQL.
570 * @exception E_INVALID_OPERATION The specified @c sqlStatement is not a SELECT query.
571 * @exception E_OBJECT_LOCKED The database instance is locked.
572 * @exception E_INVALID_FORMAT The database file is malformed.
573 * @exception E_IO Either of the following conditions has occurred: @n
574 * - An unexpected device failure has occurred as the media ejected suddenly. @n
575 * - %File corruption is detected.
576 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
577 * @remarks This method returns an enumerator if the result set is generated by the SELECT query.
578 * @c null is returned if no result set is available after the successful execution of the SELECT query.
579 * Note that, a return value of @c null does not mean that the statement execution has failed.
580 * The enumerator returned by the SELECT query does not indicate any row before it calls
581 * DbEnumerator::MoveNext().
582 * The specific error code can be accessed using the GetLastResult() method.
585 DbEnumerator* QueryN(const Tizen::Base::String& sqlStatement);
588 * Begins a transaction within this %Database instance.
591 * @brief <i> [Compatibility] </i>
595 * @compatibility This method has compatibility issues with OSP compatible applications. @n
596 * For more information, see @ref CompDatabaseExceptionPage "here".
599 * @return An error code
600 * @exception E_SUCCESS The method is successful.
601 * @exception E_INVALID_STATE The transaction has already begun.
602 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
603 * @see CommitTransaction()
604 * @see RollbackTransaction()
606 result BeginTransaction(void);
609 * Commits a transaction within this %Database instance.
612 * @brief <i> [Compatibility] </i>
616 * @compatibility This method has compatibility issues with OSP compatible applications. @n
617 * For more information, see @ref CompDatabaseExceptionPage "here".
620 * @return An error code
621 * @exception E_SUCCESS The method is successful.
622 * @exception E_INVALID_STATE The transaction mode is not activated.
623 * @exception E_OBJECT_LOCKED The database instance is locked.
624 * @exception E_INVALID_FORMAT The database file is malformed.
625 * @exception E_STORAGE_FULL The disk space or database image is full.
626 * @exception E_IO Either of the following conditions has occurred: @n
627 * - An unexpected device failure has occurred as the media ejected suddenly. @n
628 * - %File corruption is detected.
629 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
630 * @remarks Database::CommitTransaction() automatically resets not only all the DbStatement instances
631 * but also all the DbEnumerator instances obtained from the current %Database instance.
632 * As a result, the prepared statement of the %DbStatement instances are reset to its initial state, ready to be re-executed,
633 * and enumerator of the %DbEnumerator instances are reset to the first position.
634 * Therefore, the user should be careful when the same instance of the %Database class is shared across multiple threads.
635 * Further, access to the %DbStatement or %DbEnumerator instances resets due to commit operation. This will eventually lead to crash.
636 * To avoid a crash, the user can use multiple database instances for each thread.
637 * Sharing of the same database instance across multiple threads is not recommended.
638 * @see BeginTransaction()
639 * @see RollbackTransaction()
641 result CommitTransaction(void);
644 * Aborts a running transaction within this %Database instance.
647 * @brief <i> [Compatibility] </i>
651 * @compatibility This method has compatibility issues with OSP compatible applications. @n
652 * For more information, see @ref CompDatabaseExceptionPage "here".
655 * @return An error code
656 * @exception E_SUCCESS The method is successful.
657 * @exception E_INVALID_STATE The transaction mode is not activated.
658 * @exception E_OBJECT_LOCKED The database instance is locked.
659 * @exception E_INVALID_FORMAT The database file is malformed.
660 * @exception E_STORAGE_FULL The disk space or database image is full.
661 * @exception E_IO Either of the following conditions has occurred: @n
662 * - An unexpected device failure has occurred as the media ejected suddenly. @n
663 * - %File corruption is detected.
664 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
665 * @see BeginTransaction()
666 * @see CommitTransaction()
668 result RollbackTransaction(void);
671 * Gets the database's filename.
675 * @return The filename of this %Database instance
677 Tizen::Base::String GetName(void) const;
680 * Deletes the database file with the specified file name.
683 * @brief <i> [Compatibility] </i>
687 * @compatibility This method has compatibility issues with OSP compatible applications. @n
688 * For more information, see @ref CompIoPathPage "here".
691 * @return An error code
692 * @param[in] databasePath The path of the database file to delete
693 * @exception E_SUCCESS The method is successful.
694 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
695 * - The length of the specified @c databasePath is invalid. @n
696 * - The specified @c databasePath parameter contains an invalid path or
697 * the path ends with '/'. @n
698 * - The directory name path is missing. @n
699 * - The parent directory does not exist. @n
700 * - An I/O security issue.
701 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
702 * @exception E_FILE_NOT_FOUND The specified database file cannot be found.
703 * @exception E_IO Either of the following conditions has occurred: @n
704 * - An unexpected device failure has occurred as the media ejected suddenly. @n
705 * - %File corruption is detected. @n
706 * - A system error has occurred.
708 static result Delete(const Tizen::Base::String& databasePath);
711 * Checks whether the database file exists.
714 * @brief <i> [Compatibility] </i>
718 * @compatibility This method has compatibility issues with OSP compatible applications. @n
719 * For more information, see @ref CompIoPathPage "here".
722 * @return @c true if the database file exists, @n
724 * @param[in] databasePath The path of the database file to check
725 * @exception E_SUCCESS The method is successful.
726 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
727 * - The length of the specified @c databasePath is invalid. @n
728 * - The specified @c databasePath parameter contains an invalid path or
729 * the path ends with '/'. @n
730 * - The directory name path is missing. @n
731 * - The parent directory does not exist. @n
732 * - An I/O security issue.
733 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
734 * @remarks The specific error code can be accessed using the GetLastResult() method.
736 static bool Exists(const Tizen::Base::String& databasePath);
739 * Converts a normal database file to a secure database file. @n
740 * A secure database file, that is converted by this method, can be shared among applications with the same key value.
743 * @brief <i> [Compatibility] </i>
747 * @compatibility This method has compatibility issues with OSP compatible applications. @n
748 * For path compatibility, see @ref CompIoPathPage "here".
749 * For exception compatibility, see @ref CompDatabaseExceptionPage "here".
751 * @feature %http://tizen.org/feature/database.encryption
753 * @return An error code
754 * @param[in] normalDbPath The normal (non-encrypted) database file path
755 * @param[in] secureDbPath The secure (encrypted) database file path to create
756 * @param[in] secretKey A key to encrypt normal database file @n
757 * If the normal database file is converted with a specific key value,
758 * applications can access the same secure database file with the identical key value.
759 * @exception E_SUCCESS The method is successful.
760 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
761 * - The length of the specified path is @c 0 or exceeds system limitations. @n
762 * - The specified path is invalid. @n
763 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
764 * @exception E_FILE_NOT_FOUND The specified @c normalDbPath does not exist.
765 * @exception E_FILE_ALREADY_EXIST The specified @c secureDbPath already exists.
766 * @exception E_OBJECT_LOCKED The database instance is locked.
767 * @exception E_INVALID_FORMAlT The database file is malformed.
768 * @exception E_STORAGE_FULL The disk space or database image is full.
769 * @exception E_IO Either of the following conditions has occurred: @n
770 * - An unexpected device failure has occurred as the media ejected suddenly. @n
771 * - %File corruption is detected.
772 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
773 * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature. For more information, see
774 * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">Application Filtering</a>.
775 * @remarks Before calling this method, check whether the feature is supported by Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
777 static result ConvertToSecureDatabase(const Tizen::Base::String& normalDbPath, const Tizen::Base::String& secureDbPath,
778 const Tizen::Base::ByteBuffer& secretKey);
781 * Gets the last inserted row ID.
785 * @return Row ID of the most recent successful insert, @n
786 * else @c -1 if no successful INSERT operations have ever occurred on
787 * the current opened database.
788 * @remarks The row ID is always available as an undeclared column named ROWID, OID, or _ROWID_
789 * as long as those names are not also used by explicitly declared columns.
790 * If the table has a column of type INTEGER PRIMARY KEY then that column is another alias
792 * This method returns the row ID of the most recent successful INSERT operation
793 * for current %Database.
795 long long GetLastInsertRowId(void) const;
799 * @page CompDatabaseExceptionPage Compatibility for E_DATABASE exception
800 * @section CompDatabaseExceptionPageIssueSection Issues
801 * Implementing this method in OSP compatible applications has the following issues: @n
803 * -# E_DATABASE exception includes many errors from underlying database engine.
804 * -# If database is locked, E_SERVICE_BUSY is returned.
806 * @section CompDatabaseExceptionPageSolutionSection Resolutions
807 * The issue mentioned above is resolved in Tizen. @n
809 * @par When working in Tizen:
810 * -# E_DATABASE exception is divided into several exceptions. Refer to exception description of API reference.
811 * -# E_SERVICE_BUSY is changed to E_OBJECT_LOCKED.
818 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
822 Database(const Database& rhs);
825 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
828 Database& operator =(const Database& rhs);
831 * The implementation of this method is intentionally blank and declared as private to prohibit implicit conversion.
835 result Construct(const Tizen::Base::String& dbPath, const wchar_t* pOpenMode);
837 class _DatabaseImpl* __pDatabaseImpl;
839 friend class _DatabaseImpl;
845 #endif //_FIO_DATABASE_H_