CN116910024A - A method and system for data link string management - Google Patents
A method and system for data link string management Download PDFInfo
- Publication number
- CN116910024A CN116910024A CN202310882991.XA CN202310882991A CN116910024A CN 116910024 A CN116910024 A CN 116910024A CN 202310882991 A CN202310882991 A CN 202310882991A CN 116910024 A CN116910024 A CN 116910024A
- Authority
- CN
- China
- Prior art keywords
- link string
- data
- database
- database link
- string
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2282—Tablespace storage structures; Management thereof
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
- G06F16/24552—Database cache management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
- G06F16/258—Data format conversion from or to a database
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
一种数据链接串管理的方法,方法为:把数据库链接串的数据用占位符进行替换;创建一张数据库链接串配置表用于存储数据库链接串,所述数据库链接串配置表的字段配置有关键字key;在Redis缓存中通过关键字key查询数据库链接串配置表,获取数据库链接串的数据,将替换后的数据库链接串的格式还原,得到完整的数据,并存储到Redis缓存中;需要更换原数据库服务器IP的时候,查询原数据库服务器IP,获取所有IP为原数据库服务器IP的数据库链接串配置表,并替换为新的服务器IP,并清空所有的配置关键字key的Redis缓存数据;重新读取数据库链接串配置表获取数据链接串数据,得到修改后完整数据库链接串,并重新存入Redis缓存,可以更轻松地管理和维护大量的数据库链接字符串,提高开发效率。
A method of data link string management, the method is: replacing the data of the database link string with placeholders; creating a database link string configuration table for storing the database link string, the field configuration of the database link string configuration table There is a keyword key; query the database link string configuration table through the keyword key in the Redis cache, obtain the data of the database link string, restore the format of the replaced database link string, obtain the complete data, and store it in the Redis cache; When you need to change the original database server IP, query the original database server IP, obtain the database link string configuration table with all IPs that are the original database server IP, replace them with the new server IP, and clear the Redis cache data of all configuration keyword keys. ; Re-read the database link string configuration table to obtain the data link string data, obtain the modified complete database link string, and re-store it into the Redis cache. This makes it easier to manage and maintain a large number of database link strings and improve development efficiency.
Description
技术领域Technical field
本发明涉及计算机技术,特别是一种数据链接串管理的方法及其系统。The invention relates to computer technology, in particular to a method and system for managing data link strings.
背景技术Background technique
在软件开发中,数据库链接字符串是一个常见的配置项,用于指定应用程序与数据库之间建立链接所需的参数,包括服务器IP、端口、数据库名称、用户名和密码等。然而,管理和维护大量的数据库链接字符串常常会带来一些困扰和挑战。In software development, the database link string is a common configuration item used to specify the parameters required to establish a link between the application and the database, including server IP, port, database name, user name and password, etc. However, managing and maintaining a large number of database connection strings often brings some troubles and challenges.
现有的方式通常将数据库链接字符串直接硬编码到代码中,当需要更改链接参数时,必须修改代码并重新编译,不灵活且容易出错。并且同一个服务器IP可能在不同的项目中在多个链接串中被使用,如果存在大量的链接字符串,需要手动逐个修改所有的链接字符串,耗时且容易出错,无法批量的对它们进行一键修改与发布。The existing method usually hardcodes the database connection string directly into the code. When the link parameters need to be changed, the code must be modified and recompiled, which is inflexible and error-prone. And the same server IP may be used in multiple link strings in different projects. If there are a large number of link strings, all link strings need to be modified manually one by one, which is time-consuming and error-prone, and cannot be done in batches. Modify and publish with one click.
发明内容Contents of the invention
为克服现有的方式通常将数据库链接字符串直接硬编码到代码中,当需要更改链接参数时,必须修改代码并重新编译,同一个服务器IP可能在不同的项目中在多个链接串中被使用,如果存在大量的链接字符串,需要手动逐个修改所有的链接字符串,耗时且容易出错,无法批量的对它们进行一键修改与发布的问题。To overcome the existing method, the database connection string is usually hard-coded directly into the code. When the link parameters need to be changed, the code must be modified and recompiled. The same server IP may be used in multiple link strings in different projects. If there are a large number of link strings, you need to manually modify all the link strings one by one, which is time-consuming and error-prone, and it is impossible to modify and publish them in batches with one click.
本发明采用以下方案实现:The present invention adopts the following solutions to achieve:
一种数据链接串管理的方法,所述方法步骤如下:A method for managing data link strings. The steps of the method are as follows:
步骤1:把数据库链接串的数据用占位符进行替换;Step 1: Replace the data in the database link string with placeholders;
步骤2:创建一张数据库链接串配置表用于存储数据库链接串,所述数据库链接串配置表的字段配置有关键字key;Step 2: Create a database link string configuration table to store the database link string, and the fields of the database link string configuration table are configured with the keyword key;
步骤3:在Redis缓存中通过关键字key查询数据库链接串配置表,获取数据库链接串的数据,将步骤1替换后的数据库链接串的格式还原,得到完整的数据,并存储到Redis缓存中;Step 3: Query the database link string configuration table through the keyword key in the Redis cache, obtain the data of the database link string, restore the format of the database link string replaced in step 1, obtain the complete data, and store it in the Redis cache;
步骤4:需要更换原数据库服务器IP的时候,查询原数据库服务器IP,获取所有IP为原数据库服务器IP的数据库链接串配置表,并替换为新的服务器IP,并清空所有的配置关键字key的Redis缓存数据;Step 4: When you need to change the original database server IP, query the original database server IP, obtain the database link string configuration table with all IPs that are the original database server IP, replace them with the new server IP, and clear all configuration keyword keys. Redis cache data;
步骤5:重新读取数据库链接串配置表获取数据链接串数据,得到修改后完整数据库链接串,并重新存入Redis缓存,以供下次使用。Step 5: Re-read the database link string configuration table to obtain the data link string data, obtain the modified complete database link string, and re-store it into the Redis cache for next use.
步骤1进一步具体为:所述数据库链接串的数据包括IP地址、数据库库名db、账号user、密码pwd、服务器端口port,将链接串的内容根据上述数据替换成{user}:{pwd}@tcp({ip}:{port})/{db}?charset=utf8mb4的格式。Step 1 is further specific: the data of the database link string includes IP address, database name db, account user, password pwd, and server port port. The content of the link string is replaced with {user}:{pwd}@ based on the above data. tcp({ip}:{port})/{db}? The format of charset=utf8mb4.
步骤2中所述数据库链接串配置表的字段配置有:关键字key、格式字符串format、服务器IP、服务器端口port、库名db、账号user、密码pwd。The field configurations of the database link string configuration table mentioned in step 2 include: keyword key, format string format, server IP, server port, database name db, account user, and password pwd.
步骤3进一步具体为:通过关键字key查询数据库链接串配置表,如果不存在则查询链接串配置表获取数据库链接串数据,按格式字符串format把相应字段替换后得到完整的数据库链接串,并存储到以配置关键字为key的Redis缓存中。Step 3 is further detailed as follows: Query the database link string configuration table through the keyword key. If it does not exist, query the link string configuration table to obtain the database link string data. Replace the corresponding fields according to the format string format to obtain the complete database link string. Store it in the Redis cache with the configuration keyword as the key.
步骤4进一步具体为:当需要更换原数据库服务器IP的时候,查询原数据库服务器IP下的所有数据库链接串配置表,获得数据列表list,接着使用更新语句更新所有旧IP数据,最后循环list,把所有的配置关键字key的Redis缓存数据清空。Step 4 is further specific: when the original database server IP needs to be replaced, query all database link string configuration tables under the original database server IP to obtain the data list, then use the update statement to update all old IP data, and finally loop the list to The Redis cache data of all configuration keyword keys is cleared.
一种数据链接串管理的系统,所述系统包括字符串转换模块、配置表创建模块、数据存储模块、管理模块、读取模块;A system for data link string management, the system includes a string conversion module, a configuration table creation module, a data storage module, a management module, and a reading module;
所述字符串转换模块用于把数据库链接串的数据用占位符进行替换;The string conversion module is used to replace the data of the database link string with placeholders;
所述配置表创建模块用于创建一张数据库链接串配置表用于存储数据库链接串,所述数据库链接串配置表的字段配置有关键字key;The configuration table creation module is used to create a database link string configuration table for storing database link strings, and the fields of the database link string configuration table are configured with keywords key;
所述数据存储模块用于在Redis缓存中通过关键字key查询数据库链接串配置表,获取数据库链接串的数据,将替换后的数据库链接串的格式还原,得到完整的数据,并存储到Redis缓存中;The data storage module is used to query the database link string configuration table through the keyword key in the Redis cache, obtain the data of the database link string, restore the format of the replaced database link string, obtain the complete data, and store it in the Redis cache middle;
所述管理模块用于需要更换原数据库服务器IP的时候,查询原数据库服务器IP,获取所有IP为原数据库服务器IP的数据库链接串配置表,并替换为新的服务器IP,并清空所有的配置关键字key的Redis缓存数据;The management module is used to query the original database server IP when it is necessary to change the original database server IP, obtain the database link string configuration table with all IPs as the original database server IP, replace them with new server IPs, and clear all configuration keys. Redis cache data of word key;
所述读取模块用于重新读取数据库链接串配置表获取数据链接串数据,得到修改后完整数据库链接串,并重新存入Redis缓存,以供下次使用。The reading module is used to re-read the database link string configuration table to obtain the data link string data, obtain the modified complete database link string, and re-store it into the Redis cache for next use.
字符串转换模块进一步具体为:所述数据库链接串的数据包括IP地址、数据库库名db、账号user、密码pwd、服务器端口port,将上述数据替换成{user}:{pwd}@tcp({ip}:{port})/{db}?charset=utf8mb4的格式。The string conversion module is further specific: the data of the database link string includes IP address, database name db, account user, password pwd, and server port port. The above data is replaced with {user}:{pwd}@tcp({ ip}:{port})/{db}? The format of charset=utf8mb4.
配置表创建模块中所述数据库链接串配置表的字段配置有:关键字key、格式字符串format、服务器IP、服务器端口port、库名db、账号user、密码pwd。The field configurations of the database link string configuration table described in the configuration table creation module include: keyword key, format string format, server IP, server port port, database name db, account user, and password pwd.
数据存储模块进一步具体为:通过关键字key查询数据库链接串配置表,如果不存在则查询链接串配置表获取数据库链接串数据,按格式字符串format把相应字段替换后得到完整的数据库链接串,并存储到以配置关键字为key的Redis缓存中。The data storage module is further detailed as follows: query the database link string configuration table through the keyword key. If it does not exist, query the link string configuration table to obtain the database link string data. Replace the corresponding fields according to the format string format to obtain the complete database link string. And stored in the Redis cache with the configuration keyword as the key.
管理模块进一步具体为:当需要更换原数据库服务器IP的时候,查询原数据库服务器IP下的所有数据库链接串配置表,获得数据列表list,接着使用更新语句更新所有旧IP数据,最后循环list,把所有的配置关键字key的Redis缓存数据清空。The management module is further detailed as follows: when the original database server IP needs to be replaced, query all database link string configuration tables under the original database server IP to obtain the data list, then use the update statement to update all old IP data, and finally loop through the list. The Redis cache data of all configuration keyword keys is cleared.
本发明的有益效果在于:The beneficial effects of the present invention are:
本发明提供了一种数据链接串管理的方法及系统,可以更轻松地管理和维护大量的数据库链接字符串,并且在需要修改或更新时能够更加高效和准确地进行操作,提高开发和运维效率、降低错误和风险、增强系统的灵活性和可维护性。The present invention provides a method and system for data link string management, which can more easily manage and maintain a large number of database link strings, and can operate more efficiently and accurately when modification or update is needed, thereby improving development and operation and maintenance. efficiency, reduce errors and risks, and enhance system flexibility and maintainability.
附图说明Description of the drawings
图1为本发明方法的流程图;Figure 1 is a flow chart of the method of the present invention;
图2为本发明系统的结构框图。Figure 2 is a structural block diagram of the system of the present invention.
具体实施方式Detailed ways
下面结合附图对本发明做进一步说明。The present invention will be further described below in conjunction with the accompanying drawings.
如图1所示,一种数据链接串管理的方法,所述方法步骤如下:As shown in Figure 1, a method for managing data link strings has the following steps:
步骤1:把数据库链接串的数据用占位符进行替换;Step 1: Replace the data in the database link string with placeholders;
步骤2:创建一张数据库链接串配置表用于存储数据库链接串,所述数据库链接串配置表的字段配置有关键字key;Step 2: Create a database link string configuration table to store the database link string, and the fields of the database link string configuration table are configured with the keyword key;
步骤3:在Redis缓存中通过关键字key查询数据库链接串配置表,获取数据库链接串的数据,将步骤1替换后的数据库链接串的格式还原,得到完整的数据,并存储到Redis缓存中;Step 3: Query the database link string configuration table through the keyword key in the Redis cache, obtain the data of the database link string, restore the format of the database link string replaced in step 1, obtain the complete data, and store it in the Redis cache;
步骤4:需要更换原数据库服务器IP的时候,查询原数据库服务器IP,获取所有IP为原数据库服务器IP的数据库链接串配置表,并替换为新的服务器IP,并清空所有的配置关键字key的Redis缓存数据;Step 4: When you need to change the original database server IP, query the original database server IP, obtain the database link string configuration table with all IPs that are the original database server IP, replace them with the new server IP, and clear all configuration keyword keys. Redis cache data;
步骤5:重新读取数据库链接串配置表获取数据链接串数据,得到修改后完整数据库链接串,并重新存入Redis缓存,以供下次使用。Step 5: Re-read the database link string configuration table to obtain the data link string data, obtain the modified complete database link string, and re-store it into the Redis cache for next use.
在本发明的一个实施例中,一种数据链接串管理的方法及系统:In one embodiment of the present invention, a method and system for data link string management:
把数据库链接串的IP、库名、账号、密码用占位符进行替换,设计成{user}:{pwd}@tcp({ip}:{port})/{db}?charset=utf8mb4的格式。Replace the IP, database name, account number, and password of the database link string with placeholders and design it as {user}:{pwd}@tcp({ip}:{port})/{db}? The format of charset=utf8mb4.
假设有一个系统需要链接mysql数据库,链接串=zhifu:ABCDEFG@tcp172.10.32.16:3306/pay?charset=utf8mb4,把链接串里的IP、库名、账号、密码用占位符进行替换,设计成如下格式{user}:{pwd}@tcp({ip}:{port})/{db}?charset=utf8mb4。Suppose there is a system that needs to connect to the mysql database, link string=zhifu:ABCDEFG@tcp172.10.32.16:3306/pay? charset=utf8mb4, replace the IP, library name, account, and password in the link string with placeholders, and design it into the following format {user}:{pwd}@tcp({ip}:{port})/{db} ? charset=utf8mb4.
{user}、{pwd}、{ip}、{port}以及{db},都表示变量,格式中:、@tcp、(:)、/、?以及charset=utf8mb4都是固定格式。{user}, {pwd}, {ip}, {port} and {db} all represent variables, in the format:, @tcp, (:), /,? and charset=utf8mb4 are both fixed formats.
创建一张数据库链接串配置表con_tb用于存储所有的数据库链接串,数据库链接串配置表con_tb的字段有配置关键字key、格式字符串format、服务器IP、服务器端口port、库名db、账号user、密码pwd。Create a database link string configuration table con_tb to store all database link strings. The fields of the database link string configuration table con_tb include configuration keyword key, format string format, server IP, server port port, library name db, and account user , password pwd.
创建一张数据库链接串配置表con_tb用于存储所有的数据库链接串,字段如下:配置关键字key、格式字符串format、服务器IP、服务器端口port、库名db、账号user、密码pwd。表结构如下:Create a database link string configuration table con_tb to store all database link strings. The fields are as follows: configuration keyword key, format string format, server IP, server port port, database name db, account user, and password pwd. The table structure is as follows:
CREATE TABLE`con_tb`(CREATE TABLE`con_tb`(
`id`int(11)NOT NULL AUTO_INCREMENT,`id`int(11)NOT NULL AUTO_INCREMENT,
`key`varchar(10)DEFAULT NULL,`key`varchar(10)DEFAULT NULL,
`format`varchar(255)DEFAULT NULL,`format`varchar(255)DEFAULT NULL,
`ip`varchar(20)DEFAULT NULL,`ip`varchar(20)DEFAULT NULL,
`port`int(5)DEFAULT NULL,`port`int(5)DEFAULT NULL,
`db`varchar(10)DEFAULT NULL,`db`varchar(10)DEFAULT NULL,
`user`varchar(10)DEFAULT NULL,`user`varchar(10)DEFAULT NULL,
`pwd`varchar(20)DEFAULT NULL,`pwd`varchar(20)DEFAULT NULL,
`create_time`datetime DEFAULT NULL,`create_time`datetime DEFAULT NULL,
PRIMARY KEY(`id`)PRIMARY KEY(`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;)ENGINE=InnoDB DEFAULT CHARSET=utf8;
程序启动时按所需的key查询Redis缓存获取数据库链接串,如果不存在则查询链接串配置表con_tb获取数据库链接串数据,按格式字符串format把相应字段替换后得到完整的数据库链接串,并存储到以配置关键字为key的Redis缓存中,以供下次使用。When the program starts, query the Redis cache according to the required key to obtain the database link string. If it does not exist, query the link string configuration table con_tb to obtain the database link string data. Replace the corresponding fields according to the format string format to obtain the complete database link string. Store it in the Redis cache with the configuration keyword as the key for next use.
假设这个系统是根据把数据库链接串存在以配置关键字key为paysystem的数据行中,数据表存储数据如表1:Assume that this system stores the database link string in the data row with the configuration keyword key as paysystem. The data table stores the data as shown in Table 1:
表1Table 1
当程序启动时,读取Redis缓存key=paysystem的缓存数据,如果存在则返回给系统使用,如果不存在则查询链接串配置表con_tb获取数据库链接串数据,执行语句select*from con_tb where key=’paysystem’limit 1。得到数据后按格式字符串format把相应字段替换后得到完整的数据库链接串=zhifu:ABCDEFG@tcp172.10.32.16:3306/pay?charset=utf8mb4。接着存储到Redis缓存key=paysystem的Redis缓存缓存中,以供下次使用。When the program starts, read the cache data of Redis cache key=paysystem. If it exists, it will be returned to the system for use. If it does not exist, query the link string configuration table con_tb to obtain the database link string data, and execute the statement select*from con_tb where key=' paysystem'limit 1. After obtaining the data, replace the corresponding fields according to the format string format to obtain the complete database link string=zhifu:ABCDEFG@tcp172.10.32.16:3306/pay? charset=utf8mb4. Then store it in the Redis cache with Redis cache key=paysystem for next use.
当需要更换数据库服务器IP的时候,查询数据库链接串配置表con_tb的ip字段等于原数据库服务器IP的数据列表的keylist,接着使用更新语句update con_tb set ip=新数据库服务器IP where ip=原数据库服务器IP更新所有旧配置数据,最后循环keylist,把所有的配置关键字key的Redis缓存数据清空。When the database server IP needs to be changed, query the ip field of the database link string configuration table con_tb which is equal to the keylist of the data list of the original database server IP, and then use the update statement update con_tb set ip = new database server IP where ip = original database server IP Update all old configuration data, finally cycle the keylist, and clear the Redis cache data of all configuration keyword keys.
假设在系统日常运行的过程中,IP为172.10.32.16的服务器因故障或机房变动等任何原因需要迁移至新服务器,假设新服务器IP为121.15.22.20,并且172.10.32.16这个IP不仅被paysystem使用,还被其他数十个系统所使用,那下面说明如何快速批量更新。Assume that during the daily operation of the system, the server with IP address 172.10.32.16 needs to be migrated to a new server due to any reasons such as failure or changes in the computer room. Assume that the new server IP is 121.15.22.20, and the IP address 172.10.32.16 is not only used by paysystem. It is also used by dozens of other systems, so here's how to quickly update in batches.
查询数据库链接串配置表con_tb的ip字段等于原数据库服务器IP的数据列表,执行查询语句select key from con_tb where ip=’172.10.32.16’得到所有使用172.10.32.16这个IP的链接串配置数据的keylist,接着使用更新语句update con_tb setip=’121.15.22.20’where ip=’172.10.32.16’更新所有使用172.10.32.16这个IP的链接串配置数据。接着循环前面取到的keylist,执行Redis缓存命令del{key},清除所有被缓存的Redis缓存数据。Query the ip field of the database link string configuration table con_tb which is equal to the data list of the original database server IP. Execute the query statement select key from con_tb where ip='172.10.32.16' to get the keylist of all link string configuration data using the IP 172.10.32.16. Then use the update statement update con_tb setip='121.15.22.20' where ip='172.10.32.16' to update all link string configuration data using the IP 172.10.32.16. Then loop through the keylist obtained previously and execute the Redis cache command del{key} to clear all cached Redis cache data.
当程序按所需的key查询Redis缓存获取数据库链接串时,Redis缓存数据已被清理,则重新读取链接串配置表con_tb获取数据链接串数据,重新组织得到完整数据库链接串,并重新存入Redis缓存,以供下次使用。When the program queries the Redis cache to obtain the database link string according to the required key, the Redis cache data has been cleared, then re-reads the link string configuration table con_tb to obtain the data link string data, reorganizes the complete database link string, and re-stores it. Redis caches for next time use.
当各程序按自己系统所需的key查询Redis缓存来获取数据库链接串时,发现Redis缓存读取不到数据,因为Redis缓存数据已被清理,接着重新读取链接串配置表con_tb来获取数据,并且按照步骤3的规则重新组织得到完整的数据库链接串,并重新存入Redis缓存,以供下次使用。When each program queries the Redis cache according to the key required by its own system to obtain the database link string, it is found that the Redis cache cannot read the data because the Redis cache data has been cleared, and then re-reads the link string configuration table con_tb to obtain the data. And reorganize according to the rules of step 3 to obtain the complete database link string, and re-store it into the Redis cache for next use.
如图2所示,本发明还提供了一种数据链接串管理的系统,所述系统包括字符串转换模块、配置表创建模块、数据存储模块、管理模块、读取模块;As shown in Figure 2, the present invention also provides a system for data link string management. The system includes a string conversion module, a configuration table creation module, a data storage module, a management module, and a reading module;
所述字符串转换模块用于把数据库链接串的数据用占位符进行替换;The string conversion module is used to replace the data of the database link string with placeholders;
所述配置表创建模块用于创建一张数据库链接串配置表用于存储数据库链接串,所述数据库链接串配置表的字段配置有关键字key;The configuration table creation module is used to create a database link string configuration table for storing database link strings, and the fields of the database link string configuration table are configured with keywords key;
所述数据存储模块用于在Redis缓存中通过关键字key查询数据库链接串配置表,获取数据库链接串的数据,将替换后的数据库链接串的格式还原,得到完整的数据,并存储到Redis缓存中;The data storage module is used to query the database link string configuration table through the keyword key in the Redis cache, obtain the data of the database link string, restore the format of the replaced database link string, obtain the complete data, and store it in the Redis cache middle;
所述管理模块用于需要更换原数据库服务器IP的时候,查询原数据库服务器IP,获取所有IP为原数据库服务器IP的数据库链接串配置表,并替换为新的服务器IP,并清空所有的配置关键字key的Redis缓存数据;The management module is used to query the original database server IP when it is necessary to change the original database server IP, obtain the database link string configuration table with all IPs as the original database server IP, replace them with new server IPs, and clear all configuration keys. Redis cache data of word key;
所述读取模块用于重新读取数据库链接串配置表获取数据链接串数据,得到修改后完整数据库链接串,并重新存入Redis缓存,以供下次使用。The reading module is used to re-read the database link string configuration table to obtain the data link string data, obtain the modified complete database link string, and re-store it into the Redis cache for next use.
字符串转换模块进一步具体为:所述数据库链接串的数据包括IP地址、数据库库名db、账号user、密码pwd、服务器端口port,将上述数据替换成{user}:{pwd}@tcp({ip}:{port})/{db}?charset=utf8mb4的格式。The string conversion module is further specific: the data of the database link string includes IP address, database name db, account user, password pwd, and server port port. The above data is replaced with {user}:{pwd}@tcp({ ip}:{port})/{db}? The format of charset=utf8mb4.
配置表创建模块中所述数据库链接串配置表的字段配置有:关键字key、格式字符串format、服务器IP、服务器端口port、库名db、账号user、密码pwd。The field configurations of the database link string configuration table described in the configuration table creation module include: keyword key, format string format, server IP, server port port, database name db, account user, and password pwd.
数据存储模块进一步具体为:通过关键字key查询数据库链接串配置表,如果不存在则查询链接串配置表获取数据库链接串数据,按格式字符串format把相应字段替换后得到完整的数据库链接串,并存储到以配置关键字为key的Redis缓存中。The data storage module is further detailed as follows: query the database link string configuration table through the keyword key. If it does not exist, query the link string configuration table to obtain the database link string data. Replace the corresponding fields according to the format string format to obtain the complete database link string. And stored in the Redis cache with the configuration keyword as the key.
管理模块进一步具体为:当需要更换原数据库服务器IP的时候,查询原数据库服务器IP下的所有数据库链接串配置表,获得数据列表list,接着使用更新语句更新所有旧IP数据,最后循环list,把所有的配置关键字key的Redis缓存数据清空。The management module is further detailed as follows: when the original database server IP needs to be replaced, query all database link string configuration tables under the original database server IP to obtain the data list, then use the update statement to update all old IP data, and finally loop through the list. The Redis cache data of all configuration keyword keys is cleared.
总之,本发明提供了一种数据链接串管理的方法及系统,可以更轻松地管理和维护大量的数据库链接字符串,并且在需要修改或更新时能够更加高效和准确地进行操作,提高开发和运维效率、降低错误和风险、增强系统的灵活性和可维护性。In short, the present invention provides a method and system for data link string management, which can more easily manage and maintain a large number of database link strings, and can operate more efficiently and accurately when modification or update is needed, improving development and Operation and maintenance efficiency, reducing errors and risks, and enhancing system flexibility and maintainability.
以上所述仅为本发明的较佳实施例,凡依本发明申请专利范围所做的均等变化与修饰,皆应属本发明的涵盖范围。The above are only preferred embodiments of the present invention, and all equivalent changes and modifications made in accordance with the patentable scope of the present invention shall fall within the scope of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310882991.XA CN116910024A (en) | 2023-07-19 | 2023-07-19 | A method and system for data link string management |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310882991.XA CN116910024A (en) | 2023-07-19 | 2023-07-19 | A method and system for data link string management |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN116910024A true CN116910024A (en) | 2023-10-20 |
Family
ID=88356125
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202310882991.XA Pending CN116910024A (en) | 2023-07-19 | 2023-07-19 | A method and system for data link string management |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN116910024A (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7702642B1 (en) * | 2005-12-07 | 2010-04-20 | Precise Software Solutions, Inc. | Method, system and computer-readable code for instrumenting code for logging database-related strings |
| CN111190928A (en) * | 2019-12-24 | 2020-05-22 | 平安普惠企业管理有限公司 | Cache processing method, apparatus, computer equipment, and storage medium |
| CN111666305A (en) * | 2020-06-05 | 2020-09-15 | 福建天晴在线互动科技有限公司 | Method and system for realizing association between redis cache and database |
| CN112835874A (en) * | 2021-03-25 | 2021-05-25 | 中国工商银行股份有限公司 | Active and standby database construction method, device and system |
-
2023
- 2023-07-19 CN CN202310882991.XA patent/CN116910024A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7702642B1 (en) * | 2005-12-07 | 2010-04-20 | Precise Software Solutions, Inc. | Method, system and computer-readable code for instrumenting code for logging database-related strings |
| CN111190928A (en) * | 2019-12-24 | 2020-05-22 | 平安普惠企业管理有限公司 | Cache processing method, apparatus, computer equipment, and storage medium |
| CN111666305A (en) * | 2020-06-05 | 2020-09-15 | 福建天晴在线互动科技有限公司 | Method and system for realizing association between redis cache and database |
| CN112835874A (en) * | 2021-03-25 | 2021-05-25 | 中国工商银行股份有限公司 | Active and standby database construction method, device and system |
Non-Patent Citations (1)
| Title |
|---|
| WEIXIN_38689857: "注册表中存储数据库链接字符串的方法", pages 1 - 3, Retrieved from the Internet <URL:https://download.csdn.net/download/weixin_38689857/13077468> * |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US7096231B2 (en) | Export engine which builds relational database directly from object model | |
| US7031987B2 (en) | Integrating tablespaces with different block sizes | |
| US9928255B2 (en) | Method for generating indexes for downloading data | |
| US8032544B2 (en) | Methods and apparatus for generating dynamic program files based on input queries that facilitate use of persistent query services | |
| EP0978061B1 (en) | Object graph editing context and methods of use | |
| US11526465B2 (en) | Generating hash trees for database schemas | |
| CN108475276A (en) | In-memory key-value store for multi-model databases | |
| EP0980554A1 (en) | System and method for storing and manipulating data in an information handling system | |
| US20150142734A1 (en) | Meta Model Driven Data Base Replication and Synchronization | |
| US6941309B2 (en) | Object integrated management system | |
| AU2017243870A1 (en) | "Methods and systems for database optimisation" | |
| CN105740383A (en) | Method and system for realizing data consistency of database and cache in big data platform | |
| US20080294673A1 (en) | Data transfer and storage based on meta-data | |
| US7958154B2 (en) | Apparatus, system, and method for command manager support for pluggable data formats | |
| US20250077494A1 (en) | Methods and systems for changing a database schema | |
| US20050114404A1 (en) | Database table version upload | |
| CN116910024A (en) | A method and system for data link string management | |
| US7958501B2 (en) | System to disclose the internal structure of persistent database objects | |
| CN116414843A (en) | Data updating method and device | |
| CN114356945A (en) | Data processing method, data processing device, computer equipment and storage medium | |
| CN113868138A (en) | Method, system, equipment and storage medium for acquiring test data | |
| CN119201982A (en) | A method and device for dynamically generating database scripts | |
| CN118260291A (en) | Autonomous comparison method, device, computer equipment and storage medium | |
| CN120763173A (en) | Data management method, device, equipment, medium and product | |
| CN119988444A (en) | Data query method, system, device and storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |