使用 JApplet 访问使用 Netbeans 6.5.1 的 Web 应用程序上的数据库时出现问题

发布于 2024-07-18 14:19:19 字数 165 浏览 2 评论 0原文

我使用 Netbeans 6.5.1 创建了一个访问数据库的 JApplet。 当程序自己运行时,它运行得很好。 问题是当您尝试使用 Netbeans 中的 Web 应用程序将其联机时,它不会访问数据库。 有人告诉我,问题是 Java 安全性不允许你这样做。 它是否正确? 我该如何解决这个问题? 谢谢。

I created a JApplet using Netbeans 6.5.1 that accesses a database. When the program is run by itself, it runs perfectly. The issue is when you try to put it online using a web application in Netbeans, it will not access the database. I was told by somebody that the problem is that Java security will not allow you to do this. Is this correct? How do I fix this problem? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

葵雨 2024-07-25 14:19:19

正如已经提到的,未签名的 applet 只能与该 applet 所在的主机建立网络连接。 但是,如果数据库托管在与原始小程序不同的服务器上,那么您必须对小程序进行签名。 如果应用程序不用于生产用途,您可以对小程序进行自签名(不适合生产用途,其中签名必须由受信任的证书颁发机构完成。证书颁发机构通常会收取验证其客户凭据的服务费用。 )但是,出于测试和演示目的,您可以创建自签名证书。 对于自签名证书,浏览器会向用户显示一条警告,指出自签名证书中给出的信息尚未经过受信任的第三方(证书颁发机构)的验证。

对于自签名小程序,请查看以下链接:

http:// /java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html

http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html

其他需要记住的事情是要使用的 JDBC 驱动程序类型。 Type-1 和 Type-2 驱动程序不适合在 applet 中使用,因为它们依赖于本机二进制代码。 Type-3 和 Type-4 是您应该用来从小程序内连接到数据库的类型。

最好的解决方案是不要从小程序建立数据库连接(如果可能),而是使用服务器端应用程序代表小程序连接到数据库。

As already mentioned, an unsigned applet can only make network connection to the host from which the applet originated. However, if the database is hosted on a different server than the originating applet then you will have to make the applet signed. If the application is not for production use, you can self sign the applet (not suitable in production use where the signing has to be done by a trusted Certificate Authority. Certificate authorities typically charge a fee for the service of validating their clients' credentials.) However, for testing and demo purposes, you can create a self-signed certificate. With self-signed certificates, the browser displays a warning to the user mentioning that the information given in a self-signed certificate has not been validated by a trusted third party (Certificate Authority).

For self signing the applet take a look at the following links:

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html

http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html

The other things to keep in mind are the JDBC driver types to use. Type-1 and Type-2 drivers are not suitable to be used within applet due their dependence on native binary code. Type-3 and Type-4 are ones you should be using to connect to database from within an applet.

The best solution is to NOT make database connection from an applet (if possible) but instead use a server side application to connect to the database on behalf of the applet.

千鲤 2024-07-25 14:19:19

正如克林特指出的那样,小程序只允许连接到它的原始服务器。
要解决此问题,您可以使用根颁发机构颁发的证书对您的小程序进行签名,但证书费用为 200-400 美元/年。

as Clint pointed out, an applet is only allowed to connect to it's origin server.
to work around this, you can sign your applet with a certificate from a root authority, but certificates cost 200-400$/year.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文