Movatterモバイル変換


[0]ホーム

URL:


CN103544284A - System and method for correcting character encoding - Google Patents

System and method for correcting character encoding
Download PDF

Info

Publication number
CN103544284A
CN103544284ACN201310511883.8ACN201310511883ACN103544284ACN 103544284 ACN103544284 ACN 103544284ACN 201310511883 ACN201310511883 ACN 201310511883ACN 103544284 ACN103544284 ACN 103544284A
Authority
CN
China
Prior art keywords
database
character encoding
client
sql statement
connection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201310511883.8A
Other languages
Chinese (zh)
Other versions
CN103544284B (en
Inventor
朱超
陈飞
代兵
王超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd, Qizhi Software Beijing Co LtdfiledCriticalBeijing Qihoo Technology Co Ltd
Priority to CN201310511883.8ApriorityCriticalpatent/CN103544284B/en
Publication of CN103544284ApublicationCriticalpatent/CN103544284A/en
Application grantedgrantedCritical
Publication of CN103544284BpublicationCriticalpatent/CN103544284B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

Translated fromChinese

本发明涉及互联网技术领域,公开了一种字符编码修正系统,包括:数据库连接取出单元,适于接收客户端的SQL语句,从连接池中取出数据库连接;数据库访问单元,适于在使得所述数据库连接的当前字符编码状态与预先保存的所述客户端当前字符编码状态相同时,所述客户端根据所述数据库连接访问数据库;数据库连接释放单元,适于在执行完所述SQL语句后释放所述数据库连接至所述连接池。本发明还公开了一种字符编码修正方法。本发明能够使得客户端在其字符编码状态与数据库连接的字符编码状态相同时访问数据库,并在执行完当前的SQL语句后立即释放该数据库连接,达到了既能避免字符编码不一致导致的乱码,又能保证连接池内所有连接的有效复用的有益效果。

Figure 201310511883

The invention relates to the technical field of the Internet, and discloses a character code correction system, comprising: a database connection fetching unit, adapted to receive an SQL statement from a client, and fetches a database connection from a connection pool; a database access unit, adapted to make the database When the current character encoding state of the connection is the same as the pre-saved current character encoding state of the client, the client accesses the database according to the database connection; the database connection release unit is adapted to release the SQL statement after executing the SQL statement. The database is connected to the connection pool. The invention also discloses a character code correction method. The invention enables the client to access the database when its character encoding state is the same as that of the database connection, and immediately releases the database connection after executing the current SQL statement, so as to avoid garbled characters caused by inconsistent character encoding, It can also ensure the beneficial effect of effective multiplexing of all connections in the connection pool.

Figure 201310511883

Description

Character code update the system and method
Technical field
The present invention relates to Internet technical field, be specifically related to a kind of character code update the system and method.
Background technology
Various characters coding (character code: in order to use the various letters of binary representation, word, symbol etc. is also supported in the data storage of MySQL database, people have formulated various character code modes, by the good binary string of various predefineds, represent each character.Reading with writing of information must be used identical coded system, just can not cause mess code, as Chinese character of two byte representations for GB2312, and Chinese character of three byte representations for UTF-8, if write a Chinese character of encoding with GB2312, after reading, with UTF-8 coding, go to resolve again, just can only obtain wrong result), as: GBK, UTF-8 etc.MySQL provides specially character-coded statement has been set for this reason: SET NAMES, as SET NAMES GBK, just current character code has been arranged to GBK, and read-write afterwards is all carried out according to GBK coding.
Character code state connects and binds with database, that is to say, the different coding arranging in a plurality of connections is independent of each other.For example: two clients, be connected respectively to same MySQL database server, then carry out respectively SET NAMES GBK and SET NAMES UTF8, latter two client with GBK and UTF-8, encode to read and write data respectively, do not conflict mutually.
There is no connection pool, (data access request all must experience building database connection, open database, access data and close the steps such as database connection each time, and connect and open database, be the both time-consuming work of consumption of natural resource, if frequently there is this database manipulation, the performance of system will inevitably sharply decline.Database Connection-Pool Technology is after access data has operated, not closing database connects, but stored, next database request just can directly be used this connection, by the multiplexing database of having set up, connect, greatly save system resource and time) time, each client is set up one to the connection of MySQL and is monopolized this connection, and client one is carried out the encoding state in the connection that SET NAMES statement can not have influence on client two in the connection of oneself.And after introducing connection pool, problem some complexity that becomes, because client is no longer monopolized a connection now, but often execute a SQL statement, connection pool is just put back in used connection, a client will be carried out next SQL statement, and connection pool takes out a connection establishing again and uses to it.In other words, the connection that many SQL statement of same client executing are used is not necessarily same, but often executes a statement, connects and is just replaced.Doing like this object is can, by effectively multiplexing, promote the whole utilization ratio connecting for the connection in connection pool.
But due to character-coded state with connect and bind, therefore the client two that is likely that client one is used when carrying out certain SQL statement was carried out the connection of SET NAMES statement, will cause like this client one to use mistakenly UTF-8 coding to go to read and write GBK coded data, consequence is exactly mess code.
In prior art, a kind of solution that prevents mess code be partial cancellation connect multiplexing, a client is monopolized a connection at run duration, until after this client exits, the connection that it takies is just put back to connection pool.Because comprise that at this client run duration all SQL statement of SET NAMES all carry out in same connection, therefore can guarantee character-coded unification, avoid occurring the situation of mess code.
The shortcoming of obvious above-mentioned solution is that the reusing degree connecting reduces greatly.Each client also can be processed other logics at run duration except carrying out SQL statement, that is to say to carry out between two SQL statement and have certain time interval, if the connection pool of complete multiplexing connection type, the connection that this client takies in this interval will be put back to connection pool for other clients, and in the framework of above-mentioned solution, this connection is not used, and can only be taken and not put by this client.Only after this client exits, its connection taking could be used by other clients.
Summary of the invention
In view of the above problems, the present invention has been proposed to a kind of character code update the system and method that overcomes the problems referred to above or address the above problem is at least in part provided.
According to one aspect of the present invention, a kind of character code update the system is provided, comprising:
Database connects retrieval unit, is suitable for receiving the SQL statement of client, takes out database and connect from connection pool;
Database access unit, is suitable for when the current character encoding state that described database is connected is identical with the described client current character encoding state of preserving in advance, and described client is according to described database connected reference database;
Database Connection Release unit, is suitable for discharging described database after executing described SQL statement and is connected to described connection pool.
Alternatively, described database access unit further comprises:
Character code state set unit, is suitable for comprising when character-coded statement is set in described SQL statement, and it is the character code in described SQL statement that the current character encoding state that described database connects is set;
Character code state updating unit, being suitable for upgrading the described client current character encoding state of preserving is in advance the character code in described SQL statement;
SQL statement transmitting element, is suitable for described SQL statement to be connected and sent to described database by described database, so that database described in described client-access.
Alternatively, described database access unit further comprises:
SQL statement transmitting element, be suitable for not comprising character-coded statement being set in described SQL statement, and when the current character encoding state that the described database taking out connects is identical with the described client current character encoding state of preserving in advance, described SQL statement is connected and sent to described database by described database, so that database described in described client-access.
Alternatively, described database access unit further comprises:
SQL statement plug-in unit, be suitable for not comprising character-coded statement being set in described SQL statement, and when the current character encoding state that the described database taking out connects is not identical with the described client current character encoding state of preserving in advance, before described SQL statement, insert character-coded statement is set, to form new SQL statement;
SQL statement transmitting element, is suitable for described new SQL statement to be connected and sent to described database by described database, so that database described in described client-access.
Alternatively, by relation mapping table, preserve described client and described client current character encoding state.
According to a further aspect in the invention, provide a kind of character code modification method, comprised step:
Receive the SQL statement of client, from connection pool, take out database and connect;
When the current character encoding state that described database is connected is identical with the described client current character encoding state of preserving in advance, described client is according to described database connected reference database;
After executing described SQL statement, discharge described database and be connected to described connection pool.
Alternatively, when the described current character encoding state described database is connected is identical with the described client current character encoding state of preserving in advance, described client further comprises according to described database connected reference database:
In described SQL statement, comprise when character-coded statement is set, it is the character code in described SQL statement that the current character encoding state that described database connects is set;
Upgrading the described client current character encoding state of preserving is in advance the character code in described SQL statement;
Described SQL statement is connected and sent to described database by described database, so that database described in described client-access.
Alternatively, when the described current character encoding state described database is connected is identical with the described client current character encoding state of preserving in advance, described client further comprises according to described database connected reference database:
In described SQL statement, do not comprise character-coded statement is set, and when the current character encoding state that the described database taking out connects is identical with the described client current character encoding state of preserving in advance, described SQL statement is connected and sent to described database by described database, so that database described in described client-access.
Alternatively, when the described current character encoding state described database is connected is identical with the described client current character encoding state of preserving in advance, described client further comprises according to described database connected reference database:
In described SQL statement, do not comprise character-coded statement is set, and when the current character encoding state that the described database taking out connects is not identical with the described client current character encoding state of preserving in advance, before described SQL statement, insert character-coded statement is set, to form new SQL statement;
Described new SQL statement is connected and sent to described database by described database, so that database described in described client-access.
Alternatively, by relation mapping table, preserve described client and described client current character encoding state.
According to character code update the system of the present invention and method, accessing database when the character code state that can make client connect at its character code state and database is identical, and after executing current SQL statement, discharge immediately this database and connect, in the prior art having solved thus for fear of occurring mess code, and the problem that the reusing degree that database is connected reduces greatly, obtained and can avoid the inconsistent mess code causing of character code, can guarantee again the effective multiplexing beneficial effect of all connections in connection pool.
Above-mentioned explanation is only the general introduction of technical solution of the present invention, in order to better understand technological means of the present invention, and can be implemented according to the content of instructions, and for above and other objects of the present invention, feature and advantage can be become apparent, below especially exemplified by the specific embodiment of the present invention.
Accompanying drawing explanation
By reading below detailed description of the preferred embodiment, various other advantage and benefits will become cheer and bright for those of ordinary skills.Accompanying drawing is only for the object of preferred implementation is shown, and do not think limitation of the present invention.And in whole accompanying drawing, by identical reference symbol, represent identical parts.In the accompanying drawings:
Fig. 1 shows character code modification method process flow diagram according to an embodiment of the invention;
Fig. 2 shows method particular flow sheet in Fig. 1;
Fig. 3 shows two clients by the schematic diagram of connection pool accessing database;
Fig. 4 shows character code update the system structural representation according to an embodiment of the invention.
Embodiment
Exemplary embodiment of the present disclosure is described below with reference to accompanying drawings in more detail.Although shown exemplary embodiment of the present disclosure in accompanying drawing, yet should be appreciated that and can realize the disclosure and the embodiment that should do not set forth limits here with various forms.On the contrary, it is in order more thoroughly to understand the disclosure that these embodiment are provided, and can by the scope of the present disclosure complete convey to those skilled in the art.
For fear of there is mess code, can make again database connect by effectively multiplexing, the character code modification method flow process of the present embodiment as shown in Figure 1, comprising:
Step S110, the SQL statement of reception client is taken out database and is connected from connection pool.Owing to being that idle database of random taking-up connects from connection pool, therefore, the character code state that the database of taking-up connects may be identical with the character code state of this client, also may be different.
Step S120, when the current character encoding state that described database is connected is identical with the described client current character encoding state of preserving in advance, described client is according to described database connected reference database.
In this step, the current character encoding state that make described database connect is identical with the described client current character encoding state of preserving in advance, specifically comprises following three kinds of situations:
One, client is when sending SQL statement to connection pool, in possible this SQL statement, just comprise character-coded statement is set, be SET NAMES code(as SET NAMES GBK or SET NAMES UTF8), represent that client wants display update character code state.Therefore, in described SQL statement, comprise when character-coded statement is set, it is the character code in described SQL statement that the current character encoding state that described database connects is set; And the described client current character encoding state that upgrades preservation is in advance the character code in described SQL statement.Afterwards described SQL statement is connected and sent to described database by described database, so that database described in described client-access.
Two, in described SQL statement, do not comprise character-coded statement is set, and when the current character encoding state that the described database taking out connects is identical with the described client current character encoding state of preserving in advance, described SQL statement is connected and sent to described database by described database, so that database described in described client-access.
Three, in described SQL statement, do not comprise character-coded statement is set, and when the current character encoding state that the described database taking out connects is not identical with the described client current character encoding state of preserving in advance, before described SQL statement, insert character-coded statement is set, insert SET NAMES cli_code, to form new SQL statement.Again described new SQL statement is connected and sent to described database by described database, so that database described in described client-access.
Wherein, can preserve described client and described client current character encoding state by relation mapping table, and when each client display update character code state, upgrade client current character encoding state.
Step S130 discharges described database and is connected to described connection pool after executing described SQL statement.Execute after a SQL statement, client can enter other logical process stages.For example: execute a SELECT statement, database returns after the data that inquire, and client can process the data that inquire.After handling, may obtain new data, again by new data data inserting storehouse, at this moment to database connection pool, send INSERT statement again, from connection pool, take out a database connection (may be connected difference with the database that SELECT statement is used before, now need to perform step S120) and come connection data storehouse.And in client, data are processed during this period of time, the database connection before taking is released in connection pool, can be used by other client.
When client is passed through connection pool accessing database (MySQL database), above-mentioned flow process can as shown in Figure 2, comprise:
Step S210, judges whether connection pool receives the SQL statement that client is sent, if execution step S220, otherwise the SQL statement of client is waited in continuation.
Step S220 takes out a database and connects from connection pool, normally takes out at random an idle database and connects, and unappropriated database connects.
Step S230, judges in the SQL statement that client sends whether comprise SET NAMES code statement, if so, performs step S240, otherwise execution step S250;
Step S240, expression client is wanted display update character code state, and therefore, the current character encoding state that the database connection of taking-up is set is the character code in described SQL statement, and putting con_code is code; And to upgrade the described client current character encoding state of preserving be in advance the character code in described SQL statement, putting cli_code is code.Then redirect performs step S270.
Step S250, judges that whether cli_code is identical with con_code, if so, performs step S270, otherwise execution step S260;
Step S260 inserts character-coded statement is set before the SQL statement receiving, and inserts SET NAMES cli_code, to form new SQL statement.
Step S270, sends to MySQL by SQL statement (being likely the SQL statement that client arrives, is likely also the SQL statement after the SET NAMES code statement of an insertion).
Step S280, executes after the SQL statement receiving, and database Connection Release, to connection pool, is waited for and being used next time.
As shown in Figure 3, take two clients (client 1 and client 2 312) below describes as example by connection pool 320 access MySQL databases 330.
Client 1 and client 2 312 use be respectively connected one be connected two and carried out SET NAMES GBK statement and SET NAMES UTF8 statement, and to preserve the current character code state of client 1 be GBK, the current character code state of client 2 312 is UTF-8, connecting a current character code state is GBK, and connecting two current character code states is UTF-8.
Execute after SET NAMES code statement, connection pool has been put back in the used connection one of client 1 and the used connection two of client 2 312.Client 1 will be carried out the SQL statement of a read data now, takes out a connection and use to it from connection pool.If what take out is to connect one, connection pool checks client 1 and is connected a current character code, finds that the two is all GBK, directly in connection one, carries out SQL statement.If what take out is to connect two, check client 1 and be connected two current character codes, find that the former is GBK, the latter is UTF-8, and the two is inconsistent, can not directly carry out the SQL statement of read data, need to before the SQL statement of read data, insert a SET NAMES GBK statement, the character code that connects two is modified to GBK, and then carries out the SQL statement of read data, coding just can be not chaotic like this.
Character code update the system and the method for the present embodiment, can be so that the character code state that client connects at its character code state and database accessing database when identical, and after executing current SQL statement, discharge immediately this database and connect, in the prior art having solved thus for fear of occurring mess code, and the problem that the reusing degree that database is connected reduces greatly, obtained and can avoid the inconsistent mess code causing of character code, can guarantee again the effective multiplexing beneficial effect of all connections in connection pool.
The present invention also provides a kind of character code update the system 400, as shown in Figure 4, comprising:
Database connects retrieval unit 410, is suitable for receiving the SQL statement of client, takes out database and connect from connection pool.
Database access unit 420, is suitable for when the current character encoding state that described database is connected is identical with the described client current character encoding state of preserving in advance, and described client is according to described database connected reference database.Wherein, can preserve described client and described client current character encoding state by relation mapping table.
Database Connection Release unit 430, is suitable for discharging described database after executing described SQL statement and is connected to described connection pool.
Described database access unit 420 may further include:
Character code state set unit, is suitable for comprising when character-coded statement is set in described SQL statement, and it is the character code in described SQL statement that the current character encoding state that described database connects is set;
Character code state updating unit, being suitable for upgrading the described client current character encoding state of preserving is in advance the character code in described SQL statement;
SQL statement transmitting element, is suitable for described SQL statement to be connected and sent to described database by described database, so that database described in described client-access.
In described database access unit 420, SQL statement transmitting element is further adapted in described SQL statement and does not comprise character-coded statement is set, and when the current character encoding state that the described database taking out connects is identical with the described client current character encoding state of preserving in advance, described SQL statement is connected and sent to described database by described database, so that database described in described client-access.
Described database access unit 420 can further include:
SQL statement plug-in unit, be suitable for not comprising character-coded statement being set in described SQL statement, and when the current character encoding state that the described database taking out connects is not identical with the described client current character encoding state of preserving in advance, before described SQL statement, insert character-coded statement is set, to form new SQL statement;
Described SQL statement transmitting element is further adapted for described new SQL statement is connected and sent to described database by described database, so that database described in described client-access.
The algorithm providing at this is intrinsic not relevant to any certain computer, virtual system or miscellaneous equipment with demonstration.Various general-purpose systems also can with based on using together with this teaching.According to description above, it is apparent constructing the desired structure of this type systematic.In addition, the present invention is not also for any certain programmed language.It should be understood that and can utilize various programming languages to realize content of the present invention described here, and the description of above language-specific being done is in order to disclose preferred forms of the present invention.
In the instructions that provided herein, a large amount of details have been described.Yet, can understand, embodiments of the invention can not put into practice in the situation that there is no these details.In some instances, be not shown specifically known method, structure and technology, so that not fuzzy understanding of this description.
Similarly, be to be understood that, in order to simplify the disclosure and to help to understand one or more in each inventive aspect, in the above in the description of exemplary embodiment of the present invention, each feature of the present invention is grouped together into single embodiment, figure or sometimes in its description.Yet, the method for the disclosure should be construed to the following intention of reflection: the present invention for required protection requires than the more feature of feature of clearly recording in each claim.Or rather, as reflected in claims below, inventive aspect is to be less than all features of disclosed single embodiment above.Therefore, claims of following embodiment are incorporated to this embodiment thus clearly, and wherein each claim itself is as independent embodiment of the present invention.
Those skilled in the art are appreciated that and can the module in the equipment in embodiment are adaptively changed and they are arranged in one or more equipment different from this embodiment.Module in embodiment or unit or assembly can be combined into a module or unit or assembly, and can put them into a plurality of submodules or subelement or sub-component in addition.At least some in such feature and/or process or unit are mutually repelling, and can adopt any combination to combine all processes or the unit of disclosed all features in this instructions (comprising claim, summary and the accompanying drawing followed) and disclosed any method like this or equipment.Unless clearly statement in addition, in this instructions (comprising claim, summary and the accompanying drawing followed) disclosed each feature can be by providing identical, be equal to or the alternative features of similar object replaces.
In addition, those skilled in the art can understand, although embodiment more described herein comprise some feature rather than further feature included in other embodiment, the combination of the feature of different embodiment means within scope of the present invention and forms different embodiment.For example, in the following claims, the one of any of embodiment required for protection can be used with array mode arbitrarily.
All parts embodiment of the present invention can realize with hardware, or realizes with the software module moved on one or more processor, or realizes with their combination.It will be understood by those of skill in the art that and can use in practice microprocessor or digital signal processor (DSP) to realize the some or all functions that send the some or all parts in server according to the application coupling message of the embodiment of the present invention.The present invention for example can also be embodied as, for carrying out part or all equipment or device program (, computer program and computer program) of method as described herein.Realizing program of the present invention and can be stored on computer-readable medium like this, or can there is the form of one or more signal.Such signal can be downloaded and obtain from internet website, or provides on carrier signal, or provides with any other form.
It should be noted above-described embodiment the present invention will be described rather than limit the invention, and those skilled in the art can design alternative embodiment in the situation that do not depart from the scope of claims.In the claims, any reference symbol between bracket should be configured to limitations on claims.Word " comprises " not to be got rid of existence and is not listed as element or step in the claims.Being positioned at word " " before element or " one " does not get rid of and has a plurality of such elements.The present invention can be by means of including the hardware of some different elements and realizing by means of the computing machine of suitably programming.In having enumerated the unit claim of some devices, several in these devices can be to carry out imbody by same hardware branch.The use of word first, second and C grade does not represent any order.Can be title by these word explanations.

Claims (10)

Translated fromChinese
1.一种字符编码修正系统,其包括步骤:1. A character encoding correction system comprising the steps of:数据库连接取出单元,适于接收客户端的SQL语句,从连接池中取出数据库连接;The database connection fetching unit is suitable for receiving the SQL statement of the client and fetching the database connection from the connection pool;数据库访问单元,适于在使得所述数据库连接的当前字符编码状态与预先保存的所述客户端当前字符编码状态相同时,所述客户端根据所述数据库连接访问数据库;The database access unit is adapted to access the database according to the database connection when the current character encoding state of the database connection is the same as the pre-saved current character encoding state of the client;数据库连接释放单元,适于在执行完所述SQL语句后释放所述数据库连接至所述连接池。The database connection release unit is adapted to release the database connection to the connection pool after the SQL statement is executed.2.如权利要求1所述的字符编码修正系统,其中,所述数据库访问单元进一步包括:2. The character encoding correction system as claimed in claim 1, wherein said database access unit further comprises:字符编码状态设置单元,适于在所述SQL语句包括设置字符编码的语句时,设置所述数据库连接的当前字符编码状态为所述SQL语句中的字符编码;A character encoding state setting unit, adapted to set the current character encoding state of the database connection as the character encoding in the SQL statement when the SQL statement includes a statement for setting character encoding;字符编码状态更新单元,适于更新预先保存的所述客户端当前字符编码状态为所述SQL语句中的字符编码;A character encoding state updating unit, adapted to update the pre-saved current character encoding state of the client as the character encoding in the SQL statement;SQL语句发送单元,适于将所述SQL语句通过所述数据库连接发送到所述数据库,以使所述客户端访问所述数据库。An SQL statement sending unit, adapted to send the SQL statement to the database through the database connection, so that the client accesses the database.3.如权利要求1所述的字符编码修正系统,其中,所述数据库访问单元进一步包括:3. The character encoding correction system as claimed in claim 1, wherein said database access unit further comprises:SQL语句发送单元,适于在所述SQL语句不包括设置字符编码的语句,且取出的所述数据库连接的当前字符编码状态与预先保存的所述客户端当前字符编码状态相同时,将所述SQL语句通过所述数据库连接发送到所述数据库,以使所述客户端访问所述数据库。The SQL statement sending unit is suitable for when the SQL statement does not include a statement for setting character encoding, and when the current character encoding state of the fetched database connection is the same as the pre-saved current character encoding state of the client, send the An SQL statement is sent to the database through the database connection, so that the client accesses the database.4.如权利要求1所述的字符编码修正系统,其中,所述数据库访问单元进一步包括:4. The character encoding correction system as claimed in claim 1, wherein said database access unit further comprises:SQL语句插入单元,适于在所述SQL语句不包括设置字符编码的语句,且取出的所述数据库连接的当前字符编码状态与预先保存的所述客户端当前字符编码状态不相同时,在所述SQL语句前插入设置字符编码的语句,以形成新的SQL语句;The SQL statement insertion unit is suitable for when the SQL statement does not include a statement for setting character encoding, and the current character encoding state of the database connection taken out is different from the pre-saved current character encoding state of the client, when the SQL statement is set Insert a statement that sets the character encoding before the above SQL statement to form a new SQL statement;SQL语句发送单元,适于将所述新的SQL语句通过所述数据库连接发送到所述数据库,以使所述客户端访问所述数据库。The SQL statement sending unit is adapted to send the new SQL statement to the database through the database connection, so that the client accesses the database.5.如权利要求1~4中任一项所述的字符编码修正系统,其中,通过关系映射表保存所述客户端及所述客户端当前字符编码状态。5. The character encoding correction system according to any one of claims 1 to 4, wherein the client and the current character encoding state of the client are saved through a relational mapping table.6.一种字符编码修正方法,其包括步骤:6. A character encoding correction method, which comprises the steps of:接收客户端的SQL语句,从连接池中取出数据库连接;Receive the client's SQL statement and take out the database connection from the connection pool;在使得所述数据库连接的当前字符编码状态与预先保存的所述客户端当前字符编码状态相同时,所述客户端根据所述数据库连接访问数据库;When the current character encoding state of the database connection is the same as the pre-saved current character encoding state of the client, the client accesses the database according to the database connection;在执行完所述SQL语句后释放所述数据库连接至所述连接池。After the SQL statement is executed, the database connection is released to the connection pool.7.如权利要求6所述的字符编码修正方法,其中,所述在使得所述数据库连接的当前字符编码状态与预先保存的所述客户端当前字符编码状态相同时,所述客户端根据所述数据库连接访问数据库进一步包括:7. The character encoding modification method according to claim 6, wherein, when the current character encoding state of the database connection is the same as the pre-saved current character encoding state of the client, the client The database connection access database further includes:在所述SQL语句包括设置字符编码的语句时,设置所述数据库连接的当前字符编码状态为所述SQL语句中的字符编码;When the SQL statement includes a statement for setting character encoding, set the current character encoding state of the database connection as the character encoding in the SQL statement;更新预先保存的所述客户端当前字符编码状态为所述SQL语句中的字符编码;Updating the pre-saved current character encoding state of the client to be the character encoding in the SQL statement;将所述SQL语句通过所述数据库连接发送到所述数据库,以使所述客户端访问所述数据库。sending the SQL statement to the database through the database connection, so that the client accesses the database.8.如权利要求6所述的字符编码修正方法,其中,所述在使得所述数据库连接的当前字符编码状态与预先保存的所述客户端当前字符编码状态相同时,所述客户端根据所述数据库连接访问数据库进一步包括:8. The character encoding modification method according to claim 6, wherein, when the current character encoding state of the database connection is the same as the pre-saved current character encoding state of the client, the client The database connection access database further includes:在所述SQL语句不包括设置字符编码的语句,且取出的所述数据库连接的当前字符编码状态与预先保存的所述客户端当前字符编码状态相同时,将所述SQL语句通过所述数据库连接发送到所述数据库,以使所述客户端访问所述数据库。When the SQL statement does not include a statement for setting character encoding, and the fetched current character encoding state of the database connection is the same as the pre-saved current character encoding state of the client, pass the SQL statement through the database connection sent to the database to enable the client to access the database.9.如权利要求6所述的字符编码修正方法,其中,所述在使得所述数据库连接的当前字符编码状态与预先保存的所述客户端当前字符编码状态相同时,所述客户端根据所述数据库连接访问数据库进一步包括:9. The character encoding modification method according to claim 6, wherein, when the current character encoding state of the database connection is the same as the pre-saved current character encoding state of the client, the client The database connection access database further includes:在所述SQL语句不包括设置字符编码的语句,且取出的所述数据库连接的当前字符编码状态与预先保存的所述客户端当前字符编码状态不相同时,在所述SQL语句前插入设置字符编码的语句,以形成新的SQL语句;When the SQL statement does not include a statement for setting character encoding, and the fetched current character encoding state of the database connection is different from the pre-saved current character encoding state of the client, insert the setting character before the SQL statement Encoded statements to form new SQL statements;将所述新的SQL语句通过所述数据库连接发送到所述数据库,以使所述客户端访问所述数据库。sending the new SQL statement to the database through the database connection, so that the client accesses the database.10.如权利要求6~9中任一项所述的字符编码修正方法,其中,通过关系映射表保存所述客户端及所述客户端当前字符编码状态。10. The character encoding correction method according to any one of claims 6-9, wherein the client and the current character encoding state of the client are saved through a relational mapping table.
CN201310511883.8A2013-10-252013-10-25Character code update the system and methodActiveCN103544284B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201310511883.8ACN103544284B (en)2013-10-252013-10-25Character code update the system and method

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201310511883.8ACN103544284B (en)2013-10-252013-10-25Character code update the system and method

Publications (2)

Publication NumberPublication Date
CN103544284Atrue CN103544284A (en)2014-01-29
CN103544284B CN103544284B (en)2018-06-12

Family

ID=49967736

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201310511883.8AActiveCN103544284B (en)2013-10-252013-10-25Character code update the system and method

Country Status (1)

CountryLink
CN (1)CN103544284B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN104636131A (en)*2014-12-122015-05-20北京奇虎科技有限公司Special instruction execution method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20060251073A1 (en)*2005-05-052006-11-09International Business Machines CorporationMethods and apparatus for transferring data
CN102314375A (en)*2011-03-182012-01-11北京神州数码思特奇信息技术股份有限公司Heterogeneous database storage unified interface and database access method
CN102722575A (en)*2012-06-052012-10-10河北世窗信息技术有限公司System and method for managing multi-type database connection pool

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20060251073A1 (en)*2005-05-052006-11-09International Business Machines CorporationMethods and apparatus for transferring data
CN102314375A (en)*2011-03-182012-01-11北京神州数码思特奇信息技术股份有限公司Heterogeneous database storage unified interface and database access method
CN102722575A (en)*2012-06-052012-10-10河北世窗信息技术有限公司System and method for managing multi-type database connection pool

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
IT阅读网: "数据库零碎---mysql编码设置与乱码分析", 《HTTP://WWW.ITYUEDU.COM/ARTICLE/9105584590/》*
彭海云 等: "基于JSP的高校师生互动平台的构建", 《计算机系统应用》*
潘凯华 等: "《PHP开发实战1200例(第I卷)》", 31 January 2011, 清华大学出版社*
网易博客: "正确设定MySQL中的字符集,解决终端乱码问题", 《HTTP://ALLENLI1987.BLOG.163.COM/BLOG/STATIC/19233215420125275120780》*

Cited By (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN104636131A (en)*2014-12-122015-05-20北京奇虎科技有限公司Special instruction execution method and device
CN104636131B (en)*2014-12-122018-07-27北京奇虎科技有限公司A kind of execution method and device of special instruction

Also Published As

Publication numberPublication date
CN103544284B (en)2018-06-12

Similar Documents

PublicationPublication DateTitle
US8380680B2 (en)Piecemeal list prefetch
CN105122206B (en) Method and apparatus for supporting speculative visitor return address stack emulation
CN106909597B (en)Database migration method and device
US20130097595A1 (en)Update scanning
JP6944576B2 (en) Cache device, instruction cache, instruction processing system, data processing method, data processing device, computer-readable storage medium and computer program
CN115408391B (en) A database table change method, device, equipment and storage medium
CN110532045A (en)A kind of striding course call method and relevant apparatus
CN108241676A (en)Realize the method and apparatus that data synchronize
GB2526647A (en)Decoding base instructions that are modified by a postfix instruction
CN114327477A (en)Intelligent contract execution method and device, electronic device and storage medium
CN102880473A (en)Method and device for task execution based on quartz framework
CN116303542A (en)SQL sentence execution method and device, computer equipment and storage medium
CN109947488B (en)Object initialization method, device, equipment and storage medium of universal function module
US9348867B2 (en)Method for using multiple plans to achieve temporal and archive transparency performance
CN103544284A (en)System and method for correcting character encoding
CN114138815B (en) A method, device and medium for implementing multi-database compatibility of an application program
CN117234582A (en)Project code processing method and device, electronic equipment and storage medium
CN116804915A (en)Data interaction method, processor, device and medium based on memory
CN112711602B (en)Method and device for running stored procedure, database system and storage medium
CN116257254A (en)Python-based edge computing engine implementation method and system
CN110609841B (en)Method, device, readable medium and electronic equipment for asynchronously processing messages
CN108804101B (en)Method and device for creating interface element, storage medium and mobile terminal
CN113657077A (en)Document variable chapter online compiling method and readable storage medium
US20130318509A1 (en)Generating object code from a conjoined assembler directive
CN106570143B (en)Method and device for sending response object

Legal Events

DateCodeTitleDescription
C06Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant
TR01Transfer of patent right

Effective date of registration:20220725

Address after:Room 801, 8th floor, No. 104, floors 1-19, building 2, yard 6, Jiuxianqiao Road, Chaoyang District, Beijing 100015

Patentee after:BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Address before:100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park)

Patentee before:BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Patentee before:Qizhi software (Beijing) Co.,Ltd.

TR01Transfer of patent right

[8]ページ先頭

©2009-2025 Movatter.jp