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

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

求解答,我自己糾結(jié)兩天了

我自己跟著視頻寫的代碼。調(diào)用的是mysql自帶的數(shù)據(jù)庫(kù)world。

這個(gè)是CityDAo里面的

public ArrayList<City>getAllCities(){

Connection conn=null;

PreparedStatement stmt=null;

ResultSet rs=null;

ArrayList<City> list=new ArrayList<City>();//城市集合

try{

conn=DBHelper.getConnection();

String sql="select *from city where Name='Shanghai';"; ? //SQL

stmt=conn.prepareStatement(sql);

rs=stmt.executeQuery();

//Statement stmt = conn.createStatement(); ?

//ResultSet rs = stmt.executeQuery(sql); ?

while(rs.next()){

City city=new City();

city.setId(rs.getInt("ID"));

city.setName(rs.getString("Name"));

city.setCountryCode(rs.getString("CountryCode"));

city.setDistrict(rs.getString("District"));

city.setPopulation(rs.getInt("Population"));

list.add(city); ?//每次遍歷加一個(gè)城市

}

return list; ? //返回

index.jsp文件

? <h1>數(shù)據(jù)庫(kù)city展示</h1>

? <hr>



<center>

<table>

<thead>

<tr><th>ID</th><th>名字</th><th>國(guó)家</th><th>地區(qū)</th><th>人口數(shù)量</th></tr>

</thead>

<tbody>

<%

CityDAO cityDao=new CityDAO();

ArrayList<City>list=cityDao.getAllCities();

if(list!=null&&list.size()>0){

for(int i=0;i<list.size();i++){

City city=list.get(i);

%>

?

<tr><td><%=city.getId() %></td><td><%=city.getName() %></td><td><%=city.getCountryCode() %></td><td><%=city.getDistrict() %></td><td><%=city.getPopulation() %></td></tr>

<%

}

}

%>

</tbody>

</table>

</center>


數(shù)據(jù)庫(kù)連接正常,網(wǎng)頁(yè)顯示只有第一行的表頭,沒有數(shù)據(jù)。求解答

正在回答

1 回答

String sql="select *from city where Name='Shanghai'"; ? //SQL

這里面多了一個(gè)分號(hào)


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

舉報(bào)

0/150
提交
取消
JAVA遇見HTML——JSP篇
  • 參與學(xué)習(xí)       248277    人
  • 解答問題       3198    個(gè)

Java Web入門級(jí)教程JSP,帶你輕松的學(xué)習(xí)JSP基礎(chǔ)知識(shí)

進(jìn)入課程

求解答,我自己糾結(jié)兩天了

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

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

幫助反饋 APP下載

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

公眾號(hào)

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