該樓層疑似違規已被系統折疊 隐藏此樓檢視此樓
Insert title here
String url="jdbc:odbc:user1";
Connection con=DriverManager.getConnection(url);
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String i=request.getParameter("id");
String sql="";
sql="select * from product where productid='+i+'";//這裡我改成where productid='+i
ResultSet rs=stmt.executeQuery(sql); 後面顯示沒這結果,我把
ArrayList l=new ArrayList(); 這個語句删了,資料庫運作ok
if(!rs.next()){out.println("沒有此使用者");out.println("傳回");}
else{
rs.beforeFirst();
while(rs.next())
{int j=0;
String id=rs.getString("productid");
String name=rs.getString("playername");
String price=rs.getString("price");
Product p=new Product();
p.setId(id);
p.setName(name);
p.setPrice(price);
p.setNum(1);
l.add(j,p);
out.println(id);}}%>