1&1 Mysql连接JAVA问题
我制作了一个 java 程序,其中用户将自动插入/选择行到一个 mysql 数据库中,但无法修改任何现有行、表、数据库或权限。我给自己建立了一个网站并将其托管在 1and1.com 上,但遗憾的是我发现一个数据库拥有多个用户并远程连接到数据库是一件痛苦的事情(不可能)。
我想知道我有什么选择?
我想第一个是找到另一台允许我执行此操作的主机。
我能想到的唯一其他选择是,我设法以某种方式将信息从 java 发送到我的网站,然后该网站连接到数据库。 (不是 php、html 或我必须做的任何事情的专家(通过在 GUI 上嵌入浏览器或在后台执行)。
这是我第一次尝试创建一个连接到在线数据库的程序,所以请
注意:程序在本地主机上运行。
1&1支持没用。
I made a java program in which users would be automatically inserted/selected lines into/from one mysql database, but could not modify any existing lines, tables, db, or privilages. I got myself a website and hosted it in 1and1.com, but sadly I found out that its a pain(impossible) to have multiple users for one database and to remotly connect to a database.
I was wondering what are my options here?
I suppose the first one would be to get another host that allows me to do this.
The only other option I can think of is that somehow I manage to send from java the information to my website, and then the website to connect to the database. (not an expert in php, html, or what ever i ahve to do (be by embbedding a browser on my GUI or by doing it under the hood).
This is my first attempt to create a program that connects to an online database, so please be nice.
Note: program worked in localhost.
1&1 support useless.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
几乎所有使用数据库的(Web)应用程序,整个应用程序都使用一个数据库用户连接到数据库。为应用程序的每个用户设置不同的数据库用户是一种不常见的设计。
因此,您应该配置一个数据库用户,应用程序使用该用户来读取或写入数据库;该数据库用户独立于您的应用程序的用户,并由您的应用程序的所有用户共享。从应用程序用户到数据库用户不应该存在一对一的映射。
这有不同的原因。其中之一是可扩展性。大多数数据库无法同时处理数千个连接。如果您有一个允许数千个并发用户的 Web 应用程序,您不希望每个用户都有一个具有唯一用户名的数据库连接。相反,您希望使用数据库连接数量有限的连接池;每当 Web 应用程序用户之一需要执行访问数据库的操作时,就会重用池中的连接。
Almost all (web)applications that use a database, connect to the database with one database user for the whole application. Having a different database user for each user of the application is an uncommon design.
So, you should configure one database user, which the application uses to read from or write to the database; this database user is independent of the users of your application and is shared by all users of your application. There should not be a one-to-one mapping from application users to database users.
There are different reasons for this. One of them is scalability. Most databases cannot handle thousands of connections at the same time. If you have a web app that allows thousands of concurrent users, you don't want to have a database connection with a unique username for each of those users. Instead you want to use a connection pool with a limited number of database connections; the connections in the pool are reused whenever one of the web app users needs to perform an action that accesses the database.