第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

界面無(wú)法讀取數(shù)據(jù)庫(kù)并顯示,數(shù)據(jù)庫(kù)配置沒(méi)問(wèn)題,測(cè)試過(guò),可以正常查詢

package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import util.DBUtils;

import entity.Items;

public class DBItems {
public ArrayList<Items> getAllItems(){
Connection conn = null ;
PreparedStatement pst = null ;
ResultSet rs = null ;
ArrayList<Items> itemList = new ArrayList<Items>();


try {
conn=DBUtils.getConnection();
String sql = "select * from items";
pst = conn.prepareStatement(sql);
rs=pst.executeQuery();
while(rs.next()){
Items item = new Items();
item.setId(rs.getInt("id"));
item.setName(rs.getString("name"));
item.setCity(rs.getString("city"));
item.setNumber(rs.getInt("number"));
item.setPrice(rs.getInt("price"));
item.setPicture(rs.getString("picture"));
itemList.add(item);
}
return itemList;
} catch(Exception ex)
{
ex.printStackTrace();
return null;
}
/*
* 釋放資源
* */
finally{
if (pst!=null) {
try {
pst.close();
pst=null;
}catch(Exception ex)
{
ex.printStackTrace();
}

}
if (rs!=null) {
try {
rs.close();
rs=null;
} catch(Exception ex)
{
ex.printStackTrace();
}

}
}

}

}

只要連接數(shù)據(jù)庫(kù)就一直提示,錯(cuò)誤,在14行,14行修改15又錯(cuò)誤,15行修改,16行又錯(cuò)。。然后循環(huán),不連接數(shù)據(jù)庫(kù)光顯示靜態(tài)網(wǎng)頁(yè)就沒(méi)錯(cuò)誤,

數(shù)據(jù)庫(kù)配置沒(méi)問(wèn)題,測(cè)試過(guò),可以正常查詢,但是只要index.jsp中讀取并使用數(shù)據(jù)庫(kù)中內(nèi)容,就會(huì)出錯(cuò)。。。是在找不到原因了,

希望大神解答,謝謝!??!http://img1.sycdn.imooc.com//575cf5f10001547307000534.jpg


正在回答

1 回答

問(wèn)題解決了,粗心大意啊。。。

連接數(shù)據(jù)庫(kù)時(shí),數(shù)據(jù)庫(kù)的jar包一定要放在WEB-INF文件夾中,如果還出錯(cuò),就把jar包放在Tomcat安裝目錄的lib文件夾下面

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

界面無(wú)法讀取數(shù)據(jù)庫(kù)并顯示,數(shù)據(jù)庫(kù)配置沒(méi)問(wèn)題,測(cè)試過(guò),可以正常查詢

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)