留言管理系统java代码 留言管理系统java代码怎么写( 八 )


* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
protected void getDsnConn(){
String sqlUrl="jdbc:mysql://10.0.0.1/你申请用户名?user=你的名字password=你的帐号";
try{
if(debug)
conn=DriverManager.getConnection("jdbc:odbc:ODBC源","用户名","密码口令");
else
conn=DriverManager.getConnection(sqlUrl);
}
catch(SQLException es){
System.err.println("和库连接时出错:"+es.getMessage());
}
}
protected void executeInsert(String sqlStr){
try{
Statement stmt=conn.createStatement();
stmt.executeUpdate(sqlStr);
}
catch(SQLException es){
System.err.println("执行插入时:"+es.getMessage());
}
}
protected void executeUpdate(String sqlStr){
try{
Statement stmt=conn.createStatement();
stmt.executeUpdate(sqlStr);
}
catch(SQLException e){
System.err.println("error in query record");
}
}
//查寻
protected ResultSet executeQuery(String sqlStr){
rs=null;
try{
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sqlStr);
}
catch(SQLException ex){
System.err.println("执行查寻出错:"+ex.getMessage());
}
return rs;
}
protected ResultSet executeScrollableQuery(String sqlStr){
rs=null;
try{
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(sqlStr);
}
catch(SQLException e){
System.err.println("执行动态查寻出错");
}
return rs;
}
//得到表记录总数
protected int getRecordCount(String sTableName){
rs=null;
int CountResult=0;
String sqlStr="select count(*) from "+sTableName;
try{
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sqlStr);
if(rs.next())
CountResult=rs.getInt(1);
rs=null;
stmt.close();
}
catch(SQLException ex){
System.err.println(ex.getMessage());
}
return CountResult;
}
//得到记录总页数
protected int getTotalPage(String sTableName,int iPageSize){
int totalPage;
int totalRecNum=getRecordCount(sTableName);
if(totalRecNum%iPageSize==0)
totalPage=totalRecNum/iPageSize;
else
totalPage=totalRecNum/iPageSize+1;
return totalPage;
}
protected String convert(String InputStr){
String converted=new String();
byte[] bytes;
try{
bytes=InputStr.getBytes("ISO8859-1");
converted=new String(bytes,"GB2312");
}
catch(java.io.UnsupportedEncodingException e){
System.out.print("error");
}
return converted;
}
/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
}
求一个留言板的代码,要求用jsp+javaBean+java写 。[ftf=Webdings][fts=4][ftc=8FC63D][ftc=17BCB4]Y[/ft][/ft][/ft][/ft][ftf=Webdings][fts=3][ftc=438CCB]Y[/ft][/ft][/ft][ftf=Webdings][fts=4][ftc=EF6EA8]Y[/ft][/ft][/ft]
[M]
[B][fts=3][ftc=ACD372][ftc=00AEEF][ftc=EE1000]再[/ft][/ft][/ft][/ft][/B]好旳[U][B][ftc=F68E54][ftc=EE1000][ftc=ACD372][ftc=FFF100][ftc=EE1000]东西[/ft][/ft][/ft][/ft][/ft][/B][/U],都有失去旳一天 。再深旳[B][U][ftc=00BFF3][ftc=00BFF3][ftc=00AEEF]记忆[/ft][/ft][/ft][/U][/B],也有淡忘旳一天 。
再爱旳人 , 也有[B][U][ftc=8FC63D]远走[/ft][/U][/B]旳一天 。再美旳梦,也有[B][ftc=EE1000][ftc=ACD372][ftc=00BFF3][ftc=EE1000]苏醒[/ft][/ft][/ft][/ft][/B]旳一天 。
[/M]
[R] [[url=]Q友乐园留言代码[/url][/ft]][/R]