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);
295 * Initializes this instance of %Database with the specified parameters. @n
296 * This method creates a new database file or opens an existing database file in the read-write mode.
299 * @brief <i> [Deprecated] [Compatibility] </i>
301 * @deprecated This method is deprecated. Instead of using this method, use Directory::Create(const Tizen::Base::String &dirPath,
302 * bool createParentDirectories=false) and Database::Construct(const Tizen::Base::String& dbPath, const Tizen::Base::String& openMode).
305 * @compatibility This method has compatibility issues with OSP compatible applications. @n
306 * For more information, see @ref CompIoPathPage "here".
309 * @return An error code
310 * @param[in] dbPath The path of the database file to open
311 * @param[in] createIfNotExist Set to @c true to create a database file, @n
312 * else @c false to open an existing database file
313 * @exception E_SUCCESS The method is successful.
314 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
315 * - The length of the specified @c dbPath is invalid. @n
316 * - The specified @c dbPath is invalid or the path ends with '/'. @n
317 * - The directory name path is missing. @n
318 * - The parent directory does not exist. @n
319 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
320 * @exception E_FILE_ALREADY_EXIST The specified database file already exists. @n
321 * Creation of database file has failed because the destination file already exists. @n
322 * Creation of the database file is attempted if the file does not exist and
323 * the specified @c createIfNotExist is @c true.
324 * However, at this moment another thread has been already created the database file
325 * with the same file path.
326 * This is a rare case, however, it is possible if a race condition is present between several threads.
327 * @exception E_FILE_NOT_FOUND The specified database file cannot be found or accessed.
328 * @exception E_DATABASE Either of the following conditions has occurred: @n
329 * - The method has failed to open or create a file. @n
330 * - An unexpected device failure has occurred as the media ejected suddenly. @n
331 * - %File corruption is detected.
332 * @remarks To open the database file in the read-only mode,
333 * use the Database::Construct(const Tizen::Base::String& dbPath, const char* pOpenMode) method
334 * with "r" as the value for the open mode flag.
338 result Construct(const Tizen::Base::String& dbPath, bool createIfNotExist);
343 * Initializes this instance of %Database with the specified parameters. @n
344 * This method creates a new database file or opens an existing database file in the read-only or the read-write mode.
347 * @brief <i> [Deprecated] [Compatibility] </i>
349 * @deprecated This method is deprecated. Instead of using this method, use Directory::Create(const Tizen::Base::String &dirPath,
350 * bool createParentDirectories=false) and Database::Construct(const Tizen::Base::String& dbPath, const Tizen::Base::String& openMode).
353 * @compatibility This method has compatibility issues with OSP compatible applications. @n
354 * For more information, see @ref CompIoPathPage "here".
357 * @return An error code
358 * @param[in] dbPath The path of the database file to open
359 * @param[in] openMode An open mode flag @n
360 * Currently, the following flags can be used in combination with the logical OR operator: @n
361 * (1) DB_OPEN_READ_ONLY @n
362 * (2) DB_OPEN_READ_WRITE @n
363 * (3) DB_OPEN_READ_WRITE | DB_OPEN_CREATE
364 * @param[in] option This argument is reserved for further use
365 * @exception E_SUCCESS The method is successful.
366 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
367 * - The length of the specified @c dbPath is invalid. @n
368 * - The specified @c openMode is invalid. @n
369 * - The specified @c dbPath is invalid or the path ends with '/'. @n
370 * - The directory name path is missing. @n
371 * - The parent directory does not exist. @n
372 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
373 * @exception E_FILE_ALREADY_EXIST The specified database file already exists.
374 * @exception E_FILE_NOT_FOUND The specified database file cannot be found or accessed.
375 * @exception E_DATABASE Either of the following conditions has occurred: @n
376 * - The method has failed to open or create a file. @n
377 * - An unexpected device failure has occurred as the media ejected suddenly. @n
378 * - %File corruption is detected.
382 result Construct(const Tizen::Base::String& dbPath, long openMode, long option);
385 * Initializes this instance of %Database with the specified parameters. @n
386 * This method opens an existing database file or creates a new database file according to the specified file opening mode.
390 * @return An error code
391 * @param[in] dbPath The path of the database file to open or create
392 * @param[in] pOpenMode The file opening mode @n
393 * It can be one of the following:
394 * - r : Open for reading.
395 * - r+: Open for reading and writing.
396 * - a+: Open for writing and reading. The database file is created if it does not exist.
397 * @exception E_SUCCESS The method is successful.
398 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
399 * - The overall length of the specified @c dbPath is equal to @c 0 or
400 * exceeds system limitations. @n
401 * - The specified @c dbPath ends with '/'. @n
402 * - The combination of the specified @c pOpenMode is not allowed. @n
403 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
404 * @exception E_FILE_NOT_FOUND The specified @c dbPath cannot be found.
405 * @exception E_INVALID_FORMAT The specified @c dbPath is not a database.
406 * @exception E_STORAGE_FULL The disk space is full.
407 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
408 * @exception E_IO Either of the following conditions has occurred: @n
409 * - An unexpected device failure has occurred as the media ejected suddenly. @n
410 * - %File corruption is detected. @n
412 result Construct(const Tizen::Base::String& dbPath, const char* pOpenMode);
415 * Initializes this instance of %Database with the specified parameters. @n
416 * This method opens an existing secure database file or creates a new one according to the specified file opening mode.
417 * The contents written to the secure database file is automatically encrypted and the contents read from the secure database
418 * file is automatically decrypted by the platform. @n
419 * Applications using this method can access the same secure database files that are created by other applications with the
420 * identical key value in same device. However, the secure files created by this method cannot be accessed in other devices.
423 * @feature %http://tizen.org/feature/database.encryption
425 * @return An error code
426 * @param[in] dbPath The path of the database file to open or create
427 * @param[in] pOpenMode The file opening mode @n
428 * It can be one of the following: @n
429 * - r : Open for reading @n
430 * - r+: Open for reading and writing @n
431 * - a+: Open for writing and reading. The database file is created if it does not exist. @n
432 * @param[in] secretKey A key used to encrypt data of a database file or decrypt a secure database file @n
433 * If a secure database file is created with a specific key value,
434 * other applications can access the same secure database file with the identical key value.
435 * @exception E_SUCCESS The method is successful.
436 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
437 * - The overall length of the specified @c dbPath is equal to @c 0 or
438 * exceeds system limitations. @n
439 * - The specified @c dbPath ends with '/'. @n
440 * - The combination of the specified @c pOpenMode is not allowed. @n
441 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
442 * @exception E_FILE_NOT_FOUND The specified @c dbPath cannot be found.
443 * @exception E_INVALID_FORMAT The specified @c dbPath is not a database.
444 * @exception E_STORAGE_FULL The disk space is full.
445 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
446 * @exception E_IO Either of the following conditions has occurred: @n
447 * - An unexpected device failure has occurred as the media ejected suddenly. @n
448 * - %File corruption is detected. @n
449 * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature. For more information, see
450 * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">Application Filtering</a>.
451 * @remarks Before calling this method, check whether the feature is supported by Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
453 result Construct(const Tizen::Base::String& dbPath, const char* pOpenMode, const Tizen::Base::ByteBuffer& secretKey);
456 * Creates a SQL statement for the current database.
459 * @brief <i> [Compatibility] </i>
463 * @compatibility This method has compatibility issues with OSP compatible applications. @n
464 * For more information, see @ref CompDatabaseExceptionPage "here".
467 * @return A pointer to the DbStatement instance, @n
468 * else @c null if an exception occurs
469 * @param[in] sqlStatement The SQL statement to compile
470 * @exception E_SUCCESS The method is successful.
471 * @exception E_INVALID_ARG The specified @c sqlStatement is invalid SQL.
472 * @exception E_OBJECT_LOCKED The database instance is locked.
473 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
474 * @remarks The specific error code can be accessed using the GetLastResult() method.
475 * @see ExecuteStatementN()
477 DbStatement* CreateStatementN(const Tizen::Base::String& sqlStatement);
480 * Executes a statement in the calling %Database instance. @n
481 * If an application opens a database file using Database::Construct(const Tizen::Base::String& dbPath,
482 * const char* pOpenMode, const Tizen::Base::ByteBuffer& secretKey),
483 * the data set written by INSERT/UPDATE is automatically encrypted by the Tizen platform and
484 * the data set read by SELECT is also decrypted by itself.
487 * @brief <i> [Compatibility] </i>
491 * @compatibility This method has compatibility issues with OSP compatible applications. @n
492 * For more information, see @ref CompDatabaseExceptionPage "here".
495 * @return A pointer to the DbEnumerator instance, @n
496 * else @c null if an exception occurs, if no result set is generated after the successful execution of the
497 * SELECT query, or if one of INSERT, UPDATE, and DELETE queries is executed.
498 * @param[in] dbStatement The DbStatement instance to execute
499 * @exception E_SUCCESS The method is successful.
500 * @exception E_INVALID_ARG The specified @c dbStatement includes invalid SQL.
501 * @exception E_OBJECT_LOCKED The database instance is locked.
502 * @exception E_INVALID_FORMAT The database file is malformed.
503 * @exception E_STORAGE_FULL The disk space or database image is full.
504 * @exception E_IO Either of the following conditions has occurred: @n
505 * - An unexpected device failure has occurred as the media ejected suddenly. @n
506 * - %File corruption is detected.
507 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
508 * @remarks If @c dbStatement contains the SELECT query, the Reset() method of the DbEnumerator instance returned
509 * from this method should be called. The Reset() method should be called before re-binding the dbStatement
510 * with the bind methods of the DbStatement class.
511 * This method returns an enumerator if the result set is generated by the SELECT query.
512 * @c null is returned if no result set is available after the successful execution of the SELECT query.
513 * Note that, a return value of @c null does not mean that the statement execution has failed.
514 * The enumerator returned by the SELECT query does not indicate any row before it calls DbEnumerator::MoveNext().
515 * The specific error code can be accessed using the GetLastResult() method.
517 DbEnumerator* ExecuteStatementN(const DbStatement& dbStatement);
520 * Executes SQL statement in this %Database instance. @n
521 * Any SQL statement that does not give a result set can be run using this method; for example, CREATE, INSERT, UPDATE, DELETE.
522 * The SELECT query cannot be executed using this method. @n
523 * If an application opens a database file using Database::Construct(const Tizen::Base::String& dbPath,
524 * const char* pOpenMode, const Tizen::Base::ByteBuffer& key),
525 * the data set written by INSERT/UPDATE is automatically encrypted by the Tizen platform.
528 * @brief <i> [Compatibility] </i>
532 * @compatibility This method has compatibility issues with OSP compatible applications. @n
533 * For more information, see @ref CompDatabaseExceptionPage "here".
536 * @return An error code
537 * @param[in] sqlStatement The SQL statement to execute
538 * @param[in] option This argument is reserved for further use.
539 * @exception E_SUCCESS The method is successful.
540 * @exception E_INVALID_ARG The specified @c sqlStatement is invalid SQL.
541 * @exception E_INVALID_OPERATION The specified @c sqlStatement is a SELECT query.
542 * @exception E_OBJECT_LOCKED The database instance is locked.
543 * @exception E_INVALID_FORMAT The database file is malformed.
544 * @exception E_STORAGE_FULL The disk space or database image is full.
545 * @exception E_IO Either of the following conditions has occurred: @n
546 * - An unexpected device failure has occurred as the media ejected suddenly. @n
547 * - %File corruption is detected.
548 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
549 * @remarks Use QueryN() to execute SELECT query.
552 result ExecuteSql(const Tizen::Base::String& sqlStatement, bool option);
555 * Executes a SELECT query in the calling %Database instance. @n
556 * If an application opens a database file using Database::Construct(const Tizen::Base::String& dbPath,
557 * const char* pOpenMode, const Tizen::Base::ByteBuffer& key),
558 * the data set read by SELECT is automatically decrypted by the Tizen platform.
561 * @brief <i> [Compatibility] </i>
565 * @compatibility This method has compatibility issues with OSP compatible applications. @n
566 * For more information, see @ref CompDatabaseExceptionPage "here".
569 * @return A pointer to the %DbEnumerator instance, @n
570 * else @c null if an exception occurs or if no result set is generated after the successful execution of the SELECT query
571 * @param[in] sqlStatement The SQL statement to execute
572 * @exception E_SUCCESS The method is successful.
573 * @exception E_INVALID_ARG The specified @c sqlStatement is invalid SQL.
574 * @exception E_INVALID_OPERATION The specified @c sqlStatement is not a SELECT query.
575 * @exception E_OBJECT_LOCKED The database instance is locked.
576 * @exception E_INVALID_FORMAT The database file is malformed.
577 * @exception E_IO Either of the following conditions has occurred: @n
578 * - An unexpected device failure has occurred as the media ejected suddenly. @n
579 * - %File corruption is detected.
580 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
581 * @remarks This method returns an enumerator if the result set is generated by the SELECT query.
582 * @c null is returned if no result set is available after the successful execution of the SELECT query.
583 * Note that, a return value of @c null does not mean that the statement execution has failed.
584 * The enumerator returned by the SELECT query does not indicate any row before it calls
585 * DbEnumerator::MoveNext().
586 * The specific error code can be accessed using the GetLastResult() method.
589 DbEnumerator* QueryN(const Tizen::Base::String& sqlStatement);
592 * Begins a transaction within this %Database instance.
595 * @brief <i> [Compatibility] </i>
599 * @compatibility This method has compatibility issues with OSP compatible applications. @n
600 * For more information, see @ref CompDatabaseExceptionPage "here".
603 * @return An error code
604 * @exception E_SUCCESS The method is successful.
605 * @exception E_INVALID_STATE The transaction has already begun.
606 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
607 * @see CommitTransaction()
608 * @see RollbackTransaction()
610 result BeginTransaction(void);
613 * Commits a transaction within this %Database instance.
616 * @brief <i> [Compatibility] </i>
620 * @compatibility This method has compatibility issues with OSP compatible applications. @n
621 * For more information, see @ref CompDatabaseExceptionPage "here".
624 * @return An error code
625 * @exception E_SUCCESS The method is successful.
626 * @exception E_INVALID_STATE The transaction mode is not activated.
627 * @exception E_OBJECT_LOCKED The database instance is locked.
628 * @exception E_INVALID_FORMAT The database file is malformed.
629 * @exception E_STORAGE_FULL The disk space or database image is full.
630 * @exception E_IO Either of the following conditions has occurred: @n
631 * - An unexpected device failure has occurred as the media ejected suddenly. @n
632 * - %File corruption is detected.
633 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
634 * @remarks Database::CommitTransaction() automatically resets not only all the DbStatement instances
635 * but also all the DbEnumerator instances obtained from the current %Database instance.
636 * As a result, the prepared statement of the %DbStatement instances are reset to its initial state, ready to be re-executed,
637 * and enumerator of the %DbEnumerator instances are reset to the first position.
638 * Therefore, the user should be careful when the same instance of the %Database class is shared across multiple threads.
639 * Further, access to the %DbStatement or %DbEnumerator instances resets due to commit operation. This will eventually lead to crash.
640 * To avoid a crash, the user can use multiple database instances for each thread.
641 * Sharing of the same database instance across multiple threads is not recommended.
642 * @see BeginTransaction()
643 * @see RollbackTransaction()
645 result CommitTransaction(void);
648 * Aborts a running transaction within this %Database instance.
651 * @brief <i> [Compatibility] </i>
655 * @compatibility This method has compatibility issues with OSP compatible applications. @n
656 * For more information, see @ref CompDatabaseExceptionPage "here".
659 * @return An error code
660 * @exception E_SUCCESS The method is successful.
661 * @exception E_INVALID_STATE The transaction mode is not activated.
662 * @exception E_OBJECT_LOCKED The database instance is locked.
663 * @exception E_INVALID_FORMAT The database file is malformed.
664 * @exception E_STORAGE_FULL The disk space or database image is full.
665 * @exception E_IO Either of the following conditions has occurred: @n
666 * - An unexpected device failure has occurred as the media ejected suddenly. @n
667 * - %File corruption is detected.
668 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
669 * @see BeginTransaction()
670 * @see CommitTransaction()
672 result RollbackTransaction(void);
675 * Gets the database's filename.
679 * @return The filename of this %Database instance
681 Tizen::Base::String GetName(void) const;
684 * Deletes the database file with the specified file name.
687 * @brief <i> [Compatibility] </i>
691 * @compatibility This method has compatibility issues with OSP compatible applications. @n
692 * For more information, see @ref CompIoPathPage "here".
695 * @return An error code
696 * @param[in] databasePath The path of the database file to delete
697 * @exception E_SUCCESS The method is successful.
698 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
699 * - The length of the specified @c databasePath is invalid. @n
700 * - The specified @c databasePath parameter contains an invalid path or
701 * the path ends with '/'. @n
702 * - The directory name path is missing. @n
703 * - The parent directory does not exist. @n
704 * - An I/O security issue.
705 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
706 * @exception E_FILE_NOT_FOUND The specified database file cannot be found.
707 * @exception E_IO Either of the following conditions has occurred: @n
708 * - An unexpected device failure has occurred as the media ejected suddenly. @n
709 * - %File corruption is detected. @n
710 * - A system error has occurred.
712 static result Delete(const Tizen::Base::String& databasePath);
715 * Checks whether the database file exists.
718 * @brief <i> [Compatibility] </i>
722 * @compatibility This method has compatibility issues with OSP compatible applications. @n
723 * For more information, see @ref CompIoPathPage "here".
726 * @return @c true if the database file exists, @n
728 * @param[in] databasePath The path of the database file to check
729 * @exception E_SUCCESS The method is successful.
730 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
731 * - The length of the specified @c databasePath is invalid. @n
732 * - The specified @c databasePath parameter contains an invalid path or
733 * the path ends with '/'. @n
734 * - The directory name path is missing. @n
735 * - The parent directory does not exist. @n
736 * - An I/O security issue.
737 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
738 * @remarks The specific error code can be accessed using the GetLastResult() method.
740 static bool Exists(const Tizen::Base::String& databasePath);
743 * Converts a normal database file to a secure database file. @n
744 * A secure database file, that is converted by this method, can be shared among applications with the same key value.
747 * @brief <i> [Compatibility] </i>
751 * @compatibility This method has compatibility issues with OSP compatible applications. @n
752 * For path compatibility, see @ref CompIoPathPage "here".
753 * For exception compatibility, see @ref CompDatabaseExceptionPage "here".
755 * @feature %http://tizen.org/feature/database.encryption
757 * @return An error code
758 * @param[in] normalDbPath The normal (non-encrypted) database file path
759 * @param[in] secureDbPath The secure (encrypted) database file path to create
760 * @param[in] secretKey A key to encrypt normal database file @n
761 * If the normal database file is converted with a specific key value,
762 * applications can access the same secure database file with the identical key value.
763 * @exception E_SUCCESS The method is successful.
764 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
765 * - The length of the specified path is @c 0 or exceeds system limitations. @n
766 * - The specified path is invalid. @n
767 * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
768 * @exception E_FILE_NOT_FOUND The specified @c normalDbPath does not exist.
769 * @exception E_FILE_ALREADY_EXIST The specified @c secureDbPath already exists.
770 * @exception E_OBJECT_LOCKED The database instance is locked.
771 * @exception E_INVALID_FORMAlT The database file is malformed.
772 * @exception E_STORAGE_FULL The disk space or database image is full.
773 * @exception E_IO Either of the following conditions has occurred: @n
774 * - An unexpected device failure has occurred as the media ejected suddenly. @n
775 * - %File corruption is detected.
776 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
777 * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature. For more information, see
778 * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">Application Filtering</a>.
779 * @remarks Before calling this method, check whether the feature is supported by Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
781 static result ConvertToSecureDatabase(const Tizen::Base::String& normalDbPath, const Tizen::Base::String& secureDbPath,
782 const Tizen::Base::ByteBuffer& secretKey);
785 * Gets the last inserted row ID.
789 * @return Row ID of the most recent successful insert, @n
790 * else @c -1 if no successful INSERT operations have ever occurred on
791 * the current opened database.
792 * @remarks The row ID is always available as an undeclared column named ROWID, OID, or _ROWID_
793 * as long as those names are not also used by explicitly declared columns.
794 * If the table has a column of type INTEGER PRIMARY KEY then that column is another alias
796 * This method returns the row ID of the most recent successful INSERT operation
797 * for current %Database.
799 long long GetLastInsertRowId(void) const;
803 * @page CompDatabaseExceptionPage Compatibility for E_DATABASE exception
804 * @section CompDatabaseExceptionPageIssueSection Issues
805 * Implementing this method in OSP compatible applications has the following issues: @n
807 * -# E_DATABASE exception includes many errors from underlying database engine.
808 * -# If database is locked, E_SERVICE_BUSY is returned.
810 * @section CompDatabaseExceptionPageSolutionSection Resolutions
811 * The issue mentioned above is resolved in Tizen. @n
813 * @par When working in Tizen:
814 * -# E_DATABASE exception is divided into several exceptions. Refer to exception description of API reference.
815 * -# E_SERVICE_BUSY is changed to E_OBJECT_LOCKED.
822 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
826 Database(const Database& rhs);
829 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
832 Database& operator =(const Database& rhs);
835 * The implementation of this method is intentionally blank and declared as private to prohibit implicit conversion.
839 result Construct(const Tizen::Base::String& dbPath, const wchar_t* pOpenMode);
841 class _DatabaseImpl* __pDatabaseImpl;
843 friend class _DatabaseImpl;
849 #endif //_FIO_DATABASE_H_