This content has been marked as final. Show 3 replies
Well the error message is that it can't connect to the database at all.
Does it manage to process any lines at all? Put a System.out.println statement in your loop to say something like "Executing query for word " + current);
Is MySQL installed on your machine?
Is it currently running?
Also, as you may have surmised you should open it once, and then reuse it many times. In fact you should probably reuse your prepared statement multiple times rather than creating it afresh each time.
I would probably do it in the order
-open database connection
- prepare sql statement
- loop over each word in the array
-- setString into prepared statement
-- execute query