?? commentmanager.java
字號:
package struts.business;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class CommentManager {
private static final String validate_question="Select * from comment where title=?and type=?";
private static final String insert_question="insert into comment(name,title,text,type,floor) values(?,?,?,?,?)";
public boolean validate(String title,String type)throws Exception
{
Connection con=null;
DBUtility db=DBUtility.getInstance();
try{
con=db.getConnection();
PreparedStatement stmt=con.prepareStatement(validate_question);
stmt.setString(1,title);
stmt.setString(2,type);
ResultSet rs=stmt.executeQuery();
if(rs.next())
{
return true;
}
else
{
return false;
}
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}
}
public int insert(String name,String title,String text,
String type,int floor ) throws Exception
{
Connection con=null;
String strSql;
int result=0;
DBUtility db=DBUtility.getInstance();
try
{
con=db.getConnection();
PreparedStatement stmt=con.prepareStatement(insert_question);
stmt.setString(1, name);
stmt.setString(2, title);
stmt.setString(3, text);
stmt.setString(4, type);
stmt.setInt(5,floor);
result=stmt.executeUpdate();
con.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
return result;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -