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

  • SEARCH
  • Home
  • 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 6794049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:10:30+00:00 2026-05-26T18:10:30+00:00

I am receiving a data from the socket. My ServerSocket creats a new thread

  • 0

I am receiving a data from the socket. My ServerSocket creats a new thread for each new request. Then a need to upload the data to MySQL database. A database connection and all required prepared statemnts were created beforehand.

Well, I want to process all requests at the same time. Is that mean, that I need several connections to the database? I was considering pooled connections, but prepared statemens must be created only one time at application startup.

What is the best way to implement that to achive the best performance?

What if I replace my database with Oracle. Should I use several connections? Tom Kyte in the first chapter of his book appeals to use only one connection to the Oracle database, while MS SQLServer is used with several ones. Does it mean, that I can execute several statements using only one connection?

  • 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-05-26T18:10:31+00:00Added an answer on May 26, 2026 at 6:10 pm

    You need pool of connection with cached connections for more details you can see http://en.wikipedia.org/wiki/Connection_pool. You can have cached prepared statements and after each execute clear parameters.
    For best performance you need use Thread pool also not need create a new thread for each new request.
    I think you can create some pool of prepared statements , and retrieving those by some key (you can define keys for queries).
    Something like that :

    public class StatementPool{
    
      HashMap<String, Queue<Statement>> statementsPoolMap = ...
      public Statement getStatementByKey(String key){ // you can define keys for queries
    
         Queue<Statement> queue = statementsPoolMap.get (key); 
         Statement statement = null;
         if(queue.isEmpty()){
           Statement st =  connectionPool.getConnection().prepareStatement();
           ... 
         }else{
           statement = queue.poll();
         }
         ...
         return statement
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one thread that is receiving data over a socket like this: while
I have a TCP socket client receiving messages (data) from a server. messages are
I'm receiving data from tcp socket in binary view. In erlang shell i see:
I am receiving data from a server through a socket using boost asio, and
In my iOS app, I need to configure a socket server for receiving data
I have an App that has a thread handler receiving some socket data all
I need to use the tcp socket connection to get the data from a
I'm designing a system which is receiving data from a number of partners in
Lets put it in parts. I got a socket receiving data OK and I
I'm receiving byte data from a VNC server, using Real VNC this works in

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.