My company has a product that we sell as a solution to mediocre firms, they are ok with using java but they have different opinions on db due to licensing and other technical/resource issues.
I was wondering if there is a way i can create the app in such a way that during installation we configure the database (select weather mysql/oracle and input/generate connection strings, allocate driver, e.t.c.) and it works similarly as the other db. I have heard about hibernate being able to generate table but havent ever worked on it before.
I need an opinion and if possible reference to a guide. thank you in advanced. sorry for a stupid question, i only know basics of java, haven't yet worked on ORM or any other framework.
Yes,
The JPA (java persistance API) allows you to do what you're looking for. You will be needing a JPA provider (such as hibernate, Apache OpenJPA or eclipse link among others).
You will be able to automatically create the schema of your database according to the objects you need to map into it.
Here are few links to get started:
https://docs.oracle.com/javaee/6/tutorial/doc/bnbpz.html
https://www.tutorialspoint.com/jpa/
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/SettingUpJPA/SettingUpJPA.htm
Many JPA ressources will point to java ee ressources and tutorials, since it is heavily used with java entreprise edition, but the API itself can be used with the standard java platform.
Related
I'm creating a java desktop application using swing which requires some database persistance for which I'm planning to use Hibernate. I'm pretty new to desktop application development so I wanted to know if and how the database can be created on the client computer when installed.
Is there a script to be run or maybe a hibernate configuration which initiates database creation?
A sample tutorial or example illustrating this will be ideal (although I was not able to find one).
Thanks in advance for any help provided.
Hibernate is not an database server itself, it is a object-relational mapping framework so you need a either embedded or stanalone database server. Java DB that comes with the JDK will be sufficent for desktop applications.
http://hamidseta.blogspot.in/2008/05/install-mysql-server-50-silently.html
In your package installer scripts perform the steps of silent MySql installation. In the BAT file put the code you find in the above link before triggering your Java application installer.
As per free licensing terms, one should not package MySql bundle for free, just check about the licensing if you bother.
I think it would be better if you can start with javaDB or SQLite.
They are perferred embedded database technologies for desktop java applications.
You can download the jar for sqlite-jdbc from here.
Take a look at few tutorials on JDBC
If you making swing applications, make sure you learn to use swing worker well. It will
be important to perform background processing.
Hibernate is Framework used as middle layer in project which interact between database and Business layer logic.
Hibernate features
J2EE integration
Object/Relational mapping
Automatic primary key generation
Object-oriented query language
So my suggestion is to go with MySQL because
Handles large databases. We use MySQL Server with databases that contain 50 million records. We also know of users who use MySQL Server with 60,000 tables and about 5,000,000,000 rows.
A very fast thread-based memory allocation system.
Very fast joins using an optimized one-sweep multi-join.
The server can provide error messages to clients in many languages.
This is only few features but you go to official site for more detail. And most important it's open source.
And the post help to install and configure on client system.
I was wondering why there are so many technologies to access DB in .Net, including ADO.net, OLE DB, ODBC etc. In the modern world now, It is commonly to use OR mapping framework like Entity Framework, Nhibernate etc.
But In Java world , There only exist one API to access DB. It is called JDBC. It is simple and enough. It is well appreciated.
So I was thinking Is there any possibility to intercept the behavior of accessing DB in .Net world No matter what technology has been used. So I can inject some code before or after them. thanks!
In Java you have also many different technologies: JDBC, Hibernate, JDO, JPA to name only the most popular.
The main difference between Java and .NET is that in Java everything (except JDBC) is an external library whereas is .NET all technologies are bundled with the SDK.
Therefore it looks like .NET has many different technologies. Basically the different technologies are only evolutions...
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.
I have written a relatively simple Java App Engine application which I would like to be able to port to another cloud provider.
I am using the JDO datastore API so I think my data handling should be portable to other backends as listed here: http://www.datanucleus.org/products/accessplatform/index.html
I would ideally like to deploy my application onto EC2 with minimal code changes. What is my best approach?
Note: I am aware of the http://code.google.com/p/appscale/ project but I want to avoid using this as it doesn't look like they are updating very often.
AppScale remains your best option to avoid rewriting any code. They do keep up to date with official App Engine - for instance, they just released preliminary support for Go. Even if they weren't so assiduous at keeping up to date, though, this would only be relevant if some feature you required wasn't yet supported - and it sounds like your needs are fairly basic.
JDO should be trivial, there might be some Google specific configuration here and there but generally it should be easy. The storage model Google promotes is not bad for RDBMS either, but you might need to fine tune your model depending on the backend you end up with.
If you're not using the low-level Google APIs, you should be pretty much there.
I managed to get my application working on EC2 using the following components.
Tomcat 7
Datanucelus
HBase
I had to manually create a table in HBase for each of my data classes but was able to configure Datanucleus to auto create the columns.
I also had to change my primary key value generation strategy from identity to increment as per this table of supported features.
http://www.datanucleus.org/products/accessplatform_3_0/datastore_features.html
I am looking for some advice on what should I concentrate my efforts to get the needed skills to become a Java developer for Oracle applications. I'm bit confused as there are lot of technologies in the Java world. Where should I start? What to avoid? Is JDeveloper a good IDE for a beginner?
You're question is a little bit too vague in order to give a proper answer...
If you plan to query the Oracle Database from an External Java Program (Either within a Swing Application or an Application Server) then you need to learn 2 core APIs:
JDBC (Java Database Connectivity)
JPA (Java Persistence API)
JDBC is the core API that allows a Java Program to interact with any RDBMS so you should at least know how it works so whenever you have to dig into low-level code, you will actually know what's happening.
JPA is the latest Java API for Persistence which basically allows one to map Plain Old Java Object (AKA PoJo) to RDBMS Table Structures. There are multiple known implementation available but I would recommend Hibernate or TopLink as good starting points.
After that, you can start to dig into other known frameworks like the Spring Framework for some other RDBMS related APIs.
To become an Oracle Developer there is a bit more to learn than jdbc. You should take a look at the Oracle web site. It is kind of slow and not very intuitive but has a lot of good information. There are OUGs that have good info as well.
If you just want to access Oracle via JAVA then you should use a framework such as Spring. Takes away the pain of jdbc. Lets you write sql and map it to objects.
If you don't know PL/SQL it might be good to learn what it is.
My two cents from working with Oracle for the past 7 yrs.
You should be able to do everything related to Oracle using JDBC, so make sure you bone up on that API. Other than that, it depends on the type of application. Standalone apps may use Swing (the Java UI toolkit) or in the future JavaFX, which is supposed to make Swing obsolete and may do so in a few years. Web/enterprisey apps will make use of Java Enterprise Edition, so take a look at the servlet API, and if the app uses Enterprise JavaBeans, look at the Java Persistence API, which you would probably be using instead of JDBC.
I haven't used JDeveloper, but I haven't found anything wrong with the free IDEs like Eclipse or Netbeans, and my personal favorite is JetBrains's IntelliJ IDEA.
There's really nothing specific you need to learn to be an oracle devloper per se. Obviously you need to learn oracle sql syntax, and all the standard rdbms theory that goes along with database programming in general. The Java libs for database support are pretty easy to pick up and run with. I'm sure you can find a tutorial on the web by a quick google search.
As for IDE I'd recommend Eclipse. It's a bit cumbersome at times, but the number of plug-ins available is staggering, and it has great refactoring and code completion support.
Expert Oracle JDBC Programming is a book aimed directly at developers who want to use Java with Oracle. Before you make even that small monetary investment though, you might want to check out the JDBC tutorial published by Sun.
You can use JDeveloper and try to find some tutorials for it (I actually had some from my university). It integrates well with rest of Oracle stack (db and application server). Down site is that although you can download some developers editions to run for personal usage, running Oracle db + Oracle application server + JDeveloper on a machine that has less then 4GB of ram and one core is not really peasant experience.
Your question is very simple so I have listed a few simple steps to start developing a Java application using Oracle technologies.
Install Oracle XE Database.
Install [JDeveloper]. Choose the install with Weblogic if you are developing a J2EE application.
Build and run a jdbc application using the [sample code] or use the wizard in JDeveloper.
Install SQL Developer for writing stored procedures.
Steps 3. and 4. are optional. You now have everything you need to build either a proof of concept or an enterprise grade database application, using simple wizards and without re-inventing the wheel.
You mentioned developing an Oracle Application. It's best to leave the development of Oracle's packaged Application to Oracle itself but if you want to integrate your custom java application with Oracle's packaged application then use Oracle's SOA Suite.
Cheers
KB