资源简介
java留言板,代码,数据库java留言板,代码,数据库java留言板,代码,数据库java留言板,代码,数据库java留言板,代码,数据库
代码片段和文件信息
package QueryDao;
import java.sql.Connection;
import java.util.*;
import UserBean.Write;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.naming.spi.DirStateFactory.Result;
import UserBean.Reply;
import UserBean.User;
import UserBean.Traveler;
public class Query {
int count=0;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
Write write;
User user;
//此DAO用于数据库的连接
private Connection con;
//采用构造函数对数据库进行初始化
public Query(){
try {
Class.forName(“com.mysql.jdbc.Driver“);
try {
con=DriverManager.getConnection(“jdbc:mysql://localhost:3306/write““root“““);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//用户注册
public void QueryReg(User user){
String sql=“insert into user values(“+“null“+“‘“+user.getUsername()+“‘‘“+user.getPassword()+“‘‘“+user.getTelphone()+“‘‘“+user.getQq()+“‘‘“+user.getEmail()+“‘);“;
System.out.println(user.getUsername());
try {
con.createStatement().execute(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//用户登陆
public void QueryLogin(User user){
String sql=“select * from user where username=‘“+user.username+“‘ and password=‘“+user.password+“‘;“;
try {
ResultSet rs=con.createStatement().executeQuery(sql);
while(rs.next()){
count=rs.getInt(1);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//管理员登陆
public void QueryAdminLogin(User user){
String sql=“select * from admin where username=‘“+user.username+“‘ and password=‘“+user.password+“‘;“;
try {
ResultSet rs=con.createStatement().executeQuery(sql);
while(rs.next()){
count=rs.getInt(1);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//将留言写进数据库
public void QueryWrite(Write write){
java.sql.Timestamp nowTime=new java.sql.Timestamp(write.getDate().getTime());
String sql=“insert into user_write values(“+“null“+“‘“+write.getUsername()+“‘‘“+write.gettitle()+“‘‘“+write.getContent()+“‘‘“+nowTime+“‘‘“+write.getState()+“‘‘“+write.getReplystate()+“‘);“;
try {
con.createStatement().execute(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//查看用户所有留言,进行留言管理(删除)
public ArrayList QuerySelect(Write write){
ArrayList al=new ArrayList();
String sql=“select * from user_write where username=‘“+write.getUsername()+“‘;“;
try {
ResultSet rs=con.createStatement().executeQuery(sql);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 588 2011-09-27 13:02 Writern\.classpath
文件 1040 2011-09-27 13:02 Writern\.project
文件 503 2011-09-27 13:02 Writern\.settings\.jsdtscope
文件 450 2011-10-09 16:50 Writern\.settings\org.eclipse.core.resources.prefs
文件 395 2011-09-27 13:02 Writern\.settings\org.eclipse.jdt.core.prefs
文件 451 2011-09-27 13:02 Writern\.settings\org.eclipse.wst.common.component
文件 305 2011-09-27 13:02 Writern\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2011-09-27 13:02 Writern\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2011-09-27 13:02 Writern\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 14379 2011-10-21 15:48 Writern\build\classes\QueryDao\Query.class
文件 4451 2011-10-14 18:15 Writern\build\classes\SendEmail\SendTest.class
文件 2164 2011-10-14 16:36 Writern\build\classes\Servlet\ServletAdminLogin.class
文件 3042 2011-10-14 17:19 Writern\build\classes\Servlet\ServletAdminReplyTraveler.class
文件 3793 2011-10-14 16:36 Writern\build\classes\Servlet\ServletAdminUserReply.class
文件 2423 2011-10-14 16:36 Writern\build\classes\Servlet\ServletAdminWriteManager.class
文件 2083 2011-10-14 16:36 Writern\build\classes\Servlet\ServletAdminWriteManagerSimple.class
文件 2391 2011-10-14 16:36 Writern\build\classes\Servlet\ServletDelete.class
文件 2078 2011-10-14 16:36 Writern\build\classes\Servlet\ServletDeleteWrite.class
文件 2139 2011-10-14 16:36 Writern\build\classes\Servlet\ServletLogin.class
文件 1775 2011-10-14 16:36 Writern\build\classes\Servlet\ServletReg.class
文件 2312 2011-10-14 16:36 Writern\build\classes\Servlet\ServletReply.class
文件 1836 2011-10-14 16:36 Writern\build\classes\Servlet\ServletReplyOk.class
文件 5718 2011-10-14 16:36 Writern\build\classes\Servlet\ServletSelect.class
文件 1846 2011-10-14 16:36 Writern\build\classes\Servlet\ServletTravelerDelete.class
文件 1873 2011-10-14 16:36 Writern\build\classes\Servlet\ServletTravelerManager.class
文件 2575 2011-10-14 17:42 Writern\build\classes\Servlet\ServletTravelerManagerSimple.class
文件 2113 2011-10-14 16:36 Writern\build\classes\Servlet\ServletTravelerReply.class
文件 2036 2011-10-14 16:36 Writern\build\classes\Servlet\ServletTravelerWrite.class
文件 1930 2011-10-14 16:36 Writern\build\classes\Servlet\ServletUserDelete.class
文件 1554 2011-10-14 16:36 Writern\build\classes\Servlet\ServletUserManager.class
............此处省略83个文件信息
- 上一篇:抓住神经猫源码
- 下一篇:Android+3D+游戏开发教程.zip
评论
共有 条评论