Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7874013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:41:05+00:00 2026-06-03T02:41:05+00:00

create server made in Java. The server accept request on port 111, and when

  • 0

create server made in Java. The server accept request on port 111, and when a client connect to the server send to it a JSON file. The server receive the JSON then he must store into a postgres database.

My question is how to manage the postgres connection.

Should I create only one Connection and synchronize it for every client request or create a new connection for every client connected to the server.

I mean:

——— Only one connection: ————–

The server create the only one connection with

_connection = DriverManager.
   getConnection("jdbc:postgresql:"+_dbName, _username, _password);

and for every clients use this connection

syncronize(_connection) { send data to database }

——— A connection for every client ————-

The server when accept a client request create a new connection for the connected client

_clientConnection = DriverManager.
   getConnection("jdbc:postgresql:"+_dbName, _username, _password);

And every client has a personal connection.

Can anyone explain what is the best working practice for do this stuff? I think is the same with MySQL.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:41:07+00:00Added an answer on June 3, 2026 at 2:41 am

    The best practice is to use a pool of connections. This makes sure that

    • multiple clients can access the database concurrently
    • the number of open connections always stays reasonable, and doesn’t put the server or database to its knees in case of a high number of concurrent requests
    • connections are not constantly opened and closed. Opening a connection is a time and memory consuming operation

    There are several free connection pools available (C3P0, DBCP, etc.). Google is your friend.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a server socket, which should reject a connect request, if
i have a java chat server & client, that works fine. I made a
I'm using Java to create a client/server application that communicates using TCP. The network
I have only started learning Java. My task is to create a file server
Here is how I'm creating a file: System.IO.File.Create(Server.MapPath(..) + name + .html); But sometimes
I want to create a server smo object in my function, then use it
Im trying to create a server/client application that will work on two or more
I need to create a server which creates a new thread for each client
I need to create 1000 server sockets using Java. Somewhere between creating 600 and
I made a custom server that accepts TCP connections on a certain port. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.