1. 在Myeclipse 的stuts-config.xml里的design模式下點右鍵創(chuàng)建 Form,Action and JSP 的時候,出現:Warning: Superclass does not exist.
答:把struts.jar在重新引入到工程目錄下
2. 創(chuàng)建數據庫連接
Connection conn = null;// 數據庫連接
Statement stmt = null;// 數據庫表達式
ResultSet rs = null;// 結果集
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}// sql 的驅動
try {
conn = java.sql.DriverManager.getConnection(url,username,password);
} catch (SQLException e) {
e.printStackTrace();
}
3. 數據操作
stmt = conn.createStatement();
// 執(zhí)行插入數據的 SQL
int row = stmt.executeUpdate("insert into……");
rs = stmt.executeQuery("select * from Student");
while (rs.next()) {
System.out.println("編號=" + rs.getInt(1));
System.out.println("學生姓名=" +rs.getString("username"));
System.out.println("密碼=" + rs.getString("password"));
System.out.println("年齡=" + rs.getString("age"));
}
// 執(zhí)行刪除數據的 SQL, 被刪除的記錄的ID為7
row = stmt.executeUpdate("delete from student where id = 7");
System.out.println("刪除了 " + row);
4. 關閉
try {
rs.close();
}
catch (SQLException e){
}
try {
stmt.close();
}
catch (SQLException e){
}
try {
conn.close();
}
catch (SQLException e) {
}
5. Activation.main: 警告: sun.rmi.activation.execPolicy 系統屬性未被指定且 ExecPermissions/ExecOptionPermissions均未被授權??荚嚧筇崾倦S后的激活嘗試失敗,原因是對ExecPermission/ExecOptionPermission 的權限檢查失敗。
有關如何配置 rmid 安全性的文檔說明,請參閱: http://pic02.newdu.com/uploads/202503/19/3.html%3cBR%3e %3b %3b %3b %3b%d4%ad%d2%f2%a3%bamain%ba%af%ca%fd%ce%b4%d6%b8%b6%a8%a3%bb%d4%cb%d0%d0%ca%b1%a3%ac%bf%c9%d2%d4%d1%a1%d4%f1%b8%c3%ba%af%ca%fd%a3%ac%d3%d2%bc%fc%d4%cb%d0%d0
答:把struts.jar在重新引入到工程目錄下
2. 創(chuàng)建數據庫連接
Connection conn = null;// 數據庫連接
Statement stmt = null;// 數據庫表達式
ResultSet rs = null;// 結果集
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}// sql 的驅動
try {
conn = java.sql.DriverManager.getConnection(url,username,password);
} catch (SQLException e) {
e.printStackTrace();
}
3. 數據操作
stmt = conn.createStatement();
// 執(zhí)行插入數據的 SQL
int row = stmt.executeUpdate("insert into……");
rs = stmt.executeQuery("select * from Student");
while (rs.next()) {
System.out.println("編號=" + rs.getInt(1));
System.out.println("學生姓名=" +rs.getString("username"));
System.out.println("密碼=" + rs.getString("password"));
System.out.println("年齡=" + rs.getString("age"));
}
// 執(zhí)行刪除數據的 SQL, 被刪除的記錄的ID為7
row = stmt.executeUpdate("delete from student where id = 7");
System.out.println("刪除了 " + row);
4. 關閉
try {
rs.close();
}
catch (SQLException e){
}
try {
stmt.close();
}
catch (SQLException e){
}
try {
conn.close();
}
catch (SQLException e) {
}
5. Activation.main: 警告: sun.rmi.activation.execPolicy 系統屬性未被指定且 ExecPermissions/ExecOptionPermissions均未被授權??荚嚧筇崾倦S后的激活嘗試失敗,原因是對ExecPermission/ExecOptionPermission 的權限檢查失敗。
有關如何配置 rmid 安全性的文檔說明,請參閱: http://pic02.newdu.com/uploads/202503/19/3.html%3cBR%3e %3b %3b %3b %3b%d4%ad%d2%f2%a3%bamain%ba%af%ca%fd%ce%b4%d6%b8%b6%a8%a3%bb%d4%cb%d0%d0%ca%b1%a3%ac%bf%c9%d2%d4%d1%a1%d4%f1%b8%c3%ba%af%ca%fd%a3%ac%d3%d2%bc%fc%d4%cb%d0%d0