package aaa;
import java.sql.*;
public class DBOperate_wenti
{
Statement st;
Connection con;
ResultSet rs;
public void connection() throws Exception
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_net",
"qyadmin","166424");
st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
}
public ResultSet ListWenti() throws Exception//问题列表
{
connection();
rs=st.executeQuery("select * from tb_question,tb_userinformation where tb_question.q_id=tb_userinformation.id order by tb_question.q_id DESC");
return rs;
}
public ResultSet viewWenti(int id) throws Exception//查看问题
{
connection();
rs=st.executeQuery("select * from tb_question,tb_userinformation where tb_question.q_id=tb_userinformation.id and tb_question.q_id="+id);
return rs;
}
public ResultSet viewHuifu(int id) throws Exception//查看回复
{
connection();
rs=st.executeQuery("select * from tb_answer,tb_userinformation where tb_answer.a_id=tb_userinformation.id and tb_answer.a_id="+id);
return rs;
}
public ResultSet ListHuifu(int id) throws Exception//回复列表
{
connection();
rs=st.executeQuery("select * from tb_answer,tb_userinformation where tb_answer.a_id=tb_userinformation.id and tb_question.q_id="+id+" order by tb_answer.a_id ASC");//DESC
return rs;
}
public void AddNewWenti(String title,String content) throws Exception//提出新问题
{
String date=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date());
connection();
st.executeUpdate("insert into tb_question (title,content,createtime) values("+title+"','"+content+"','"+date+"')");
}
public void AddNewHuifu(int wentiID,String content,int userID) throws Exception//回复
{
String date=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date());
connection();
st.executeUpdate("insert into tb_answer (q_id,user_id,content,createtime) values("+wentiID+","+userID+",'"+content+"','"+date+"')");
}
public void UpdateHuifu(int huifuID,String content) throws Exception//修改回复
{
String date=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date());
connection();
st.executeUpdate("update tb_answer set content='"+content+"',createtime='"+date+"' where q_id="+huifuID);
}
public void UpdateWenti(int wentiID,String content,String title) throws Exception//修改问题
{
String date=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date());
connection();
st.executeUpdate("update tb_question set title='"+title+"' , content='"+content+"',createtime='"+date+"' where q_id="+wentiID);
}
public void DeleteWenti(int wentiID) throws Exception//删除问题
{
connection();
st.executeUpdate("delete from tb_question where q_id="+wentiID);
st.executeUpdate("delete from tb_answer where q_id="+wentiID);
}
public void DeleteHuifu(int huifuID) throws Exception//删除回复
{
connection();
st.executeUpdate("delete from tb_answer where a_id="+huifuID);
}
public void closeCon() throws Exception
{
con.close();
}
public static void main(String[] args) throws SQLException, Exception{
DBOperate_wenti d = new DBOperate_wenti();
ResultSet rs=d.ListWenti();
System.out.println(rs);
rs.close();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
JSP+SQL2000精品课程网站
共121个文件
jsp:45个
gif:14个
mno:14个
3星 · 超过75%的资源 需积分: 10 53 下载量 75 浏览量
2010-05-31
00:42:34
上传
评论 1
收藏 1.72MB RAR 举报
温馨提示
这个网站是我用差不多一个月的时间做的 还有很多功能没有完善 希望对大家的学习有所帮助
资源推荐
资源详情
资源评论
收起资源包目录
JSP+SQL2000精品课程网站 (121个子文件)
DBOperate_wenti.class 5KB
DBOperate_userinfo.class 4KB
DBOperate_xuexi.class 3KB
DBOperate_news.class 3KB
DBOperate_admin.class 2KB
.classpath 552B
org.eclipse.wst.jsdt.ui.superType.container 49B
fenghuolun.fla 446KB
a5.gif 5KB
a7.gif 5KB
a2.gif 5KB
a6.gif 5KB
a4_.gif 5KB
abc.gif 5KB
a8.gif 5KB
daohang.gif 4KB
a3.gif 2KB
a1.gif 2KB
a4.gif 2KB
pic1.gif 1KB
pic2.gif 1KB
titleb.gif 68B
sbcl.htm 21KB
ltxt.htm 6KB
syzd.htm 5KB
kjxz.htm 5KB
jxlx.htm 5KB
jsdw.htm 5KB
kcjs.htm 5KB
jxdg.htm 4KB
login.htm 4KB
ckwx.htm 4KB
zhuce.htm 3KB
login_.htm 3KB
login.htm 1KB
_desktop.ini 9B
msbase.jar 280KB
mssqlserver.jar 66KB
msutil.jar 58KB
DBOperate_wenti.java 3KB
DBOperate_userinfo.java 3KB
DBOperate_xuexi.java 2KB
DBOperate_news.java 2KB
DBOperate_admin.java 687B
JDSJ070.jpg 86KB
090501-2161225.jpg 14KB
090501-2200110.jpg 12KB
.jsdtscope 500B
index.jsp 6KB
index.jsp 6KB
newslist.jsp 6KB
wentilist.jsp 6KB
wentiview.jsp 5KB
userlist.jsp 5KB
newMima.jsp 4KB
editWenti.jsp 4KB
huifuwenti.jsp 4KB
wentiview.jsp 4KB
newwenti.jsp 4KB
newUsername.jsp 4KB
editHuifu.jsp 4KB
test.jsp 3KB
index.jsp 3KB
newquestion.jsp 3KB
news.jsp 3KB
check.jsp 3KB
newsview.jsp 3KB
new_news.jsp 2KB
stgl.jsp 2KB
index.jsp 2KB
addhuifu.jsp 917B
update_username.jsp 870B
addquestion.jsp 852B
update_mima.jsp 825B
updateWenti.jsp 810B
login.jsp 792B
updateHuifu.jsp 761B
deletehuifu.jsp 727B
delete_news.jsp 716B
addnews.jsp 705B
addwenti.jsp 700B
deleteuser.jsp 697B
registor.jsp 690B
deletewenti.jsp 680B
adminlogin.jsp 633B
user_info.jsp 612B
logout.jsp 263B
logout.jsp 122B
err.jsp 71B
err.jsp 71B
err.jsp 71B
err.jsp 71B
editquestion.jsp 0B
ss.mdb 212KB
MANIFEST.MF 36B
fenghuolun.swf.mno 137B
JDSJ070.jpg.mno 116B
pic1.gif.mno 113B
pic2-.gif.mno 113B
pic2.gif.mno 113B
共 121 条
- 1
- 2
资源评论
- comeon_grace2013-05-12不能运行,好失望
- 一将功成2014-04-29缺少了数据库,不能用
- pxt199010272012-11-03连数据库都没有
- 疯狂--石头2013-04-11缺少了数据库,不能用
- 义博说2013-05-03缺少数据库,不能用
shujukubimuyu
- 粉丝: 14
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功