Forum Stats

  • 3,815,465 Users
  • 2,259,031 Discussions
  • 7,893,110 Comments

Discussions

Oracle JDBC driver vs ODP.NET.

mlov83
mlov83 Member Posts: 339 Bronze Badge
edited Feb 21, 2018 6:40PM in Java Programming

I thought about asking this question in stack overflow, but seeing that this question is not related to a specific programming question and more specifically related to the Oracle JDBC driver I decided that it would probably be better suited for this forum.  I've been a long time .net developer. However, for the past year, I've been working with Java and Tomcat. I'm hoping someone here can clarify my confusion.  In .net when connecting to a database using Oracle ODP.net driver from a web application I would simply use the appropriate commands and I can do the connection pooling for the web app and just be on my merry way. In java it appears I can do the same, but I'm not entirely sure. It looks like in Java it is preferred to have the connection pool set up on the server (tomcat). Now every example that I have seen does not actually say that, especially if you look at the examples using Oracle UCP which is what I'm using for this particular applications. So my question is if I deployed 5 distinct applications on to a tomcat web server each (referencing their own UCP java and OJDBC jar) when the application's startup, do each application create its own separate connection pool? At least in the .net world is how I would understand it worked. Forgive my noobness I just don't want to take anything for granted.

Best Answer

  • Unknown
    edited Feb 21, 2018 1:08PM Answer ✓
    It looks like in Java it is preferred to have the connection pool set up on the server (tomcat).

    Not quite - the connection pool (and any other Java code) will be 'set up' within the JVM instance. That will be on whatever machine you execute 'java.exe' on.

    So my question is if I deployed 5 distinct applications on to a tomcat web server each (referencing their own UCP java and OJDBC jar) when the application's startup, do each application create its own separate connection pool?

    See my first comment above.

    1. you use 'java.exe' to create a JVM - a JVM is a container - it does NOT interact with anything outside that container unless you write code to do so.

    2. you run ONE APPLICATION on that JVM

    3. that application can create as many connection pools as it wants in that JVM

    4. that application can be multi-threaded so each thread can do whatever it wants/needs to do including creating pools (see #3)

    5. multiple applications launch their own JVMs running a single app so for each app just go back and see #2, #3 and #4

    mlov83

Answers

  • Unknown
    edited Feb 21, 2018 1:08PM Answer ✓
    It looks like in Java it is preferred to have the connection pool set up on the server (tomcat).

    Not quite - the connection pool (and any other Java code) will be 'set up' within the JVM instance. That will be on whatever machine you execute 'java.exe' on.

    So my question is if I deployed 5 distinct applications on to a tomcat web server each (referencing their own UCP java and OJDBC jar) when the application's startup, do each application create its own separate connection pool?

    See my first comment above.

    1. you use 'java.exe' to create a JVM - a JVM is a container - it does NOT interact with anything outside that container unless you write code to do so.

    2. you run ONE APPLICATION on that JVM

    3. that application can create as many connection pools as it wants in that JVM

    4. that application can be multi-threaded so each thread can do whatever it wants/needs to do including creating pools (see #3)

    5. multiple applications launch their own JVMs running a single app so for each app just go back and see #2, #3 and #4

    mlov83
  • mlov83
    mlov83 Member Posts: 339 Bronze Badge
    edited Feb 21, 2018 1:16PM

    Thanks for the response RP0428, that makes a ton of sense, just to make sure I understand in Tomcat I wouldn't execute a java.exe are you referring to .net in your above reply? follow up question, do you think tomcat would do the same? The reason I ask is because I've been reading a lot about class loaders and how if I have to projects with the same exact class names they will clash. Sorry , If I'm confusing apples and oranges here, I'm just trying to be thorough and make sure I understand.

  • Unknown
    edited Feb 21, 2018 6:40PM

    Tomcat is launching the JVM and creating multi-threaded 'apps' within it. Each of those 'apps' can have its own connection pool and there won't be any crosstalk/access between the apps.

This discussion has been closed.