A class that handles database exceptions. A prompt message is displayed according to the error code.

Source: Internet
Author: User

Public class myerrorcontext
{
Public static class myerror
{
Int errno;
String szerrordesc;
Public myerror (INT errno, string errordesc)
{
This. errno = errno;
This. szerrordesc = errordesc;
}
Public int geterrorno ()
{
Return errno;
}
Public String geterrordesc ()
{
Return szerrordesc;
}
}
Public static final int db_er_cant_create_table = 1005; // table creation failed
Public static final int db_er_cant_create_db = 1006; // database creation failed
Public static final int db_er_db_create_exists = 1007; // The database already exists and creation failed.
Public static final int db_er_db_drop_exists = 1008; // The database does not exist. An error occurred while deleting the database.
Public static final int db_er_db_drop_delete = 1009; // The database file cannot be deleted, leading to database deletion failure.
Public static final int db_er_db_drop_rmdir = 1010; // The data directory cannot be deleted, leading to database deletion failure.
Public static final int db_er_cant_delete_file = 1011; // An error occurred while deleting the database file.
Public static final int db_er_cant_find_system_rec = 1012; // records in the system table cannot be read.
Public static final int db_er_checkread = 1020; // The record has been modified by another user.
Public static final int db_er_disk_full = 1021; // insufficient space left on the hard disk. please increase the available space on the hard disk.
Public static final int db_er_dup_key = 1022; // duplicate keyword, change record failed
Public static final int db_er_error_on_close = 1023; // An error occurred while disabling
Public static final int db_er_error_on_read = 1024; // An error occurred while reading the file.
Public static final int db_er_error_on_rename = 1025; // An error occurred while changing the name.
Public static final int db_er_error_on_write = 1026; // file write error
Public static final int db_er_key_not_found = 1032; // the record does not exist.
Public static final int db_er_open_as_readonly = 1036; // The data table is read-only and cannot be modified.
Public static final int db_er_outofmemory = 1037; // The system memory is insufficient. Restart the database or restart the server.
Public static final int db_er_out_of_sortmemory = 1038; // The Memory Used for sorting is insufficient. Increase the sorting buffer.
Public static final int db_er_con_count_error = 1040; // maximum number of connections to the database. Increase the number of available connections to the database.
Public static final int db_er_out_of_resources = 1041; // insufficient system memory
Public static final int db_er_bad_host_error = 1042; // The host name is invalid.
Public static final int db_er_handshake_error = 1043; // The connection is invalid.
Public static final int db_er_dbaccess_denied_error = 1044; // The current user has no permission to access the database.
Public static final int db_er_access_denied_error = 1045; // The database cannot be connected. The user name or password is incorrect.
Public static final int db_er_bad_null_error = 1048; // the field cannot be blank.
Public static final int db_er_bad_db_error = 1049; // The database does not exist.
Public static final int db_er_table_exists_error = 1050; // The data table already exists.
Public static final int db_er_bad_table_error = 1051; // The data table does not exist.
Public static final int db_er_bad_field_error = 1054; // The field does not exist.
Public static final int db_er_empty_query = 1065; // invalid SQL statement. The SQL statement is empty.
Public static final int db_er_ipsock_error = 1081; // a socket connection cannot be established.
Public static final int db_er_record_file_full = 1114; // The data table is full and cannot accommodate any records
Public static final int db_er_too_many_tables = 1116; // too many open data tables
Public static final int db_er_host_is_blocked = 1129; // database exception. Restart the database.
Public static final int db_er_host_not_privileged = 1130; // failed to connect to the database. You are not authorized to connect to the database.
Public static final int db_er_password_no_match = 1133; // The database user does not exist.
Public static final int db_er_nonexisting_grant = 1141; // The current user does not have access to the database
Public static final int db_er_tableaccess_denied_error = 1142; // The current user does not have access to the data table
Public static final int db_er_columnaccess_denied_error = 1143; // The current user is not authorized to access fields in the data table.
Public static final int db_er_no_such_table = 1146; // The data table does not exist.
Public static final int db_er_nonexisting_table_grant = 1147; // you are not authorized to access the data table.
Public static final int db_er_syntax_error = 1149; // SQL statement syntax error
Public static final int db_er_net_read_error = 1158; // network error. A read error occurs. Check the network connection status.
Public static final int db_er_net_read_interrupted = 1159; // network error. Read timeout. Check the network connection status.
Public static final int db_er_net_error_on_write = 1160; // network error. A write error occurs. Check the network connection status.
Public static final int db_er_net_write_interrupted = 1161; // network error. Write timeout. Check the network connection status.
Public static final int db_er_dup_entry = 1062; // The field value is repeated and the Database Import fails.
Public static final int db_er_dup_unique = 1169; // The field value is repeated and the update record fails.
Public static final int db_er_check_no_such_table = 1177; // An error occurred while opening the data table.
Public static final int db_er_error_during_commit = 1180; // transaction submission failed
Public static final int db_er_error_during_rollback = 1181; // transaction rollback failed
Public static final int db_er_too_many_user_connections = 1203; // The maximum number of connections established between the current user and the database to the database. Increase the number of available database connections or restart the database.
Public static final int db_er_lock_wait_timeout = 1205; // lock timeout
Public static final int db_er_no_permission_to_create_user = 1211; // The current user does not have the permission to create a user.
Public static final int db_er_no_referenced_row = 1216; // The foreign key constraint check fails and the sub-Table Record Update fails.
Public static final int db_er_row_is_referenced = 1217; // The foreign key constraint check fails, And the deletion or modification of the primary table record fails.
Public static final int db_er_user_limit_reached = 1226; // The resource used by the current user has exceeded the allowed resource. Restart the database or restart the server.
Public static final int db_er_specific_access_denied_error = 1227; // You do not have permission to perform this operation
Public static final int db_er_not_supported_yet = 1235; // the mysql version is too low and does not have this function
Private Static final myerror [] errormap =
{
New myerror (db_er_cant_create_table, "Table creation failed "),
New myerror (db_er_cant_create_db, "database creation failed "),
New myerror (db_er_db_create_exists, "database already exists, database creation failed "),
New myerror (db_er_db_drop_exists, "database does not exist, database deletion failed "),
New myerror (db_er_db_drop_delete, "failed to delete database files because database files cannot be deleted "),
New myerror (db_er_db_drop_rmdir, "failed to delete database because the data directory cannot be deleted "),
New myerror (db_er_cant_delete_file, "failed to delete database files "),
New myerror (db_er_cant_find_system_rec, "records in the system table cannot be read "),
New myerror (db_er_checkread, "the record has been modified by another user "),
New myerror (db_er_disk_full, "insufficient disk space available, please increase disk space available "),
New myerror (db_er_dup_key, "Duplicate keyword, change record failed "),
New myerror (db_er_error_on_close, "An error occurred when closing "),
New myerror (db_er_error_on_read, "file read error "),
New myerror (db_er_error_on_rename, "An error occurred while changing the name "),
New myerror (db_er_error_on_write, "file write error "),
New myerror (db_er_key_not_found, "the record does not exist "),
New myerror (db_er_open_as_readonly, "the data table is read-only and cannot be modified "),
New myerror (db_er_outofmemory, "the system memory is insufficient. Restart the database or restart the server "),
New myerror (db_er_out_of_sortmemory, "the memory used for sorting is insufficient. please increase the sorting buffer "),
New myerror (db_er_con_count_error, "the maximum number of connections to the database has been reached. please increase the number of available connections to the Database "),
New myerror (db_er_out_of_resources, "insufficient system memory "),
New myerror (db_er_bad_host_error, "invalid host name "),
New myerror (db_er_handshake_error, "invalid connection "),
New myerror (db_er_dbaccess_denied_error, "the current user has no permission to access the database "),
New myerror (db_er_access_denied_error, "the database cannot be connected, the user name or password is incorrect "),
New myerror (db_er_bad_null_error, "field cannot be blank "),
New myerror (db_er_bad_db_error, "database does not exist "),
New myerror (db_er_table_exists_error, "data table already exists "),
New myerror (db_er_bad_table_error, "data table does not exist "),
New myerror (db_er_bad_field_error, "the field does not exist "),
New myerror (db_er_empty_query, "invalid SQL statement, SQL statement is empty "),
New myerror (db_er_ipsock_error, "cannot establish socket connection "),
New myerror (db_er_record_file_full, "the data table is full and cannot accommodate any records "),
New myerror (db_er_too_many_tables, "too many open data tables "),
New myerror (db_er_host_is_blocked, "database exception occurred. Please restart the Database "),
New myerror (db_er_host_not_privileged, "database connection failed, no database connection permission "),
New myerror (db_er_password_no_match, "database user does not exist "),
New myerror (db_er_nonexisting_grant, "the current user does not have access to the database "),
New myerror (db_er_tableaccess_denied_error, "the current user does not have access to the data table "),
New myerror (db_er_columnaccess_denied_error, "the current user does not have access to fields in the data table "),
New myerror (db_er_no_such_table, "data table does not exist "),
New myerror (db_er_nonexisting_table_grant, "the user's access to the data table is not defined "),
New myerror (db_er_syntax_error, "SQL statement syntax error "),
New myerror (db_er_net_read_error, "network error, read error, please check network connection status "),
New myerror (db_er_net_read_interrupted, "network error, read timeout, Check network connection status "),
New myerror (db_er_net_error_on_write, "network error. A write error occurs. Check the network connection status "),
New myerror (db_er_net_write_interrupted, "network error, write timeout, Check network connection status "),
New myerror (db_er_dup_entry, "repeated field values, failed to import "),
New myerror (db_er_dup_unique, "Duplicate Field Values, update record failed "),
New myerror (db_er_check_no_such_table, "failed to open the data table "),
New myerror (db_er_error_during_commit, "transaction commit failed "),
New myerror (db_er_error_during_rollback, "rollback transaction failed "),
New myerror (db_er_too_many_user_connections, "the maximum number of connections established between the current user and the database has reached the database. please increase the number of available database connections or restart the Database "),
New myerror (db_er_lock_wait_timeout, "lock timeout "),
New myerror (db_er_no_permission_to_create_user, "the current user has no permission to create a user "),
New myerror (db_er_no_referenced_row, "failed to check foreign key constraints and failed to update sub-table records "),
New myerror (db_er_row_is_referenced, "failed to check foreign key constraints, failed to delete or modify the primary table record "),
New myerror (db_er_user_limit_reached, "The resource used by the current user has exceeded the allowed resource. Please restart the database or the server "),
New myerror (db_er_specific_access_denied_error, "You are not authorized to perform this operation "),
New myerror (db_er_not_supported_yet, "mysql version is too low and does not have this function "),
};
Public static string geterrorinfo (INT errno)
{
For (INT I = 0; I <errormap. length; I ++)
{
If (errno = errormap [I]. geterrorno ())
{
Return errormap [I]. geterrordesc ();
}
}
Return "";
}
Public String geterrormessage (INT errorcode)
{
String error = NULL;
For (INT I = 0; I <errormap. length; I ++)
{
If (errormap [I]. geterrorno () = errorcode)
{
Error = errormap [I]. geterrorno () + ":" + errormap [I]. geterrordesc ();
Break;
}
}
Return Error;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.