使用MySQL的Ormlite(Ormlite with MySQL)

编程入门 行业动态 更新时间:2024-10-26 01:18:39
使用MySQL的Ormlite(Ormlite with MySQL)

我正在开发需要数据库的Android应用程序。 我有Hibernate的经验,但我没有尝试过,因为我听说它对于android来说太过分了。

我按照这个很好的教程[1]来设置带有sqlite的ormlite。 但我需要使用像MySQL这样的真实数据库。 是否有任何关于使用MySQL与ormlite的好教程?

http://logic-explained.blogspot.com/2011/12/using-ormlite-in-android-projects.html

I'm developing android app that needs a DB. I had experience with Hibernate but I didn't try it because I'm hearing that it's too much for android.

I followed this nice tutorial [1] to setup ormlite with sqlite. But I need to use a real DB like MySQL. Is there any good tutorial out there for using MySQL with ormlite?

http://logic-explained.blogspot.com/2011/12/using-ormlite-in-android-projects.html

最满意答案

是否有任何关于使用MySQL与ormlite的好教程?

不,但您可以查看HelloAndroidH2示例程序,该程序在Android上使用JDBC连接到H2数据库:

http://ormlite.com/android/examples/

您可以使用ormlite-core和ormlite-jdbc软件包,而不是使用ormlite-core和ormlite-android软件包。 在示例程序中,您可以看到:

connectionSource = new JdbcConnectionSource( "jdbc:h2:/data/data/helloandroidh2/databases/helloAndroidH2");

该JDBC URI将H2数据库存储在本地Android存储上。 相反,您将使用类似以下内容作为数据库URI:

jdbc:mysql://my-database-host/my-database-name

这种方法让我担心的一件事是Android没有正式支持JDBC。 在下一个Android代码发布之前,您可能会发现工作正常。 仅供参考。

Is there any good tutorial out there for using MySQL with ormlite?

No, but you can look at the HelloAndroidH2 example program which uses JDBC on Android to connect to a H2 database:

http://ormlite.com/android/examples/

Instead of using the ormlite-core and ormlite-android packages, you would use the ormlite-core and ormlite-jdbc packages. In the example program you can see:

connectionSource = new JdbcConnectionSource( "jdbc:h2:/data/data/helloandroidh2/databases/helloAndroidH2");

That JDBC URI stores the H2 database on the local Android storage. Instead, you'd use something like the following as your database URI:

jdbc:mysql://my-database-host/my-database-name

One thing that worries me with this method is that JDBC is not officially supported by Android. You might find things working fine until the next Android code release. Just FYI.

更多推荐

android,ormlite,MySQL,Hibernate,电脑培训,计算机培训,IT培训"/> <meta name=&qu

本文发布于:2023-07-19 17:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1184003.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MySQL   Ormlite

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!