Guest User

Untitled

a guest
Nov 8th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. <%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.  
  7. <link rel="stylesheet" type="text/css" href="cadastro_costumização.css"/>
  8. <title>Untitled Document</title>
  9. <style type="text/css">
  10. <!--
  11. body,td,th {
  12. font-family: Times New Roman, Times, serif;
  13. font-size: 16px;
  14. color: #000;
  15. }
  16. h1{
  17. color:#00F;
  18. font-family:Georgia, "Times New Roman", Times, serif;
  19. font-size:24px;
  20.  
  21. }
  22. p{
  23. color:#003
  24. font-family:Georgia, "Times New Roman", Times, serif;
  25. font-size:22px;
  26.  
  27. }
  28. table{
  29. background-color: #69F;
  30. }
  31. -->
  32. </style></head>
  33.  
  34. <body>
  35.  
  36. <p align="center">Manunten&ccedil;&atilde;o do Bairro</p>
  37. <p align="center"><img src="img/loja.png" width="290" height="158" /></p>
  38. <a href="#" onclick="window.open('imprime_usuario.jsp')">impress&atilde;o na tela cheia</a>
  39. <div align="center"></br> <p>Cadastre e Impresse
  40. aqui</p>
  41. <a href="bairro_cadastro.jsp"><img src="img/cadstrar.png" width="82" height="83" /></a><a href="imprime_usuario.jsp"><img src="img/indice.jpg" width="82" height="83" /></a>
  42. <h1><strong>Ordena&ccedil;&atilde;o: <a href="bairro.jsp?ordenacao=crescente">Crescente</a>- <a href="bairro.jsp?ordenacao=alfabetica">Alfab&eacute;tica</a></strong></h1></div>
  43. <div align="center" >
  44. <table width="777" border="0">
  45. <tr>
  46. <td width="150"><div align="center"><p>C&oacute;digo</p></div></td>
  47. <td width="251"><div align="center">
  48. <p>Nome do bairro</p></div></td>
  49.  
  50. <td width="254"><div align="center"><p>Alterar</p></div></td>
  51. <td width="104"><div align="center"><p>Excluir</p></div></td>
  52. </tr>
  53.  
  54. <%
  55.  
  56. try
  57. {
  58. Class.forName("org.postgresql.Driver");
  59. //out.println("Conceguiu carregar o drive<br>");
  60. Connection con = DriverManager.getConnection("jdbc:postgresql://localhost/js","postgres","1974");
  61. //out.println("Conexão com sucesso");
  62.  
  63. Statement st = con.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
  64. //out.println("passou pelo Statement ");
  65. if(request.getParameter("acao")!= null)
  66. {
  67. st.executeUpdate("delete from bairro where bai_codigo="+request.getParameter("codigo"));
  68. }
  69. ResultSet rs = null;
  70.  
  71. if(request.getParameter("ordenacao")== null)
  72. {
  73. rs = st.executeQuery("select * from bairro order by bai_nome ");
  74. }
  75.  
  76. else if(request.getParameter("ordenacao").equals("crescente"))
  77. {
  78. rs = st.executeQuery("select * from bairro ");
  79. }
  80.  
  81. else if(request.getParameter("ordenacao").equals("alfabetica"))
  82. {
  83. rs = st.executeQuery( "select * from bairro order by bai_nome");
  84. }
  85.  
  86. while(rs.next())
  87. { %>
  88.  
  89. <tr>
  90. <td><div align="center"><%=rs.getString("bai_codigo") %></div>
  91. </td>
  92. <td><div align="center"> <%=rs.getString("bai_nome") %></div></td>
  93.  
  94. <td><div align="center">
  95. <form id="form1" name="form1" method="post" action="">
  96. <a href="bairro_altera.jsp?codigo=<%=rs.getString ("bai_codigo")%>&bairro=<%=rs.getString("bai_nome")%>"><img src="img/POWER - SWITCH USER.png" width="30" height="30" /></a>
  97. </form>
  98. </div></td>
  99. <td><div align="center"><a href="bairro.jsp?acao=excluir&codigo=<%=rs.getString("bai_codigo")%>"><img src="img/Lixeiras_1545_Poubelle_v3.png" width="30" height="30" /></a></div></td>
  100. </tr>
  101.  
  102. <% }
  103. }
  104. catch(ClassNotFoundException erroClass)
  105. {
  106. out.println("Driver não localizado,erro="+ erroClass);
  107. }
  108. catch(SQLException erroSQL)
  109. {
  110. out.println("Erro de conexão com o Banco de dados,erro="+ erroSQL);
  111. }
  112.  
  113. %>
  114.  
  115. </table>
  116. </div>
  117. </body>
  118. </html>
Add Comment
Please, Sign In to add comment