We tested a socket connection programme with the idea where the socket connection will be one separate thread by itself and then it will enqueue and another separate thread for dbprocessor will pick from the queue and run through a number of sql statement. So I notice here is where the bottle neck that the db processing. I would like to get some idea is what I am doing the right architecture or I should change or improve on my design flow? Beside that there are two more thread which will do the sms and email task.

The requirement is to capture data via socket connections and run through a db process then store it accordingly.


Java Code:
public class cServer
{
 private LinkedBlockingQueue<String> databaseQueue = new LinkedBlockingQueue<String>();

   class ConnectionHandler implements Runnable {
        ConnectionHandler(Socket receivedSocketConn1) {
          this.receivedSocketConn1=receivedSocketConn1;
        }


       // gets data from an inbound connection and queues it for databse update

       public void run(){
         databaseQueue.add(message); // put to db queue
       }
    }
    class DatabaseProcessor implements Runnable {
    public void run(){
             // open database connection
             createConnection();
             while (true){
               message = databaseQueue.take(); // keep taking message from the queue add by connectionhandler and here I will have a number of queries to run in terms of select,insert and updates.
             }
    }

    void createConnection(){
        System.out.println("Crerate Connection");
        connCreated = new Date();
        try{
        dbconn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test1?"+"user=user1&password=*******");
        dbconn.setAutoCommit(false);
        }
        catch(Throwable ex){
           ex.printStackTrace(System.out);
        }
     }
    }

    public void main()
    {
    new Thread(new DatabaseProcessor()).start(); //calls the DatabaseProcessor
    try 
    {
      final ServerSocket serverSocketConn = new ServerSocket(9000);             
      while (true){
        try{
            Socket socketConn1 = serverSocketConn.accept();
            new Thread(new ConnectionHandler(socketConn1)).start();                     
       }
       catch(Exception e){
         e.printStackTrace(System.out);
       }
      }
    } 
    catch (Exception e){
      e.printStackTrace(System.out);
    }

    }

}