i was wondering, why does it have to be so complex to develop a swing application that works with a DBMS on java?
I would expect it to be as simple as it is to develop an android app with DBMS, which is pretty much straight forward with the android.database.sqlite package...
Specifically, i would like to know why would it make you connect to the DBMS with URL's and have to install so many background complicated things just to get it to start working?
and do you guys know of a java package that works similiar to the android package for DBMS? or is there a way to include this package and work with it in a regular java project?
I think you question is too generic.
You can use SQLite in Java SE/Java EE in various ways.
For example - have you taken a look here?
You should understand that the standard way to access relational DB is via JDBC.
Jdbc provides you an abstraction API for database access, and since it supports many DB vendors,
It has for example to support loading the property JDBC driver, which provides a vendor-specific implementation for the DB vendor in use (for example - mysql and oracle DB have different JDBC drivers).
As far as I know, this is not the case with Android - which currently has a single "DB provider" - SQLite, so in case of Android development you can skip the "Vendor driver loading" as you have one vendor.
However, there are various frameworks that allow you to simplify the work with relational database, such as spring-jdbc.
Your java program is possibly going to run on a windows, linux, apple (or other) box. It has the ability to connect to mysql, postgresql, sql server, oracle or sqllite. It needs to be able to connect under all those operating systems potentially to all those databases. This flexibility comes at a cost.
Your android app is going to run on the android os with the sqllite database. This can be baked into the os, making life easy for you. But that app won't run on iOS or WinPhone.
Related
I'd like to ask for your opinion on local databases for a java application i'm developing.
Its veterinary application, meaning I'll need to store Customer, Pet and Medical History details for a start. I know how to use JDBC but I've only used it online in applets.
So, I really dont know much about local solutions and how those gonna work when I'll publish the application in a .jar, so please guide me. Would MySQL still work?
Thanks!
This is fairly general question and light on details and MySQL sounds like it would work here. If this is for local-only access and a typical client-server model is not needed then I'd encourage looking into a database engine that can be loaded directly in the JVM. One of the benefits is that there is no need to install any separate database components and the JARs for the entire database engine can be packaged in your application.
Below are a few of these:
Apache Derby
HyperSQL
H2
SQLite - Some Java wrappers around the C library are available but there are not any pure Java JDBC drivers available for this that I am aware of.
I realize that it is not difficult for developers to configure MySQL for local use but it could lead to a number of support issues for end users. It may be possible to script the installation to preconfigure a large amount of it but I am not sure of the details of that and it would be an additional item for you to work out when packaging the application.
Some general questions about utilizing MySQL for this are shown below. It may very well be the best way to go but these are just some things to consider. Most of these are not really specific to the development of the application and are more on the support side of things. Utilizing a database engine noted above can eliminate all or many of these.
Will multiple computers every have to connect simultaneously to the same database?
What MySQL password do you use?
Do you recommend that end users all use the same one which may not be good security?
Or do the end users need to create one in which case you may need to deal with forgotten passwords and the end user having to configure the password in your application?
Do your end users run antivirus software that may interfere with the database connection?
What if they have another program that uses MySQL that is already using the default port?
i'm planning to start the development of a java desktop application with a database embedded. It will be an application without internet connection and just for that, to insert, update and delete data on the database. It will be a lot of data.
So, i would like to have your opinions, what libraries should i use to incorporate the database in the application to have good performances in the end? Should i use jdbc derby that's already incorporated with neatbeans?
Thanks in advance!
I been using Derby in production for years and it works well. The H2 database also looks good, it's supposed to offer better performance than Derby but I haven't used it in production. Both of these, along with HSQLDB are good choices as they are pure java, all you need to do is bundle the required jar files with your application. Sqlite and Berkely are fine products but not written in Java so I imagine these would be a little more difficult to work with.
You don't need any particular libraries. Each of the above databases should provide a JDBC driver which is the standard way of doing things. You can certainly use an ORM such as Hibernate as mentioned above. This makes some things simpler but if you're just starting out, it might be better to avoid this at first.
Some popular options are:
HSQLDB
BerkleyDB
Sqlite
Derby
Its impossible to say if they will be "fast enough", since its all relative. What is fast enough? How powerful is the host machine? How big is your dataset? Etc etc.
However, I can say I have seen really good performance from HSQLDB, with fairly large dataset (100K records +) on fairly moderate desktop machines. Sqlite I only explored for android, but its pretty impressive on this platform (considering the hardware it is running on).
I think you should do a little proof of concept, and test them out with some simulated data.
If Derby is available, I would use Derby. HSQLDB is another good option. For libraries, I would look at some library for database access. Spring comes to mind. If you have control of the database, I would look at an ORM mapping framework such as Hibernate.
This question already has answers here:
Java and SQLite [closed]
(9 answers)
Closed 7 years ago.
I need to build a Java application that I will install on a Linux server.
When people will install they just would need to install this application, launch it, and nothing more. But we have some data to save.
I said no to MySQL, because it needs a server.
I said no to XML because there will be really a lot of data to save and manipulate.
So I'm looking at SQLite which is the best I think. Indeed (stop me if i'm wrong), SQLite doesn't need any server? (just install the final application and SQLite works fine in my application?)
Then I checked at http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers and I'm really a little bit confused.
What is the difference between a Wrapper and a Driver?
Plus I see there exists a "pure java implementation": SQLJet is it more or less optimized?
Finally what would you use in my situation?
Another database to consider is H2. It is an embedded database engine completely written in Java so you have the benefit of full unicode (16 bit) character support that Sqlite does not have. Other embedded databases are HSQLDB and Derby.
sqlite doesnt need any requirement on the server ?
Correct. It does not. Neither does H2.
just install the final application and sqlite works fine in my application ?
Correct. As long as you include Sqlite or H2 in your WAR (or unpack it into your jar), it will work fine.
What is the difference between a Wrapper and a Driver ?
Depends on the usage. I think Sqlite is talking about the fact that when you use the JDBC driver for Sqlite, it is actually a wrapping of the Sqlite C native libraries inside the driver. Typically the JDBC driver talks to a remote database.
H2 also is that way with the "driver" actually doing the database operations just that it was written in Java so you don't need the C wrapper.
Plus I see there exists a "pure java implementation" : SQLJet is it more or less optimized?
This is the first I've heard of Sqljet so I'm not sure. The Xerial Sqlite driver is what I've used and it's performance seems to be good.
Finally what would you use in my situation?
I'd use H2 myself for the native Java features.
Yes SQLite doesn't require a server.
One very simple solution for development is using SQLLite by embedding it in your source code, with a little stub data. You can then commit your database to your version control system (i.e. I use github, its super easy to do this) as a single file. This is, obviously, not a good production method, but it is a good way to create a single development version.
A Wrapper is a program which facades another program by allowing you to access its functionality through a different interface. For example, eclipse "wraps" many java programs that we use in everyday development for us in a convenient GUI. Whereas a Driver is a program that is needed to launch an existing application. For example, in a java application, we might have a main class that can be thought of as a Driver for entry point to the application.
I am studying Information Technology at a local college. I am currently doing a Java project for one of my Modules. We are expected to make a Java application that communicates with a Microsoft Access database. I am working in a group, and all of us are assigned to code separate functions of the software. However, we need to share one database. We are currently using ODBC on our individual computers and are using JDBC to connect to the database on the local machine. What we have thought is to just work on separate Microsoft Access databases and then just combine them later on. But I think that's not the best way. Is there a way that will allow me and my group members to have a centralized database, to which all of us can connect and make our queries? Is this possible by hosting the Microsoft Access database somewhere online, and then connecting to it from inside the Java software. Please help me out, as I have no idea how to get a centralized Microsoft Access database.
If you want to get rid of this by using Microsoft Access is because that's the easiest way out for you and your group to solve this kind of problem but I'd rather suggest you to use the database using a database provided by Java Derby database, it's quite help you to short your code within the server. Maybe I will suggest you to use Netbeans as a GUI and the Derby to control the database.
So what's your core problem is that a programming side or configuration and control within the hosting ? Thanks
I have thought of creating my first database application for one of my projects using Oracle and Java. I have chosen Netbeans as my development environment. I have a few questions to getting started.
This will be a data intensive (yet still for a college project) database application. I do not need 1000 user concurrency or any other very advanced features but basic stuff such as triggers, stored procedures etc. Will the 11g "Express" (XE) suffice for my requirements?
Do i need any Java to Oracle bridge (database connectivity driver eg. ODBC etc) for Netbeans to connect to the oracle database? If yes, what are they? Does Netbeans support Oracle databases natively?
Any easy to follow guide on how do I connect to the database and insert/retrieve/display data on a J2SE application? (I know that i should Google this but if there's any guide previously followed by anyone and is considered easy, it would be greatly appreciated.)
There are several different ways to access databases using Java. I'm assuming you are wanting to use JDBC, which is included in all recent JDK's. There are other layers on top of JDBC like Hibernate that may make things cleaner for larger applications, but may also be too steep a learning curve if you have a project to complete and submit.
To answer your questions in order:
I think it's highly likely that Oracle 10g Express Edition will do what you need for a college project. It's pretty much the 10g Standard Edition with a 4GB limit on data size.
You will need a JDBC driver to access the database from Java. It comes with XE, and is installed in <XE client install dir>/jdbc/lib/ojdbc14.jar
Sun have an introduction to JDBC here.