Guest User

Untitled

a guest
Jun 9th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <%
  2.  
  3. String leksaker = "Leksaker";
  4. try{
  5.  
  6.  
  7. Class.forName("com.mysql.jdbc.Driver");
  8. String url = "jdbc:mysql://localhost:3306/lekrea";
  9.  
  10. Connection conn = DriverManager.getConnection(url,"root","root");
  11. Statement str = conn.createStatement();
  12.  
  13.  
  14. ResultSet rs = str.executeQuery("SELECT id, name,catagory ,brand, url, image, saleprice FROM product WHERE catagory '"+leksaker+"'");
  15.  
  16. String id = null;
  17. String name = null;
  18. String catagory = null;
  19. String brand = null;
  20. String image = null;
  21. String saleprice = null;
  22.  
  23. int count = 0;
  24.  
  25. String[] products = null;
  26.  
  27. while(rs.next()){
  28.  
  29. products = { "Dennis", "Grace", "Bjarne", "James" };
  30.  
  31.  
  32. name = rs.getString("name");
  33. catagory = rs.getString("catagory");
  34. brand = rs.getString("brand");
  35. image = rs.getString("image");
  36. saleprice = rs.getString("saleprice");
  37.  
  38.  
  39.  
  40.  
  41. count++;
  42.  
  43. }
  44.  
  45. }catch (Exception e) {
  46. System.err.println("Got an exception! ");
  47. System.err.println(e.getMessage());
  48. }
  49. %>
Add Comment
Please, Sign In to add comment