Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle JDBC driver vs ODP.NET.

mlov83Feb 21 2018 — edited Feb 21 2018

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.

This post has been answered by unknown-7404 on Feb 21 2018
Jump to Answer

Comments

unknown-7404
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

Marked as Answer by mlov83 · Sep 27 2020
mlov83

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-7404

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.

1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 21 2018
Added on Feb 21 2018
3 comments
579 views