2

So I am attempting to make an application based on the architecture proposed by this image;

Java3-Tier Image
(source: ibm.com)
[1]

However, I am getting very confused with how data access is achieved between the data access layer which is on a seperate tier (from my understanding this means a seperate server/machine) to the database. Say I have my hibernate config file;

    <property name="hibernate.connection.username">root</property>  
    <property name="hibernate.connection.password">.......</property>  
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306</property>

...etc

How, if Hibernate etc and the DB are on seperate servers can I possibly extract the data from the DB into my business logic layer using my DAL. Other than setting up JDBC and the MySQL server instance to use a remote connection, but its my understanding that it is bad practice to do this.

What is it that I am missing here?

2
  • Have you attempted to do this and cannot get it to work?
    – Bernard
    Jul 15, 2015 at 0:45
  • Well I am thinkikng, no point attempting to follow it if I cannot make sense of it =/
    – FinalFind
    Jul 15, 2015 at 1:29

1 Answer 1

3

In an app like this the "tiers" are usually various parts of the same application. You could write it as multiple JARs packaged into a single deployment, but the different tiers are more about separating the different concerns in the code than putting physical distance between them.

If you were to put the data access on a separate machine, you would need some way for the frontend to communicate with it. This could be anything from remote EJBs to RMI or just another REST or SOAP service.

3
  • "In an app like this the "tiers" are usually various parts of the same application." I thought that was layers? Damn does the tiers/layers get confusing. I have read enough times their definitions =/ I did consider using another REST service on the data machine. So I guess I would have Client <-> REST BLL <-> REST DAL <-> DB But the idea of a URL generating a url seemed a bit strange. I.e. surely I would be doing something like get/user{id=1} or something and then basically have to copy that URL with the DAL for the result?
    – FinalFind
    Jul 15, 2015 at 1:25
  • @FinalFind - Think of it like a wedding cake (in western culture). You could have 3 separate cakes in tiers (machines or instances), but each cake could have multiple layers (divisions of code). stackoverflow.com/questions/120438/…
    – JeffO
    Jul 15, 2015 at 12:43
  • Aye, that is how I thought of it, but then you see confusing things as mentioned in my question here
    – FinalFind
    Jul 15, 2015 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.