JAVA myStatement.executeQuery(sql );出现空指针 30
privateConnectionmyConnection;privateStatementmyStatement;privateResultSetesultSet;pu...
private Connection myConnection;
private Statement myStatement;
private ResultSet esultSet;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
shangpintianjia frame = new shangpintianjia(); 第66行
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
String sql ="SELECT Gno,Gname FROM goods";
try {
esultSet = myStatement.executeQuery(sql ); 第314行
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {while(esultSet.next()){
int i=0;
aa[i]= esultSet.getString("Gno");
bb[i]=esultSet.getString("Gname");
i=i+1;}
} catch (SQLException e1) {// TODO Auto-generated catch block
e1.printStackTrace();}
错误提示空指针
java.lang.NullPointerException
at demo.shangpintianjia.<init>(shangpintianjia.java:314)
at demo.shangpintianjia$1.run(shangpintianjia.java:66)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 展开
private Statement myStatement;
private ResultSet esultSet;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
shangpintianjia frame = new shangpintianjia(); 第66行
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
String sql ="SELECT Gno,Gname FROM goods";
try {
esultSet = myStatement.executeQuery(sql ); 第314行
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {while(esultSet.next()){
int i=0;
aa[i]= esultSet.getString("Gno");
bb[i]=esultSet.getString("Gname");
i=i+1;}
} catch (SQLException e1) {// TODO Auto-generated catch block
e1.printStackTrace();}
错误提示空指针
java.lang.NullPointerException
at demo.shangpintianjia.<init>(shangpintianjia.java:314)
at demo.shangpintianjia$1.run(shangpintianjia.java:66)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏30(财富值+成长值)
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询