📄 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 + -