資源簡介
JSP的數(shù)據(jù)庫查詢,插入,刪除,修改操作。適合于jsp的初學(xué)者!

代碼片段和文件信息
package?org.bean;
import?java.sql.*;
public?class?conn?{
/*?String?mDBDriver?=?“com.mysql.jdbc.Driver“;
String?mConnStr??=?“jdbc:mysql://localhost:3306/aluo“;?*/
String?sDBDriver?=?“com.microsoft.sqlserver.jdbc.SQLServerDriver“;
String?sConnStr?=?“jdbc:sqlserver://localhost:1433;DatabaseName=test“;
private?Connection?connect?=?null;
private?Statement?stmt?=?null;
ResultSet?rs?=?null;
public?conn()?{
try?{
Class.forName(sDBDriver);
connect?=?DriverManager .getConnection(sConnStr?“sa“?““);
}?catch?(SQLException?ex)?{
System.err.println(“???SQL?????:“?+?ex.getMessage());
}?catch?(ClassNotFoundException?e)?{
e.printStackTrace();
}
}
//????Select???
public?ResultSet?executeQuery(String?sql)?{
try?{
stmt?=?connect.createStatement();
rs?=?stmt.executeQuery(sql);
}?catch?(SQLException?ex)?{
System.err.println(“???SQL?????:“?+?ex.getMessage());
}
return?rs;
}
//????InsertUpdateDelete???
public?void?executeUpdate(String?sql)?{
try?{
stmt?=?connect.createStatement();
stmt.executeUpdate(sql);
stmt.close();
}?catch?(SQLException?ex)?{
System.err.println(“???SQL?????:“?+?ex.getMessage());
}
}
????
public?void?closeStmt()?{ ?
try?{
if(stmt?!=?null){
stmt.close();
}
}catch(Exception?e){
e.printStackTrace();
}
}
public?void?closeConn()?{
?try?{
?if(connect?!=?null){
?connect.close();
?}
?}catch(Exception?e){
?e.printStackTrace();
?}
?}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3127??2008-05-26?15:36??CET\build.xm
?????文件????1048576??2008-05-26?15:08??CET\CET4_Log.LDF
?????文件????1048576??2008-05-26?15:08??CET\CET4_Data.MDF
?????文件???????1635??2008-05-26?15:40??CET\web\list_do.jsp
?????文件???????1244??2008-05-26?14:51??CET\web\update.html
?????文件???????1415??2008-05-26?15:38??CET\web\update_do.jsp
?????文件???????1620??2008-05-26?15:41??CET\web\alllist.jsp
?????文件????????520??2008-05-26?14:51??CET\web\delete.html
?????文件????????739??2008-05-26?15:37??CET\web\delete_do.jsp
?????文件???????1242??2008-05-26?14:51??CET\web\insert.html
?????文件???????1701??2008-05-26?15:38??CET\web\insert_do.jsp
?????文件????????494??2008-05-26?14:51??CET\web\list.html
?????文件????????492??2008-05-26?14:53??CET\web\WEB-INF\web.xm
?????文件????????503??2008-05-26?15:36??CET\web\WEB-INF\sun-web.xm
?????文件?????????23??2008-05-26?14:50??CET\src\conf\MANIFEST.MF
?????文件???????1601??2008-05-26?15:43??CET\src\java\org\bean\conn.java
?????文件????????905??2008-05-26?15:36??CET\nbproject\project.xm
?????文件???????2174??2008-05-26?15:36??CET\nbproject\project.properties
?????文件??????41512??2008-05-26?15:36??CET\nbproject\build-impl.xm
?????文件????????455??2008-05-26?15:36??CET\nbproject\genfiles.properties
?????文件???????3538??2008-05-26?15:36??CET\nbproject\ant-deploy.xm
?????文件???????2603??2008-05-26?14:52??CET\nbproject\private\private.properties
?????文件???????2407??2008-05-26?15:39??CET\build\web\WEB-INF\classes\org\bean\conn.class
?????文件????????503??2008-05-26?15:39??CET\build\web\WEB-INF\sun-web.xm
?????文件????????492??2008-05-26?15:39??CET\build\web\WEB-INF\web.xm
?????文件?????583286??2008-05-26?15:39??CET\build\web\WEB-INF\lib\sqljdbc.jar
?????文件?????????23??2008-05-26?15:39??CET\build\web\me
?????文件???????1701??2008-05-26?15:39??CET\build\web\insert_do.jsp
?????文件???????1415??2008-05-26?15:39??CET\build\web\update_do.jsp
?????文件???????1242??2008-05-26?15:39??CET\build\web\insert.html
............此處省略86個文件信息
評論
共有 條評論