title: Connect Java Websocket endpoint to mySQL
body: <p>We are building a websocket webapp for a school project and would like to store the incoming information to MySQL. Currently we are using netbeans and the Server Endpoint is written in Java. The info sent from the client side is a JSON obj. We can decode it but dont't know how to insert it into the table</p>
  
  <p>Problems we are facing</p>
  
  <p>1.We are used to programming Java application and using mysql JDBC but this time we cannot find the library to add, like we use to do.</p>
  
  <p>2.We have tried AJAX but since the PHP is on a different server we cant do it, and I can't find the option to add a PHP file to the current project in netbeans. -- Currently I'm trying to learn how to do AJAX with JSP</p>
  
  <p>3.We think we need to spin a thread so that the reply doesn't have to wait for the insert to complete but when we try to spin a thread the Endpoint no longer works, so we commented it out</p>
  
  <p>4.We are trying to keep third party Frame works to a minimum</p>
  
  <p>Below is the code to our Server Endpoint</p>
  
  <pre><code> public void onMessage(String message, Session session) {
      // Create JsonObject from message
      JsonObject jsonObject = new Message(message).getJObject();
  
      // Decode JsonObject
      message = Decoder(jsonObject);
  
  
      for (Session peer : peers) {
          try {
               if (!peer.equals(session)) { 
  
              peer.getBasicRemote().sendText(message);
               }
           } catch (IOException ex) {
               Logger.getLogger(ServerEndpoint.class.getName()).log(Level.SEVERE, null, ex);
           }
      }
  }
  </code></pre>
  
  <p>This is our current decoder. We wanted to spin a thread from this function, I don't know if that is a good idea or not</p>
  
  <pre><code>public String Decoder(JsonObject jObject) {
      String message;
      message = jObject.getString("msg");
  
      return message;
  }
  </code></pre>