亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

jdbc連接數據庫 Statement的executeQuery方法報空指針異常?

jdbc連接數據庫 Statement的executeQuery方法報空指針異常?

汪汪一只貓 2018-12-07 05:13:06
Connection conn = null; Statement stmt = null; ResultSet rs = null; String membertype = "";//登錄用戶類型 try { StringBuffer sb = new StringBuffer(); sb.append(" select membertype from m_b_broker where brokerid='"+logonUser+"' "); System.out.print(sb); rs = stmt.executeQuery(sb.toString()); ? //這里報出空指針異常 System.out.print("1111"); while (rs.next()) { membertype=rs.getString("membertype"); } rs.close(); rs = null; stmt.close(); stmt = null; conn.close(); conn = null; } catch (Exception e) { e.printStackTrace(); } finally { try { if (rs != null) { rs.close(); rs = null; } if (stmt != null) { stmt.close(); stmt = null; } if (conn != null) { conn.close(); conn = null; } } catch (SQLException e) { e.printStackTrace(); } } return membertype;
查看完整描述

3 回答

?
一只名叫tom的貓

TA貢獻1906條經驗 獲得超3個贊

是別的文件有問題 ?這個項目的jar包和寫法不是正常的jdbc?

查看完整回答
反對 回復 2018-12-16
?
慕森卡

TA貢獻1806條經驗 獲得超8個贊

Statement stmt = null;

你的Statement 沒有初始化啊

查看完整回答
反對 回復 2018-12-16
?
絕地無雙

TA貢獻1946條經驗 獲得超4個贊

Connection conn=DriverManager.getConnection();

。。。。

。。。。

stateMent state=conn.createStateMent();

.......

.......

查看完整回答
反對 回復 2018-12-16
  • 3 回答
  • 0 關注
  • 1410 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號