Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL maximum hit in one looping
    text
    copied!<p>I have one Class ArrayList Named "Sentence". each Sentence contains value "Words". I have to check each words into MySQL database whether it is a stopwords or not. Let say, i have 200 "Sentence" and each Sentence have a various number of "Words".</p> <p>I've check the "Words" one by one into the database, when it hit over 2500 number of "Words" (sometimes it hits until 3500th Words before the connection fail), it turns Error. But it will be fine if the number of "Words" below 2500.</p> <p>This is my Query code</p> <pre><code>public Query() throws SQLException, ClassNotFoundException{ try{ cd = new Connect(); connect = cd.getConnection(); statement = (Statement) connect.createStatement(); }catch(SQLException e){ System.err.println("Database connecting failed"); } } public boolean isStopWords(String word) throws SQLException{ String query = "SELECT stopwords FROM stopword WHERE stopwords = '"+word+"'"; rs = statement.executeQuery(query); if(!rs.next()) return false; else return true; } </code></pre> <p>This is my Connection code</p> <pre><code>public Connect() throws SQLException{ try{ Class forName = Class.forName ("com.mysql.jdbc.Driver"); }catch(ClassNotFoundException ex){ } connect = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/mydatabase", "root", null); } public Connection getConnection(){ return connect; } </code></pre> <p>This is my method to retrieve the Word from Class Sentence.String[] tempWords is the value of Words in one object Sentence. And the Sentence itself will looping according to the size of the ArrayList Sentence</p> <pre><code>protected ArrayList&lt;String&gt; eraseStopWord (String[] tempWords) throws SQLException, ClassNotFoundException{ result = new ArrayList&lt;String&gt;(); db = new Query(); for(int i=0;i&lt;tempWords.length;i++){ if(!db.isStopWords(tempWords[i])){ result.add(tempWords[i]); } } return result; } </code></pre> <p>Why its fine until it hits approximately 2500 "Word"? (sometimes its fine until 3500th words before the connection fail, it just stable below 2500th of words)</p> <p>UPDATE : now i know where the connection stopped. It stopped at 153rd sentence looping. so its not depend on the words. stil look after the bug</p> <ul> <li>I found the answer. i open the connection in looping, so MySQL take too much connection (152 connection)</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload