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...
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 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.)
We are occasionally in a position to take over PHP based projects, but as we are a Java-house we are searching for ways to turn a PHP-project (or codebase) into a Java-project.
The approaches we came up to work in a mixed Java/PHP context are :
PHP in frontend and Java in backend with separate front (PHP+JavaScript) and back (Java+SQL) teams
using both technologies in a Java webapp, for example via Quercus with one or multiple teams
migrating everything to Java
We haven't tried any of these approaches as we've been lucky enough to have enough Java-only projects to work on.
Do you see other approaches, or have you tried any of the described approaches?
I've used Quercus. I think that if it supports something like Drupal then it's probably fairly mature. If your PHP app works out of the box, then it offers you a very gradual upgrade path to Java since you can write your own plugins in Java and expose them to the PHP layer, such as using a JDBC back-end.
How easy it is all depends on how well separated the layers are in the PHP application. For example, if the view layer is well separated, you might be able to replace both controller and model logic with a Spring MVC application that uses a 'QuercusView' for the view - you may be able to re-use a lot of the PHP view logic.
You should also consider how you can make a survey of the PHP code - maybe a script that extracts all the function calls, imports etc. so you can quickly test the Quercus support for them.
Sorry, I haven't used the PHP-Java bridge, but I think the Quercus library is pretty mature these days, so that would be my first choice for a staged migration.
My experiences with Querces are not so good. Maybe it has improved, but when I tried it something like two years ago (a long time, I know) it was far from complete and did not support all functions yet. Also, if your application is using some extensions (e.g. from PECL) you will experience difficulties getting this up and running under Querces.
We're currently in the process of migrating a web application from PHP to Java. We're designing a SOA and we'll probably replace some data access objects in the PHP application with a version that talks to internal webservices. Currently we're using Thrift as protocol for our internal webservices, a framework that also has a client available for PHP. We expect this to increase flexibility during migration (allowing us to do step-by-step migration, rather than all-at-once)
PHP/Java Bridge may be of your interest:
The PHP/Java Bridge is an
implementation of a streaming,
XML-based network protocol, which can
be used to connect a native script
engine, for example PHP, Scheme or
Python, with a Java virtual machine.
It is up to 50 times faster than local
RPC via SOAP, requires less resources
on the web-server side. It is faster
and more reliable than direct
communication via the Java Native
Interface, and it requires no
additional components to invoke Java
procedures from PHP or PHP procedures
from Java.
NUMITON may be useful for you:
http://java.dzone.com/announcements/automated-translations-php-jav
The shortest route from PHP to Java
Numiton offers an automated alternative to migrating PHP codebase. This way,
established applications can benefit from the advantages offered by Java in its
enterprise-level capacity.
Some of the risks inherent to any software migration are avoided by using an automated
translation tool. Our PHPtoJava product performs variable type inference,
objectualization and other operations in a uniform manner, the resulting appearance and
behavior being identical to what the users already know.
Of course, the human factor still plays an important role in the post-translation
phases: application fine-tuning and functional testing. The speed and accuracy of the
entire process surpass however those of a manual translation.
One of the applications we have migrated this way is the well-known forum engine
phpBB. The translation result, nBB2, powers our own forum and was recently donated to the
open-source community as a SourceForge project.
PHP in frontend and Java in backend
with separate front (PHP+JavaScript)
and back (Java+SQL) teams
This is technically feasible using SOAP.
using both technologies in a Java
webapp, for example via Quercus with
one or multiple teams
I have no idea about this
migrating everything to Java
This is better option, but it will take time depending on the size & complexity of your project.
I do not have any experience running PHP inside a JVM, but I am betting that IBM does. :)
You might consider Project Zero.
http://www.projectzero.org/php/
Seems similar to Querces or that other thing someone linked. The only other thing that you didn't mention that I can think of is to refactor the PHP code because I'm assuming that its an older codebase written in a PHP 4 manner.
I know this is 2 years old question but i still want to contribute. We are migrating from full java portal to php+java. We have 14 million users. This design doesn't need web services because we use java as json provider for php and js. We will see the result soon...
PHP in frontend and Java in backend with separate front
(PHP+JavaScript) and back (Java+SQL) teams
I have came from another question to this one:
How can one start with Java (JVM) ecosystem? What are beginner, intermediate and advanced knowledge-bases (bags!)? To be honest Java ecosystem was always a bit confusing to me, so it would be very helpful to provide some "reference references" and "defacto tutorials" for learning (curve!) JVM.
Note: I want to use JVM with Scala (or Clojure) but not Java itself.
I am a C# developer (WPF, Windows Forms, ASP.NET, Web Services, ... like that).
The Java Tutorial is a good place to start.
Update: you have enough questions for about a dozen posts here ;-) Honestly, you should do some research yourself (Google is your friend), then ask more specific, targeted questions; that would yield better results. (e.g. I don't think anyone can answer your question regarding Swing or JavaFX without more specific details about what you are trying to achieve.) I try to give a few pointers below, about areas I know to some extent.
for servlets and other web frameworks, here is a bunch of tutorials.
Tomcat and Jetty are both application servers.
there are a lot of different web frameworks, because different people have differing preferences, ideas and style, so many have created their own framework. It can be confusing, but at least there is choice :-)
for persistence, apart from JDBC, ORM frameworks are another strong option. I use Hibernate and I can recommend it; in a bigger project it can make your life much easier. Ultimately it depends on your specific project and constraints; there is no single right choice.
AFAIK Java has no equivalent of LINQ.
See also this post for further recommendations.
Java based web applications need to run inside of a web container such as Jetty or Tomcat.
You build your app and deploy it to the container which hosts the application at runtime.
Pure/plain JDBC should only be used directly by simple applications or integration layers that do not have access to the class model.
Most applications that I have seen have used some kind of Object Relational Mapping framework which models the entities as classes at a higher level than plain old JDBC.
Popular O/R frameworks include:
hibernate
toplink
datanucleus
cayenne
For web based development, you could start with AppFuse, see the quickstart guide.
AppFuse is a templating system that generates the skeleton of an application for you.
Then look deeper into what has been generated, and see what frameworks they are using.
AppFuse lets you choose between different technology stacks, so you could compare.
I haven't seen AppFuse support for Guice or GWT.
Guice is a Dependency Injection framework, others that could be used instead are Spring or picocontainer.
Another investigative approach that you could try would be starting with AndroMDA, which is a model driven architecture framework - you start with a UML model and then generate or forward engineer a working application.
AndroMDA also lets you control the choice of the underlying framework implementations by configuring different cartridges, once again you should dig deeper to see what they are using in the generated application.
If you are looking for a basic introduction, then the Java Tutorials are nice. To do other things like Java Web Development, then your going to need to consult google for the respective technology since they vary so widely.
One book though that I highly recommend taking a look at is Java Concurrency in Practice
Yeah, it is almost impossible for new guys to get started. This is going to drive away a lot of developers, and Java is in danger of not having constant new bloods. The old farts would love that, it's great for career security, and that's why they are making Java more and more complicated.
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