这个程序是关于自动完成的。当我输入textfield
时,会出现一个建议列表。如何解决Catch语句中的SQLException?
当我在textfield
上输入内容时,我会对DB的建议列表做出方法onWordUpdated()
。现在
,问题是我有这样的错误:
exception java.sql.SQLException is never thrown in body of corresponding try statement
我在代码中所做的评论,这样你就会知道哪些线。
有人可以帮我解决这个问题吗?
感谢..
我有这样的代码:
public void onWordUpdated(final String toComplete)
{
new Thread(new Runnable()
{
public void run()
{
try
{
final List<Suggestion> suggestions = suggestor.getSuggestions(toComplete);
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
try
{
suggestionWidgetModel.clear();
for (Suggestion suggestion : suggestions)
suggestionWidgetModel.addElement(suggestion.getCaption());
if (!suggestions.isEmpty())
suggestionWidget.setSelectedIndex(0);
}
catch (SQLException e) // This line is my problem, Could someone help me how to fix this? Thanks..
{
e.printStackTrace();
}
}
});
}
catch (SQLException e1)
{
onSqlError(e1);
}
}
}, "onWordUpdated").start();
}
请使用代码仅用于说明目的。很难理解代码与问题无关的问题以及隐藏在评论中的问题。 – topchef
SQLException说什么? –
究竟是什么问题?你期望你的代码做什么,它究竟在做什么?如果它抛出一个你不期望的异常,你能提供更多关于它的意思的信息吗? –