当我的程序从mysql数据库中检索数据时,我遇到了问题。
Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Exception in thread "main" java.lang.NullPointerException
at pdlsi.list.ListWord.getfrequencyWord(ListWord.java:67)
at pdlsi.utilities.MatrixRetrieve.getTermDocMatrixTFIDF(MatrixRetrieve.java:78)
at pdlsi.utilities.MatrixRetrieve.main(MatrixRetrieve.java:102)
当我处理来自我的数据库的小数据时,错误没有出现,但在处理来自数据库的大数据时总是出现。因此有时会出现错误,有时不会出现。
我确实尝试在my.ini中增加innodb_buffer_pool_size,但它没有用。
这是我使用的反向方法的示例:
public void retrieve() {
listStopwords.clear();
String query = "SELECT * FROM stopwords";
Connection con = Koneksi.getKoneksi();
try {
Statement statement = con.createStatement();
ResultSet result = statement.executeQuery(query);
while (result.next()) {
Stopwords stopwords = new Stopwords();
stopwords.setId(result.getInt(1));
stopwords.setStopword(result.getString(2));
listStopwords.add(stopwords);
}
con.close();
} catch (SQLException ex) {
Logger.getLogger(ListStopwords.class.getName()).log(Level.SEVERE, null, ex);
}
}
这是我的连接类:
public static Connection getConnection() {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/final", "root", "");
return con;
} catch (ClassNotFoundException | SQLException ex) {
System.out.println(ex.getMessage());
return null;
}
}
我使用jdbc和xampp作为数据库。
我坚持这个错误,所以请帮助我。 谢谢。