gudfellas

cekbuah.jsp

Jul 18th, 2012
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <%--
  2. Document : cekbuah
  3. Created on : Jul 17, 2012, 12:10:00 PM
  4. Author : Aldo
  5. --%>
  6. <%@page import="java.sql.*" %>
  7. <%
  8.  
  9. String nama_buah="";
  10. nama_buah=request.getParameter("txtbuah").toString();
  11.  
  12. if(nama_buah==null){
  13. out.print("false");
  14. }else{
  15.  
  16. String connectionURL = "jdbc:mysql://localhost:3306/webkelasmalam";
  17. String user_db = "root";
  18. String pwd_db = "";
  19. Class.forName("com.mysql.jdbc.Driver");
  20. Connection connection = DriverManager.getConnection(connectionURL,user_db,pwd_db);
  21. Statement stm = connection.createStatement();
  22.  
  23. String sql="SELECT nama_buah FROM buah WHERE nama_buah='"+nama_buah+"'";
  24.  
  25. ResultSet rs = stm.executeQuery(sql);
  26. if (rs.next()){
  27. out.print("false");
  28. }else{
  29. out.print("true");
  30. }
  31. }
  32. %>
Advertisement
Add Comment
Please, Sign In to add comment