title: JDBC with MySQL really slow, don't know why
body: <p>I have a problem with a really slow connection between my Java code and a MySQL Database. I don't know where the bottle neck is.</p>
  
  <p>My program is more or less a chatbot. The user types something in, my program splits the sentence into words and sends it word per word to the database. If it finds something there, the user gets an output.
  The database is on an external Server, but I also tried to connect to a pc next to me. Both is slow. </p>
  
  <p>I tried the connection once at another place then where I normally work and there it was fast, most of the time.</p>
  
  <p>My SQL Code:</p>
  
  <blockquote>
    <p>SELECT info.INFORMATION FROM INFORMATION info, INFO_SCHLUESSEL sch<br>
    WHERE LCASE(sch.SCHLUESSELWORT) LIKE '" + input + "%'  AND info.ID_INFO = sch.ID_INFO<br>
    Order BY info.PRIORITAET DESC LIMIT 1;</p>
  </blockquote>
  
  <p>(just remembered, if it helps to understand the sql code:<br>
  schluessel = key<br>
  Schluesselwort = key word<br>
  prioritaet = priority)</p>
  
  <p>My Java Database Code is more or less standard stuff:</p>
  
  <blockquote>
    <p>String driver = "com.mysql.jdbc.Driver";<br>
    String dbase = "jdbc:mysql://bla";<br>
    String dbuser = "bla";<br>
    String dbpw = "bla";   </p>
    
    <p>Class.forName(driver);<br>
    Connection con = DriverManager.getConnection(dbase, dbuser, dbpw);<br>
    Statement stmt = con.createStatement();  </p>
    
    <p>ResultSet rs = stmt.executeQuery(query);<br>
    while (rs.next())<br>
    {<br>
    ergebnis = rs.getString("info.INFORMATION");<br>
    }  </p>
    
    <p>rs.close();<br>
    stmt.close();<br>
    con.close();  </p>
  </blockquote>
  
  <p>edit:  </p>
  
  <p>I have tried this DBCP for a while now, and I can't seem to get it to work. It seems to be as slow as the old connection. This is the example provided by the website that I use:</p>
  
  <blockquote>
    <p>GenericObjectPool connectionPool = new GenericObjectPool(null);<br>
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory("jdbc:mysql://bla", "bla", "bla");<br>
    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true);<br>
    PoolingDriver driver = new PoolingDriver();<br>
    driver.registerPool("example",connectionPool);<br>
    Connection conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:example");  </p>
  </blockquote>