0

I have implemented a connection pool to my database which is connected to 2 middlewares. Now the problem is that my school doesnt want us to used the jdbc provided functionalities to do this hence I have to think of another way. Basically we are using java and postgres.

I was thinking of the following as a substitute:

  1. each middleware creates a 3 connections to the database each(hence 6 connections in total)

  2. then I never close those connections until the application closes,hence each middleware can use the connections and leave them but not close them.

  3. Would this be a connection pool? I was also thinking that I could make 1 middleware initialize a set of connections that stay alive until the end of the application,and each middleware can hold onto an active connection to the db. The problem is I have no idea how to go through with these ideas.

Would this be feasible? If so can I pass the connection handle between middlewares? This is a distributed application, so I am not sure how to go through with this.

LoveMeow
  • 3,858
  • 9
  • 44
  • 66
  • 1
    Augh, I loathe assignments that say "ignore the existing tools that do this, and write it yourself". It's teaching exactly the *wrong* thing to new developers. You should be able to just use DBCP or C3P0 or Tomcat's pool or whatever. Anyway, if you have to DIY a connection pool I suggest starting by reading up on how existing pools work, reading the source code for PgJDBC's primitive connection pool implementation, etc. – Craig Ringer Oct 09 '15 at 05:09
  • 1
    I know! Exactly how I felt when they mentioned that! But I have no other choice,ive started reading up, I have to say its nice to know how it actually works, thanks! – LoveMeow Oct 10 '15 at 13:19

0 Answers0