Tabella: Classe5E
index.html
- Crea la tabella
- Cancella la tabella
- Inserisci un nominativo
- Cancella un nominativo
- Visualizza tutti i nominativi
crea.jsp
<%@page import="java.sql.DriverManager"%> <%@page import="java.sql.Connection"%> <%@page import="java.sql.Statement"%> <%@page import="java.sql.ResultSet"%> <%@page import="java.sql.SQLException"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Classe 5ª E</title> </head> <body> <h1>Classe 5ª E - Creazione tabella</h1> <% try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://didattica1.liceocuneo.it/db1", "studente1", "topolino13"); Statement stat = conn.createStatement(); stat.executeUpdate("CREATE TABLE Classe5E (ID_Studente INT NOT NULL AUTO_INCREMENT, Cognome VARCHAR(45) NOT NULL, Nome VARCHAR(45) NOT NULL, LuogoNascita VARCHAR(45) NOT NULL, DataNascita DATE NOT NULL, PRIMARY KEY (ID_Studente))"); stat.close(); conn.close(); %> <p>Tabella "Classe5E" creata correttamente.</p> <% } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | SQLException ex) { %> <p><%=ex.toString()%><br/><%=ex.getMessage()%></p> <% } // endcatch %> </body> </html>
Progetto NetBeans completo: Anagrafe5E.zip