Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <% if(request.getParameter("acao") == null){ %>
- <form method="post" action="cadBairro.jsp?acao=gravar">
- <table width="337" height="62" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td width="148" align="right">Nome : </td>
- <td width="183"><label>
- <input name="nome" type="text" id="nome" maxlength="20" />
- </label></td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <input type="reset" name="Reset" id="button" value="Limpar" />
- <input name="input" type="submit" value="Enviar" /></td>
- </tr>
- </table>
- </form>
- <% }else{
- if ((request.getParameter("nome").length() <= 0) )
- {
- //out.println("Preencha os campos corretamente!");
- response.sendRedirect("cadBairro.jsp");
- }else{
- try
- {
- Class.forName ("org.postgresql.Driver");
- Connection con = DriverManager.getConnection ("jdbc:postgresql://localhost/aulas_daniel","postgres","Senac2010");
- Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
- st.executeUpdate("INSERT INTO bairro (bai_nome) VALUES ('"+request.getParameter("nome")+"')");
- out.println("Bairro cadastrado com sucesso!");
- }
- catch (ClassNotFoundException erroClass)
- {
- out.println ("Classe Driver JDBC não foi localizado, erro = " +erroClass);
- }
- catch (SQLException erroSQL)
- {
- out.println("Erro de conexão com o Banco de Dados, erro = "+erroSQL);
- }
- }
- }
- %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement