I happened to be in a Java project though I am .net developer. Also heard lot about EJB. Is it equivalent to ADO.NET in Java?
ADO.NET is what JDBC is for Java. EJB adds an ORM above that.
No, it's far more.
ADO is designed for database access from ASP, which is only a part of what EJB is designed to accomplish. EJB also hosts all your business logic (which in a typical ASP application would be coded into the ASP directly, a practice Java EE strongly discourages).
EJB has to be hosted in application server which provides enterprise services like COM+. So you can realate EJB to COM+, but COM is langauge netutral(can be called from any langauge) whreae Java bean is not langauge neutral outside JVM.
The Java Database Connectivity (JDBC) API is the industry standard for database-independent connectivity between the Java programming language and a wide range of databases SQL databases and other tabular data sources. It provides methods to query and update data in a database, and is oriented towards relational databases - exactly the same as ADO.NET (for .NET)
ADO.Net is a set of API and engine for caching structured data in memory and able to sync those data into a database e.g. MS SQL. As I know, there are not equivalent API/Engine in Java. The closest to ADO.Net is HSQLDB with in-memory mode, but create table and fields must be done through SQL statements (where ADO.Net provides API for creating its internal datatable, relation and etc.)
Related
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.
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 am dealing with quite an interesting challenge, we have an integration project that needs to interconnect the "in development" application with legacy applications. We developed a proxy that calls the legacy application from the new application and now we need to test or development against the code of a third company. I order to do that we setup a server with the same setup as the productive server and we will connect the client application to this server for testing purposes.
Application rough involved technologies: Java EE 6, Postgresql, java 7, JPA 2, Hibernate, Jboss 7
My issue is that we need to populate the DB with pseudo-real data. Meaning data that can be generated and is appropriate from the point of view of the application. The data must be somehow real as it reacts to different notifications sent by the legacy applications suite via JMS. The concerns are that it should be simple, quick to implement and somehow to create a mechanism for easy reusage - whenever I need new data, just run it once (maybe with parameters?!) and the magic is done.
Currently I try to find the best approach, I considered the following up to know:
plain SQL script
java application that inserts the needed things in DB
somehow exciting idea - use a scripting language to have the job done (which one - python, groovy)
Any idea, suggestion, question would be more than welcomed.
Maybe you should use DBUnit it has an XLSImporter. So you can maintain your test data in an Excel file.
I order to populate the DB I built a tool on top of the application's public API that creates the needed entities. To make it easier for our customer to add the needed data I exposed appropriate methods as WS that can be called as wanted by the client.
I wrote the application in java, for subjective reasons, even if I consider that a scripting language - I suppose groovy - would've been the best choice.
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