pageEncoding="gb2312" import="java.sql.*"%>
update数据String url = "jdbc:mysql://localhost:3306/test";
String user = "root";
String password = "110";
Connection conn = null;
PreparedStatement pstmt = null;
String driverName = "com.mysql.jdbc.Driver";
try {
Class.forName(driverName).newInstance();
conn = DriverManager.getConnection(url, user, password);
} catch (ClassNotFoundException e) {
out.println(e);
} catch (SQLException e) {
out.println("连接SQLserver数据库失败!!!!!!");
}
try {
Statement stmt = conn.createStatement();
String sql_delete = "delete from employee where id='2'";
int result_delete = stmt.executeUpdate(sql_delete);
} catch (SQLException e) {
out.println("delete失败!");
}
try {
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
out.println("数据库关闭异常!");
}
out.println("delete成功!");
%>