Trabalho Java
Artigo: Trabalho Java. Pesquise 862.000+ trabalhos acadêmicosPor: patiborges • 20/8/2014 • 937 Palavras (4 Páginas) • 431 Visualizações
package servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Servicos extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String url = "jdbc:mysql://localhost:3306/cadastro";
String usuario = "root";
String senha = "";
PrintWriter out = response.getWriter();
int servico = Integer.parseInt(request.getParameter("tipo"));
out.println("<h1>" + servico + " recebido</h1>");
switch (servico) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(url, usuario, senha);
// instrucoes SQL
Statement cmd = conn.createStatement();
ResultSet rs = cmd.executeQuery("select * from aluno");
out.print("<table border='1'>");
out.print("<tr>");
out.println("<td>RA</td>");
out.println("<td>Nome do Aluno</td>");
out.print("</tr>");
while (rs.next()) {
out.println("<tr>");
...