简体   繁体   English

如何从在线小程序访问jdbc驱动程序

[英]How to access the jdbc driver from an online applet

My applet queries a mysql database, so I included the connector J jar in the eclipse project libraries and my applet runs fine in eclipse, but when i put it on the website, I get an error about that jdbc driver. 我的applet查询一个mysql数据库,所以我在eclipse项目库中包含连接器J jar,我的applet在eclipse中运行正常,但是当我把它放在网站上时,我得到一个关于那个jdbc驱动程序的错误。 When I made the jar of my project from eclipse, I don't think that the jdbc driver was included in the jar, so how would I access the jar? 当我从eclipse制作我的项目的jar时,我不认为jdbc驱动程序包含在jar中,那么我将如何访问jar? Should I put the jdbc jar inside my project jar, or have my project jar access the driver stored in its own jar. 我应该将jdbc jar放在我的项目jar中,还是让我的项目jar访问存储在自己的jar中的驱动程序。

Right now, I am using 现在,我正在使用

<applet code="test.class" archive="math.jar" width=830 height=600 ></applet>

This isn't a good idea. 这不是一个好主意。 You don't want an applet to access a database directly. 您不希望applet直接访问数据库。 You'll have to expose that port on the public Internet - not a good idea. 你必须在公共互联网上公开这个端口 - 不是一个好主意。

A better thought would be to put a servlet in between the applet and the database. 更好的想法是将servlet放在applet和数据库之间。 Let the applet make the request to the servlet. 让applet向servlet发出请求。 It can deal with security, validation, binding, accessing the database, and marshalling the response. 它可以处理安全性,验证,绑定,访问数据库以及编组响应。

将所有来自jdbc.jar的类放入“math.jar”,或将其列在archive属性中: archive="math.jar,jdbc.jar"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM