iT邦幫忙

0

jsp執行到sql 帶入參數時空白頁面

請教各位前輩高手我這個方法出現空白頁面

private void selectorder(String customer,String orderdate) throws SQLException{
		  
		
		  String sqlstr = "select o_company,o_customers, o_date, o_product, o_unitprice , o_quantity,ROUND(o_unitprice*o_quantity) as total, o_invoicenumber  from orders where o_company like ? and o_date like ?";
		 PreparedStatement prepareState=conn.prepareStatement(sqlstr);
		 prepareState.setString(1, customer);
		 prepareState.setString(2, orderdate);
		 ResultSet rs=prepareState.executeQuery();
			while (rs.next()) 
			{
				total+=rs.getInt("total");
				orderslist.add(new orders(rs.getString("o_customers"),rs.getString("o_date"),rs.getDouble("o_unitprice"),rs.getInt("o_quantity"),rs.getInt("total"),rs.getString("invoicenumber")));
				
			}
	  }

使用debug到 prepareState.setString(1, customer); 發現http://ithelp.ithome.com.tw/upload/images/20161108/20102789qLVoQBWNgK.jpg

但是我其他頁面的類似的方法卻可以正常使用

找不到你的jar檔 或是引用到錯jar檔,沒紅底不代表就一定能用這個方法,版本新的用到舊的語法,也是會出錯誤的唷~還是要看一樣你jar檔的版本,查api的正確用法,以免出錯。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答