I was thinking of making an Android Application, a Cook Book for example, that can be semi-online. Meaning the Application doesn't have to be online but it can be. An example would be that the users want to share recipes with other people on the network.
I'm going to use Java as the backend of the system, so I was thinking of using JDBC. Is that possible?
In android you can use sqlite database for your data storage or you can also use and Shared Preference it is are like java properties follow beloow link for quick reference of all...
for sqlite
http://www.vogella.com/articles/AndroidSQLite/article.html
for Shared Preference
http://www.vogella.com/articles/AndroidFileBasedPersistence/article.html
You cannot use jdbc in Android.For apps requiring your data to be stored in some persistent storage,Android devices comes with in built SQLITE database where you can insert,update,delete and perform various operations on table created in it.
You can ask if you have any further queries.
Related
I'm currently getting into Socket Programming and building a multi-threaded console application where I need to register/login users. The data needs to be saved locally, but I can not seem find the right structure for it.
Here are the ideas I though about:
Simply saving the data to .txt file. (will be troublesome to search and authenticate the logins)
Using the Java Preferences API but since the application is multi-threaded I keep on overwriting the data each time a new client connects to my server. Can I create a new node for each new user?
What do you guys think is the ideal structure for saving login credentials? (security isn't currently a concern for this application)
I would consider the H2 database engine.
quote:"Very fast, open source, JDBC API Embedded and server modes; in-memory
databases Browser based Console application Small footprint: around 2
MB jar file size"
http://www.h2database.com
It really depends on what you want to do with the application. The result would be different, depending on what you would answer to the following questions:
Do you want/need to persist the databases?
Is there any other data which you need to store along with that?
are you using plain java or a framework like Spring?
Some options:
if you're just prototyping and you don't have any persistence: consider using an in-memory storage for it. For simplicity in coding/dependencies, something like a ConcurrentMap can be completely sufficient. If you wrap it properly, you can exchange it later - and you don't add dependencies and complexities at an early state.
If you're prototyping but you still need persistence, using properties files on top of the ConcurrentMaps can give you a quick win.
There might be some more stages to this, depending on where you want to go with this, choosing a database at one point can be an option. Depending on your experience and needs, you can use a SQL or NoSQL database. Personally, I get faster results with NoSQL (MongoDB in my case) but prefer SQL in production for use cases like account management.
I am working on Calendar-Project in Codename one and I want to store my events in a database so I just want to ask that can I use Realm to store my event data. Can Codename one support Realm framework?, And if it is not, then there is any other option which replaces Realm?
As far as I know nobody has ported Realm to Codename One. You could potentially port it using native interfaces, but before spending time on that, I would probably look at the existing cross-platform database options that Codename One already supports.
Existing built-in options include Storage, File System, and SQL, which are all discussed in the developer guide.
I generally try to use Storage if possible as it is very simple and the most portable. If you really need an SQL database, then use the SQL facilities.
I also developed a data access library to provide an extra layer of encapsulation on top of SQL. It provides some nice features like database versioning/updating, and DAO (data access objects) so that you don't have to use SQL for such routine tasks of loading, searching, and saving objects.
On the server-side, you can use any REST interface. E.g. you can set a Java web service with a MySQL database, or a PHP-powered webservice using Xataface, or use a BaaS using the Parse CN1lib.
If you're doing a calendar App, you might also want to explore using Google Docs as your data store as they provide good REST APIs for interacting with calendars.
Lots of options available to you.
I'm currently building my first Android app and I've gotten to the point where i need to think about data storage. My app is built to assist in the drafting of a fantasy football team so it uses a large roster of 200-400 players each with individual projections, names, positions, teams, etc.
Though the app is sufficient to edit, add, and delete players and projections from rosters it definitely is not built to create a roster from the ground up so i'm going to include a default roster with the app. I would like users to be able to save and load the modifications they make to the default roster as well as download updated projections from online.
The only experience I have with databases is a remote MySQL db used in a web programming class. Is a DB appropriate for what I'm trying to do? Is there a way to store different versions of a database/table so users can have multiple rosters or download updates? Is this a better job for just a serialized JSON object? Or both?
Any help or suggestions would be greatly appreciated! Thanks guys
Unless your data is trivial, using Sqlite (Android's default DB engine) is the recommended storage approach for structured data.
JSON is useful for exchanging data with a server.
I have prepared an application that is a small demo of Student information manipulation. I have stored information related to students in a MySQL DB. Now my application is working 100% on my computer. But I want that work everywhere without depending on Database! I mean I just want "WHEREVER MY .JAR FILE GOES, DATABASE SHOULD ALSO GO ALONG WITH THAT INSIDE .JAR FILE "
So anyone who is using my application or trying it, they can realize exact result of this application.
How can I make this possible? Please someone help me.
You will probably need to look at something like HyperSQL, which is a in-memory database (which you will need to populate at application start-up). Or have a look at SQLite, which is an embedded databsase, which you can distribute as a resource in your jar.
This doesn't work. MySQL is a full-blown RDBMS. You would have to install it on every computer if you want application to use it locally. An alternative would be using SQLite.
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
SQLite and Java
SQLite seems to be a good fit for your requirements.
I am making a desktop application in java and using MSAccess in data base.
I want that if i run the setup of the application the database should be created on client machine because there can be different client using the application and how can i create the setup?
is there any tools available for this free of cost?
please explain me in detail..
thanks
Java 6 (enhanced for desktop application work) comes with a built-in database called JavaDb (formerly IBM's Derby). That will do what you want.
Here's a set of guides and tutorials on how to use it.
I would suggest that when your application first starts, it checks for the presence of the created database, and if it doesn't exist, it builds the database (via the appropriate SQL). I've used this approach before and it works quite well.
I prefer nullsoft. Take a look at Open Source Installers Generators in Java
#pratap: database should be created on client machine..
Add an empty access database to your setup.
Have a look at SQLite, which is used by Mozilla (Firefox stores all bookmarks and history in a database) and several other major applications.
When you say
access in database
do you mean Microsoft Access or access the data in a database.
I would advise against MS Access if that is the case. If not, you could either use the JavaDB or HSQLDB and the use SQL scripts to create the database. As a summary
Package the application in one of the installers (InnoSetup or NSIS are good ones)
When installing, extract all the files in proper folders
Execute the SQL scripts before first running the application to ensure the database is setup, you can do other housekeeping tasks along with this step (refer to installer documentation for after-install steps)
Your application is good to go
In the last distribution of NetBeans I used, there was a wizard to create such application. The application used the Java Persistence API to store the Data.
My option is HSQLDB since it's fast, reliable and easy to use.
In the documentation it's explained how to use the standalone database mode, this is primarily used for unit testing but it fits your case too. The good thing with this is that you just connect to the file based database without any special set up and if the files doesn't exist, they're created.
I would second the posters who recommend JavaDB.
It is absurdly easy to adminster from inside your application. Whats more because everything is native Java you dont get the char->unicode little-endian->big-endien and all the other conversion malarky you normally get when reading SQL into java.
The one tip is that with JavaDB is prepare your SQL statements. Prepared statements get cached and the resulting access program (similar to an access plan but actually a jvm program) is reused, the programs for "executed' statements are not cached.
If you are really set on MSAccess then I would suggest you package an "default.mdb" file with all your required tables defined and your classifcation tables populated. If the user's table does not exist then simply copy over the default .mdb file and open that.
I recommend the H2 database because it is simple, fast, pure Java, and small. See this page for how H2 compares to other Java databases, including those mentioned here in other answers. It has many features Derby/JavaDB and HSQLDB do not.