动态选择数据库 [英] Select databases dynamically

查看:148
本文介绍了动态选择数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到了真正的砖墙,试图连接到动态数据库。我不知道如何实现这一点,

I ran into real brick wall trying to connect to dynamic databases. And I don't know how to achieve this,

这是我的过程,我有一个应用程序,它需要适应工作环境的变化,说If工作场所服务器崩溃,他们创建一个名为 db_new 的应用程序将连接到该数据库,而不是旧的数据库名称。

Here is my process, I have an application where it needs to be adaptable to changes in the work environment, say If the work places server crashes and they create a new database with the name db_new the application would connect to that instead of the old database name.

我已经有一个窗口,在列表框中显示服务器上的数据库,用户可以在其中指定应用程序使用哪个数据库。但问题是,如何保存选定的数据库名称,以便它可以在选择新数据库后运行? ..

I already have a window that displays the databases from the server on a listbox where the user can specify which database to use for the application. But the issue is, how can I save the selected database name so that it can run after the new database is selected? ..

在管理员应该能够更改应用程序使用的数据库,如果必要的话,应用程序应该继续使用所选的数据库,直到管理员将其更改回一个新的。

as in the administrator should be able to change the database the application uses if necessary and the application should keep on using that selected database till the administrator changes it back to a new one.

请原谅如果问题有点模糊,我只是把它放在一起在最好的方式,我可以,任何帮助,这将是真的很棒:)

Please forgive if the question a bit vague, I just put it together in the best way I could, any help on this would be really great :)

EDIT:

我不能使用文本文件或xml作为应用程序使用的数据库名称应以安全的方式存储。 :)

And I cannot use text files or xml s as the database name the application uses should be stored in a secure manner. :)

推荐答案

首先,您可以非常容易地使用文本或XML文件:如果将信息存储在文件,这不能由用户下载(我假设你会),这是安全的,因为它可以是:如果有人设法打破服务器并读取文件,它的游戏结束

First of all, you can very easily use a text or XML file: If you store the information in a file, that can't be downloaded by the user (as I assume you would), this is as safe as it can be: If somebody manages to break into the server and read the file, it's game over anyway.

也就是说,我建议您使用MySQL代理或类似的机制,指向您的Web应用程序 - 故障转移到另一个数据库或更改基础数据库然后在代理层处理,而WebApp甚至不知道它:功能不需要是您的应用程序的一部分,在我的书中,它不应该。

That said, I would recommend you use MySQL proxy or a similar mechanism and point your WebApp at it - failing over to another database or changing the underlying database could then be handled at the proxy layer without the WebApp even knowing about it: The functionality need not be part of your application and in my book it shouldn't.

这篇关于动态选择数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆