Tag Archives: The database

Prompt SQL server error 15023 solution memo when modifying user mapping

When the database is restored from the backup file of another instance and users are added and mapped to the table, save the prompt that SQL Server Error 15023 user already exists. My solution:
EXECUTE sp_change_users_login ‘Update_one’,’login1′,’login1′
ALTER USER login1 WITH LOGIN = login1
Note that this is done on the corresponding DataBase (Use [DataBase]) and cannot be done on the Master or any other system DataBase
It is said that there is batch processing, not pro test, as follows:

 1 -- fix all orphan users in database
 2 -- where username=loginname
 3 DECLARE @orphanuser varchar(50)
 4 DECLARE Fix_orphan_user CURSOR FOR
 5 SELECT dp.name  As Orphan_Users
 6 FROM sys.database_principals dp
 7 left join sys.server_principals sp
 8 ON dp.sid=sp.sid 
 9 WHERE sp.name IS NULL 
10 AND dp.type='S' AND 
11 dp.name NOT IN ('guest','INFORMATION_SCHEMA','sys')
12 
13 OPEN Fix_orphan_user
14 FETCH NEXT FROM Fix_orphan_user
15 INTO @orphanuser WHILE @@FETCH_STATUS = 0
16 BEGIN
17 
18 EXECUTE('ALTER USER ' + @orphanuser + ' WITH LOGIN = ' + @orphanuser)
19 
20 FETCH NEXT FROM Fix_orphan_user
21 INTO @orphanuser
22 END
23 CLOSE Fix_orphan_user
24 DEALLOCATE Fix_orphan_user

 
References from the solution: http://www.sqlservergeeks.com/sql-server-error-15023-user-already-exists-in-current-database/
 

Reproduced in: https://www.cnblogs.com/hu123rong00/p/7116496.html

java.sql.SQLException : IO exception: socket read timed out

[Con.err] Java.sqlexception: [con.err] Socket read timed out
the 2010-07-20 12:02:23 error [con. Err] at oracle.. JDBC driver. DatabaseError. ThrowSqlException (DatabaseError. Java: 112)
[con. Err] at the 2010-07-20 12:02:23 mistake Oracle, the JDBC driver. DatabaseError. ThrowSqlException (DatabaseError. Java: 146)
[con. Err] at the 2010-07-20 12:02:23 mistake Oracle, the JDBC driver. DatabaseError. ThrowSqlException (DatabaseError. Java: 255)
[con. Err] at the 2010-07-20 12:02:23 mistake Oracle, the JDBC driver. T4CStatement. ExecuteForDescribe (T4CStatement. Java: 806)
[con. Err] at the 2010-07-20 12:02:23 mistake Oracle, the JDBC driver. OracleStatement. ExecuteMaybeDescribe (OracleStatement. Java: 1031)
[con. Err] at the 2010-07-20 12:02:23 mistake Oracle, the JDBC driver. T4CStatement. ExecuteMaybeDescribe (T4CStatement. Java: 830)
[con. Err] at the 2010-07-20 12:02:23 mistake Oracle, the JDBC driver. OracleStatement. DoExecuteWithTimeout (OracleStatement. Java: 1124)
[con. Err] at the 2010-07-20 12:02:23 mistake Oracle, the JDBC driver. OracleStatement. ExecuteQuery (OracleStatement. Java: 1264)
the 2010-07-20 12:02:23 error [con. Err] at com. Apusic. JDBC. Adapter. StatementHandle. ExecuteQuery (Unknown Source)
.
.
.
Solutions:
Socket connection timeout try small file

Reproduced in: https://blog.51cto.com/8231017/1395064

XAException occurred. Error code is: XAER_RMERR


Problem: IBM Portal USES the built-in DB2 database by default. After performing the migration operation to Oracle, the portal process cannot be stopped normally. The following error message is reported:
[12/18/09 19:18:39:289 CST] 00000028 InternalOracl I DSRA8203I: Database product name : Oracle
[12/18/09 19:18:39:289 CST] 00000028 InternalOracl I DSRA8204I: Database product version : Oracle Database 10g Enterprise Edition Release 10.2.0.4.0- 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
[12/18/09 19:18:39:289 CST] 00000028 InternalOracl I DSRA8205I: JDBC driver name : Oracle JDBC driver
[12/18/09 19:18:39:290 CST] 00000028 InternalOracl I DSRA8206I: JDBC driver version : 10.2.0.1.0
[12/18/09 19:18:39:290 CST] 00000028 InternalOracl I DATA_STORE_HELPER_NAME
[12/18/09 19:18:39:290 CST] 00000028 WSRdbDataSour I DSRA8208I: JDBC driver type: “”
[12/18/09 19:18:39:294 CST] 00000028 WSRdbXaResour E DSRA0304E: XAException occurred. XAException contents and details are: The cause is : null.
[12/18/09 19:18:39:294 CST] 00000028 WSRdbXaResour E DSRA0302E: XAException occurred. Error code is: XAER_RMERR (-3). Exception is:
[12/18/09 19:18:39:295 CST] 00000028 XARminst E WTRN0037W: The transaction service encountered an error on an xa_recover operation. The resource was com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl@15d2dc71. The error code was XAER_RMERR. The exception stack trace follows: javax.transaction.xa.XAException at oracle.jdbc.xa.OracleXAResource.recover(OracleXAResource.java:526)
at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.recover(WSRdbXaResourceImpl.java:992)
at com.ibm.ws.Transaction.JTA.XARminst.recover(XARminst.java:137)
at com.ibm.ws.Transaction.JTA.XARecoveryData.recover(XARecoveryData.java:690)
at com.ibm.ws.Transaction.JTA.PartnerLogTable.recover(PartnerLogTable.java:514)
at com.ibm.ws.Transaction.JTA.RecoveryManager.resync(RecoveryManager.java:1896)
at com.ibm.ws.Transaction.JTA.RecoveryManager.run(RecoveryManager.java:2608)
at java.lang.Thread.run(Thread.java:571)
Solutions:
Grant select on dba_pending_transactions to; –USER is the name of the USER you want to connect to Oracle DB
Method 2: Update the JDBC driver to 10.2.0.4
 
 
 

From “ITPUB blog” link: http://blog.itpub.net/10537377/viewspace-623219/, if you want to reprint, please indicate the source, otherwise will be investigated for legal responsibility.

Reproduced in: http://blog.itpub.net/10537377/viewspace-623219/

call to member function bind_param() on boolean………..

Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in …. Stack trace: #0 {main} thrown in……… This error is usually caused by the wrong database table name, resulting in the previous parameter could not get the correct value, you can check the parameter value correctly by typing var_dump(param_name)

Reproduced in: https://blog.51cto.com/haiyanyuan/1731256

Error 1045 (28000) access denied for user ‘root’ @’localhost ‘appears in MySQL under Windows system

Error 1045(28000) Access Denied for user ‘root’@’localhost’

From http://zxy5241.spaces.live.com/blog/cns! 7682A3008CFA2BB0! 361.entry
When installing mysql database in Windows operating system, you encounter Error 1045(28000) Access Denied for user ‘root’@’localhost’, you need to reset the password.
the specific method is:
1. First, find my. Ini configuration file in the installation directory, open the configuration file, find the line [mysqld], add skip-gran-tables below and save the file, and restart mysql dynamic service.
2. Then execute mysql -u root mysql
mysql> update user set password=password(‘newpassword’) where user=’root’;
mysql> Flush privileges;
where newpassword is root’s newpassword. 3. Remove the line that added to my. Ini configuration file just now, and finally restart mysql.

After installing mysql or uninstalling the downloaded free version, the default is no my.ini file.
. However, there are several similar files, such as [code] my-small-ini, my-media.ini, my-large. Ini, my-huge. Ini, [/code].
these files are the different configuration information recommended by mysql for different applications; But these configurations will only be applied if you put them in my. Ini.
where:
1, my-small. Ini is designed for small database. This model should not be used for databases that contain common items.
2, my-media.ini is designed for medium-sized databases. If you are using RHEL in the enterprise, you will have significantly more physical memory than the minimum RAM requirements for this operating system (256MB). As you can see, if you have that much RAM memory available, you can naturally run other services on the same machine.
3, my-larg.ini is designed for use exclusively with a SQL database. Since it can use up to 512MB of memory for the database, at least 1GB of RAM will be required on this type of system so that it can handle both operating system and database applications.
4, my-huge. Ini is designed for databases in enterprises. Such a database would require a dedicated server and 1GB or more of RAM. These choices are highly dependent on the amount of memory, the speed of the computer, the size of the database details, the number of users accessing the database, and the number of users loading and accessing data into the database. The performance of the database may change as the number of databases and users increases.

according to their own situation, select a file configuration copy to my. Ini file, of course, you need to create your own, just create a new file, and then copy into the configuration information.

Error: current transaction is aborted, commands ignored until end of transaction blockp

In normal database programming, we encountered errors from time to time: Current Transaction is aborted, commands ignored until the end of transaction BlockP. How to solve it?We usually look it up on the Internet. If you’re a little bit better at English you can tell from the error message that there’s probably something wrong there. But if the experience is not very rich, or the Internet to find more convenient. The most basic error message can see from the official documentation (http://www.postgresql.org/docs/8.4/interactive/errcodes-appendix.html).
The error above is the cause of improper transaction control, which can be written as follows.
Improper writing 1:
Connection OPEN.
Try {
Try {
Database operation A.
} Catch (Exception e) {
The log. The error (” do something “);
}
 
Database operation B. // The above error may occur during this data operation.
The transaction commits commit.
} Catch (Exception ex) {
Transaction rollback rollback.
} the finally {
Close the connection.
}
 
Improper writing method 2:
Connection OPEN.
Try {
Database operation A.
Database operation B.
The transaction commits commit.
} Catch (Exception ex) {
Database operation C. // The above error may occur during this data operation.
The transaction commits commit.
} the finally {
Close the connection.
}
 
In a Postgres database, if there is an error in a database operation in the same transaction, all subsequent databases in that transaction will fail.
If there is an error in database operation A, the same database operation B will report an error when it is executed. If there is an error in database operation A or database operation B, the same database operation C will report an error.
To avoid errors, someone is using the re-open method, which in effect throws away all previous operations (not in the case of auto-commit) and adds overhead by re-opening, which is not recommended.
Depending on the cause of the error, we can treat the processing before the possible error as a transaction. The processing after the error is then treated as a transaction, depending on the specific logic. That way you can avoid making mistakes.
In this way, we can change the improper 1 to
Try {
Database operation A.
} Catch (Exception e) {
Transaction rollback or commit;
The log. The error (” do something “);
}
Database operation B.  
 
In this way we can change the improper notation 2 to
} Catch (Exception ex) {
Transaction rollback or commit;
Database operation C.   
The transaction commits commit.
} the finally {
Close the connection.
}
 
 
 

PHP connection PostgreSQL error call to undefined function PG_ connect()

Use PHP to connect PostgreSQL, Call to undefined function pg_connect();
‘PDOException’ with message ‘could not find driver’ with message ‘could not find driver’
Testing environment:
First, the extension=php_pdo_pgsql.dll and extension=php_pgsql.dll extensions are on, but not working.
Then, add \PostgreSQL\bin to the environment variable, which still doesn’t work.
Then, putting \PostgreSQL\bin\libpq.dll into System32 has no effect.
Finally, change libpq.dll from \ PHP \php5.*\ into \apache*\bin to solve the problem.

SQL Server “login failed for user ‘domain account”. [sqlstate 28000] (error 18456). “Problem solving

Problem: SQL Server 2014, synchronized data from Linked Server with Job timing, executed times “Login Failed for User ‘domain account’ “(SQLSTATE 28000) (Error 18456).
Solution: Modify the SQL Server Agent service startup account as the domain account through the configuration management tool, see: Login Failed for [SQLSTATE 28000] (Error 18456) The Step Failed

Reproduced in: https://www.cnblogs.com/abelard/p/4840962.html

Apache failed to start due to SSL library certificate has expired

1. Check the service log and see the following error from the /var/log/ HTTPD /nss_error_log file:
[Sat Aug 20 08:17:49 2016] [error] NSS_Initialize failed. Certificate database: /etc/httpd/alias.
[Sat Aug 20 08:17:49 2016] [error] SSL Library Error: -8038 SEC_ERROR_NOT_INITIALIZED
[Sat Aug 20 08:17:49 2016] [error] NSS_Initialize failed. Certificate database: /etc/httpd/alias.
[Sat Aug 20 08:17:49 2016] [error] SSL Library Error: -8038 SEC_ERROR_NOT_INITIALIZED
It says certificate problem. Check the certificate: Discovery time expired
“Certutil-d /etc/httpd/ Alia-L-n Server-CERT”
2. The default time of installation of the certificate is 4 years.
3. Treatment:
1. If you don’t need to use mod_nss module, that the/etc/HTTPD/conf. Directly to the d/NSS. The conf file renaming or deletion; 2. Do not verify certificate expiration time, add nssenforcidcerts off configuration in nss.conf;
3. Is to regenerate the new certificate; Be sure to delete the old certificate database file before generating a new certificate
CD/etc/HTTPD/alias
The rm -f *. The db
The/usr/sbin/gencert/etc/HTTPD/alias & gt; /etc/httpd/alias/install.log 2> & 1
Certutil-d /etc/httpd/ Alia-L-n Server-CERT
Chmod 750 *.db (because it operates under root, it generates permissions that are root permissions)
Restart the HTTPD
 

Reproduced in: https://www.cnblogs.com/Fle-x/articles/5789614.html

MySQL failed to add foreign key error 1452

MySQL failed to add foreign keys, error 1452
For example:
Two tables user table: User class table: Grade
Each user in the user table corresponds to a class ID, namely gradeId
Namely: The primary key of the User table gradeId is the Id in the Grade table
The user table is called the primary table and the Grade table is called the slave table
[SQL]

alter table user

Add Foreign Key (gradeId) References Grade (Id);  

[error]

ERROR 1452 : Cannot add or update a child row: a foreign key constraint fails

“Why”
Some gradeId in the User table do not belong to the ID in the Grade table
【 Solution 】
Modify the data so that all gradeId in the User table belong to ids in the Grade table

Visio2007 usage record

    installation, need to be selective installation, not all components need to install, such as office tools, office sharing functions, visio in.net programmable support does not need to install… Cad in Visio, either installed or not installed… The solution must be installed, or you can’t use the models to draw graphics…


Office Visio Professional 2007 simplified Chinese version
cd-key: w2jjw-4kydp-2ymkw-fx36h-qyvd8
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Visio is a multi-document drawing program. The best thing about visio is that it offers a number of “molds” or “solutions” that are approximately 416M in size, the main of which is the inclusion of various illustrations. Another major feature is that it provides easy editing of graphics: e.g., zoom/auto connect… The name of the graphic document created by default is “drawing 1,2,3..” . Multiple Windows can be arranged conveniently by tile in the Window menu. The “shapesheet” actually provides the details of the document graphics.. Of course, graphics can also be modified through shapesheet. Other operations, such as toolbar operation customization, online and Offline search help, are the same as Word.
Online help is from: https://support.office.microsoft.com/... , in fact, offline help is available!
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Display and print and save as Visio;

    printing basically just prints the content of the document area, the background part may print a small part of the content; When you save it as a PNG, you’re basically storing everything in the “whole” range, including everything in the background, into the PNG. And
    you can specify the background color of PNG images, such as the default white, or gray, etc. The full screen “F5” is only for display and cannot be edited.

In Visio, “shapes” can be thought of as “molds,” and “molds” are really just components, widgets, sort of visual programming.
Visio is simple to use: drag and drop/place/connect widgets.
Favorites is a place to save your favorite widgets and drag and drop them when you need to use them instead of looking for them in your library.
Why log in/register?Since browser is a record-free/save-free tool (for good reason, there is no need to keep it). So, want to on a web server to save a user’s personal information, such as: the goods into the shopping cart information, purchase records, the user’s IP/name/tel/used to sell private information, transaction records, search history, information browsing history and so on, then it must be in the database, with the user name/id/tel phone, etc. The user name/id/passwd/tel/phone, is the entrance to the user to view information about yourself, and database information (record/query/show) the primary key of primary key!! But these keys, messages/ data and so on can not be generated by the server itself, can not be generated casually, so it will be provided by the user, how to provide! —> Sign in!!
Actually, there are several tables associated with the user information: the user information table, the shopping cart table, the purchase record table, and the browsing history table. Useid is the foreign key of the following tables.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

    in addition to using automatic line, can also draw a line, draw a line, do not select a line to set, this is only valid for the line, for the subsequent draw invalid…

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = miscellaneous: = = = = = = = = = = = = = =
council: coun – cil: [k2ns2l] as “pencil” : pencil, pen – cil
pave hawks: [peiv] vt. The town council decided to pave The square. (2) the road is not asphalt. (the road is not asphalt.) Asphalt, asphalt; V. shop…
The street was paved with asphalt. V. the… To cover with grass. = to cover with grass.
The asphalt playgrounds have been grassed over or sown with flowers
Windows sound theme: When a Windows user does an “invalid “/” illegal” operation, there is always a “flicker window “+ “bang”. The speaker can be shut down, but there is no sound when playing music/video. Use a “silent” sound theme!

For Office/Software and Windows software, almost all document page Settings are in the file menu, and together with the “Print preview/Print page Settings”!
For Visio, the distance of the A4 paper size (210mm * 297mm) is in the “lower left corner”, which is consistent with the usual XOY coordinate system: right up is the positive direction…
About text: When an object is selected, double-click on the object, or click on the “text” tool to add text in pairs. Text and object are associated… To get separate, object-independent text, use the “text” tool if you want to select an object…
Since the drawing tool always has to be dragged to take effect, the “handle” appears after the drawing and waits for adjustment. When the adjustment is finished, just click on the page. Equivalent to the “ok” button
Visio document is similar to Word document, except that Word is mainly used for text processing while Visio is mainly used for displaying/drawing widgets… Both are used to express/convey information, but in different forms. Like: singing and dancing, writing letters and drawing pictures…
The CTRL button is also used to drag and copy, while ctrl_shift_ copies in the same direction as horizontal and vertical.
There are a lot of useful and nice ICONS/images in Visio that you want to export?: Saves the Visio file as: HTML file (a Web file that separates text from images/ICONS). Then make use of HTML document this function: can make a general processing: want to automatically separate text and picture, extract, is to save the file as: HTML document!!

C programming interface of SQLite database (6) result codes and error codes

SQlite database C programming interface (VI) Result Codes and Error Codes by QQ: 253786989 2012-02-07

Standard Codes
Here are the standard return values and error code definitions:

#define SQLITE_OK           0   /* Successful result */
/* beginning-of-error-codes */
#define SQLITE_ERROR        1   /* SQL error or missing database */
#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */
#define SQLITE_PERM         3   /* Access permission denied */
#define SQLITE_ABORT        4   /* Callback routine requested an abort */
#define SQLITE_BUSY         5   /* The database file is locked */
#define SQLITE_LOCKED       6   /* A table in the database is locked */
#define SQLITE_NOMEM        7   /* A malloc() failed */
#define SQLITE_READONLY     8   /* Attempt to write a readonly database */
#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
#define SQLITE_CORRUPT     11   /* The database disk image is malformed */
#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */
#define SQLITE_FULL        13   /* Insertion failed because database is full */
#define SQLITE_CANTOPEN    14   /* Unable to open the database file */
#define SQLITE_PROTOCOL    15   /* Database lock protocol error */
#define SQLITE_EMPTY       16   /* Database is empty */
#define SQLITE_SCHEMA      17   /* The database schema changed */
#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */
#define SQLITE_MISMATCH    20   /* Data type mismatch */
#define SQLITE_MISUSE      21   /* Library used incorrectly */
#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */
#define SQLITE_AUTH        23   /* Authorization denied */
#define SQLITE_FORMAT      24   /* Auxiliary database format error */
#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
#define SQLITE_NOTADB      26   /* File opened that is not a database file */
#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */
#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */
/* end-of-error-codes */

Some of these constants are returned only by a specific function, such as the SQLITE_RANGE, which is returned only by the SQlite3_bind_xxx function. Some constants, such as SQLITE_ERROR, only indicate that an error occurred during the execution of the function, but there is no way to know why the error occurred.
Sqlite_false stands for MISUSE of apis. For example, a bind function returns SQlite_ern when a statement is given another parameter after the sqlite3_step function has executed without being reset.
Extended Codes
Standard error codes provide less information about the cause of the error. So sometimes we use extended error codes. The extended error code is based on the standard error code, whose lower order byte is the original standard error code, and then attaches information to its higher order byte “or” to describe the details of the error.

int sqlite3_extended_result_codes(sqlite3*, int onoff);

The error codes for these extensions are not enabled by default due to compatibility issues with the client’s legacy programs. Programmers can enable or disable extended error codes by using the SQlite3_extended_result_CODES function.
Here are all the extended error codes (most of which describe SQLITE_IOERR) :

#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))
#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))
#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))
#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))
#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))
#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))
#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))
#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))
#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))
#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))
#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))
#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))
#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))
#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))
#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))
#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))
#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))
#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))
#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))
#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))
#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))
#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))
#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))
#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))

Error Functions

int sqlite3_extended_result_codes(sqlite3*, int onoff);

Enable or disable the use of extended error codes for a database connection. Enable extended error codes by passing a non-zero value to the second parameter of the SQlite3_extended_result_CODES function. This function always returns SQLITE_OK, and there is no way to get an extension error code that is currently enabled or off.

int sqlite3_errcode(sqlite3 *db);

If a database function operation does not return SQLITE_OK, you can then call the function to get the error code. By default it returns the standard error code, and it may also return an extended error code if the current database connection is enabled.

int sqlite3_extended_errcode(sqlite3 *db);

Similar to the SQlite3_errcode function, except that it only returns the extended error code.

const char *sqlite3_errmsg(sqlite3*);
const void *sqlite3_errmsg16(sqlite3*);

Returns an error code string, encoded in UTF-8 or UTF-16. Programmers should either call these functions, get the error code information, or make a copy. The next database operation may invalidate the returned string pointer.
SQlite error handling cannot handle multiple errors simultaneously. For example, if an API function call goes awrong and the programmer fails to check for that error, the next API function call may well return SQlite_ern, indicating that the program is trying to use an invalid data structure. So programmers should check and handle any errors that might occur after each API function call.
In addition, if multiple threads share the same database connection, it is best to encapsulate the core API calls and error-handling code in the Critical section. Programmers can use the SQlite3_db_mutex function to get the mutex pointer to the database connection (a pointer to the SQlite3_mutex object).
Prepare for V2 Version
The following table compares the prepare function of the original version with that of v2 version:

The V2 version of prepare is more concise for error handling and has the schema advantages listed in the table above, so it is recommended to use the V2 version of prepare.
Transactions and Errors
Typically, SQlite operations are in auto-commit mode. SQlite automatically encapsulates each SQL command into a transaction. Error recovery is easy if each statement is encapsulated in its own transaction. Any time SQLite finds itself in the wrong state, it simply rolls back the current transaction. This effectively cancels the current SQL command and returns the database to the state it was in before the error occurred.
However, once the BEGIN TRANSACTION command is executed, SQlite is no longer in autocommit mode. A TRANSACTION is opened and will remain open until either the END TRANSACTION or the COMMIT TRANSACTION command is executed. This allows multiple SQL commands to be encapsulated into a single transaction, allowing a discrete set of commands to execute either all or none (atomic operations), but it also limits SQLite’s error recovery.
When a displayed (explicit) transaction encounters an error during execution, SQLite attempts to cancel the statement just executed. Unfortunately, this is not always possible. If things go badly, SOMETIMES SQlite can just roll back the entire current transaction, with no other option.
The most likely errors to cause a rollback are SQLITE_FULL (database or disk space is full), SQLITE_IOERR (disk IO error or file is locked), SQLITE_BUSY (database lock), SQLITE_NOMEM (out of memory), SQLITE_INTERRUPT (interrupt). If the program is executing a display transaction and receives one of these errors, be prepared to handle the possibility of a transaction being rolled back.

int sqlite3_get_autocommit(sqlite3*);

With this function, you can get the current commit status. If a non-zero value is returned, the database is in auto-commit (atutoconmit) mode. If 0 is returned, the database is currently inside an explicit transaction.
If the SQlite database is forced to do a full transaction rollback, the database will once again go into transaction autocommit mode. If the database is not in auto-commit mode, it must be in a transaction, indicating that no rollback is required.

SQlite database C programming interface (VI) Result Codes and Error Codes by QQ: 253786989 2012-02-07