如何存储数据的Java小程序 [英] How to store data for a java applet

查看:242
本文介绍了如何存储数据的Java小程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个Java小程序需要访问静态数据是大小约为600K。这个数据是从SQL数据库中导出。在什么是最好的格式存储在这些数据(XML,JSON,Java的包含文件),得到它最快/最简单的访问。我是一个完整的Java小白这个问题可能是愚蠢的,但有在为编译这个数据为可执行所以有服务器没有额外的要求,一旦小程序加载的方法。在此先感谢!

I have to create a java applet that needs to access static data which is around 600k in size. This data is exported from an sql database. What is the the best format for that data to be stored in (xml, json, java include file), to get fastest/easiest access to it. I am a complete java noob and this question might be stupid, but is there a way to 'compile' this data in to executable so there are no additional requests to server once the applet is loaded. Thanks in advance!

推荐答案

我不知道你是什么意思,当你提到Java的包含文件。

I do not know what do you mean when you mention 'java include file'.

所有剩下的就是确定。您可以使用XML或JSON。这取决于你的需求和品味。只要记住,JDK已经内置的工具来解析XML和不具备这样的工具JSON,所以你必须添加外部依赖(例如GSON)。通常它是没有问题的,但有时code尺寸可以是用于被预期要被下载从服务器到客户端小应用程序很重要。

All the rest is OK. You can use either XML or JSON. It depends on your needs and taste. Just remember that JDK has built-in tools to parse XML and does not have such tools for JSON, so you will have to add external dependency (e.g. GSON). Generally it is not a problem but sometimes code size may be important for applets that are expected to be downloaded from server to client.

的其他问题与applet是未签名的Applet无法写入客户机的磁盘。因此,无论格式你选择你需要的地方存储信息。你可以将其存储在服务器上,但服务器可以访问DB无论如何,所以为什么要创建副本?

The other problems with applets is that unsigned applet cannot write to client's disk. So, whatever format you choose you have to store the information somewhere. You can store it on server, but server has access to DB anyway, so why to create copy?

所以,我的建议如下。在数据库中存储数据。创建服务器端组件(网络服务),让你的小程序访问数据。小程序应存储在浏览器cookie的用户ID,所以下一次用户运行它会自动进入小程序。

So, my suggestion is the following. Store data in database. Create server side component (web service) that allows your applet to access the data. Applet should store in browser cookies user id, so next time user runs the applet it enters automatically.

要访问浏览器从applet的用户cookie的实时连接,并记住,applet标记应该有MAYSCRIPT属性。

To access browser cookie from applet user live connect and remember that applet tag should have MAYSCRIPT attribute.

这篇关于如何存储数据的Java小程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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