简体   繁体   English

Raspberry pi上的数据库

[英]Database on Raspberry pi

I am working on a project where the raspberry pi (model B) runs JAVA application to connect to and retrieve data from a Router. 我正在研究一个项目,其中树莓派(模型B)运行JAVA应用程序以连接到路由器并从路由器检索数据。

What i want to know is the best approach or the best database that i should use to store that data retrieved from the router. 我想知道的是最好的方法或最好的数据库,用于存储从路由器检索到的数据。 Knowing that i will need to build another android application that should connect to that database (on the raspberry pi) and display that data. 知道我将需要构建另一个Android应用程序,该应用程序应连接到该数据库(在rapiberry pi上)并显示该数据。

So, what database that is compatible with the java application and the android application? 那么,哪个数据库与Java应用程序和android应用程序兼容?

Also, later on i wish i could run the RPI as a server that enables me to connect to that database from anywhere. 另外,稍后我希望我可以将RPI作为服务器运行,使我可以从任何地方连接到该数据库。

Keeping in mind that: I am new to Raspberry pi New to Database 请记住:我是Raspberry pi的新手

我建议您看看OrientDb是一个NoSql Java图形文档数据库(您可以选择),它也支持很多查询范例和一个Sql方言(您没有联接),速度快,轻便并且支持本机其余查询,我已经在raspberry pi上进行了测试(即使是在2/3 raspberry节点上的分布式多主模式下),它的性能也很好,令人高兴的是,它允许您以不同的方式进行思考,数据显示为一个Java对象通过HTTP在Json中通过rest范式向您公开,因此您可以使用html 5和诸如angularJs这样的jscript框架在客户端上考虑您的客户端应用程序(并且您可以直接在有效的数据库上“部署”静态资源)就像轻巧的应用服务器一样)

Almost All the Databases are Compatible with JAVA.And Hardly I belive that you will not have such privilege to choose Database while develop real time Application . 几乎所有数据库都与JAVA兼容。而且,我几乎不相信在开发实时应用程序时,您没有选择数据库的特权。

Java and Android Both are not different , both are same on a Pillar.There will be no problem because of using Database. Java和Android两者没有什么不同,在Pillar上都相同,因为使用数据库不会有问题。

我建议使用SQLite,因为Android本机使用它,并且不需要像* SQL之类的其他DBMS那样大量的资源

This answer follows the previous comments. 该答案遵循之前的评论。 Let's say : 比方说:

  • You have your router. 你有你的路由器。 Connected to it you have PC (with IP address called IP1) and your RPI with IP2. 与之连接的是PC(IP地址称为IP1)和RPI IP2。
  • On your RPI, I guess you have RaspBian. 在您的RPI上,我想您有RaspBian。 So with the package manager, you install mysql. 因此,使用包管理器安装mysql。 You create your desired database and tables. 您创建所需的数据库和表。
  • When using eclipse to access your database for testing purpose, or explore all data, I think you need to provide the jdbc driver, and configure the url of the db. 当使用eclipse访问您的数据库以进行测试或浏览所有数据时,我认为您需要提供jdbc驱动程序,并配置数据库的url。 Because you are running eclipse on your pc and you want to access the db hosted by the RPI, you should provide the IP2 address in the url. 因为您在PC上运行eclipse,并且要访问RPI托管的数据库,所以应在URL中提供IP2地址。
  • Because your Java app will run on RPI, you can set the url to "localhost". 因为您的Java应用程序将在RPI上运行,所以您可以将URL设置为“ localhost”。 See the following link : http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html 参见以下链接: http : //dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html
  • So, to sum up, eclipse and java app both need a mysql jdbc driver, configured the right way. 因此,总而言之,eclipse和java app都需要一个mysql jdbc驱动程序,并且配置正确。

  • Later, you'll want to access your db through your android app. 稍后,您将要通过android应用访问数据库。 You'll need to configure your router with port forwarding, to access your db from outside. 您需要使用端口转发配置路由器,以从外部访问数据库。 But this is out of topic. 但这是不合时宜的。 I let you search. 我让你搜索。

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

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