insertutente
<%@page language="java" %>
<%@page import="java.util.*" %>
<%@page import="java.sql.*" %>
<html>
<head>
<title>web database insert </title>
</head>
<body>
<h2>insert utente con parametri da chiamante</h2>
<table border="1">
<tr>
<th>cognome</th>
<th>password</th>
<th>e-mail</th>
</tr>
<%
String cognome = new String(request.getParameter("cognome"));
String password = new String(request.getParameter("password"));
String email = new String(request.getParameter("email"));
Connection conn=null;
Statement stmt=null;
ResultSet rs = null;
String url="jdbc:odbc:dbjsp";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//new sun.jdbc.odbc.JdbcOdbcDriver();
conn=DriverManager.getConnection(url, "", "");
stmt=conn.createStatement();
}
catch(ClassNotFoundException ex)
{
out.println("Driver non trovato");
}
catch(SQLException ex)
{
out.println("connessione fallita yyy");
}
String query = new String("insert into Utenti (cognome, password,
email) ") ;
query = query + " values ('"+cognome+" ','" +password +"','"+
email +"');";
try
{
stmt.executeUpdate(query);
System.out.println("registrazione effettuata");
stmt.close();
conn.close();
}
Pagina 1
insertutente
catch(SQLException ex)
{
out.println("errore inserimento");
}
%>
</table>
<a href="insertutente.html">torna alla form principale</a>
</body>
</html>
Pagina 2