package com.enterprise.conn;
import com.enterprise.conn.ConnectionSql;
import com.enterprise.bean.*;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.util.*;
public class ExecuteSQL {
public ExecuteSQL(){
}
/**
*
* @param name
* @param pwd
* @return 标志
* 用户存在返回1,用户不存在返回0
*/
public int checkUser(String name,String pwd){
int flag=0;
String sql="select * from tb_usertable where name='"+name+"' and password='"+pwd+"'";
try{
ConnectionSql consql=new ConnectionSql();
ResultSet rs=consql.executequery(sql);
if(rs.next())
flag=1;
else
flag=0;
consql.close();
}catch(SQLException e){
e.printStackTrace();
}
return flag;
}
/**
*
* @return newslist 新闻列表
* 返回新闻列表
*/
public List<News> selectNewsAll(){
List<News> newslist=new ArrayList<News>();
String sql="select * from tb_news";
try{
ConnectionSql consql=new ConnectionSql();
ResultSet rs=consql.executequery(sql);
while(rs.next()){
News news=new News();
news.setNewid(rs.getInt("id"));
news.setContent(rs.getString("content"));
news.setTitle(rs.getString("title"));
news.setAuthor(rs.getString("author"));
news.setSubmittime(rs.getString("submittime"));
newslist.add(news);
}
consql.close();
}catch(SQLException e){
e.printStackTrace();
}
return newslist;
}
/**
*
* @param id
* @return 返回一条新闻信息
*/
public News selectNewsByID(int id){
News news=new News();
String sql="select * from tb_news where id='"+id+"'";
try{
ConnectionSql consql=new ConnectionSql();
ResultSet rs=consql.executequery(sql);
if(rs.next()){
news.setNewid(rs.getInt("id"));
news.setContent(rs.getString("content"));
news.setTitle(rs.getString("title"));
news.setAuthor(rs.getString("author"));
news.setSubmittime(rs.getString("submittime"));
}
consql.close();
}catch(SQLException e){
e.printStackTrace();
}
return news;
}
/**
*
* @param news
* @return flag
* 如果成功插入一条新闻,则返回1,否则返回0
*/
public int newsInsert(News news){
int flag=0;
String sql="insert into tb_news(title,content,author) values('"+news.getTitle()+"','"+news.getContent()+"','"+news.getAuthor()+"')";
ConnectionSql consql=new ConnectionSql();
flag=consql.executeupdate(sql);
consql.close();
return flag;
}
/**
*
* @param news
* @return flag
* 如果成功更新一条新闻,则返回1,否则返回0;
*/
public int newsUpdate(News news){
int flag=0;
String sql="update tb_news set title='"+news.getTitle()+"',author='"+news.getAuthor()+"',content='"+news.getContent()+"'where id='"+news.getNewid()+"'";
ConnectionSql consql=new ConnectionSql();
flag=consql.executeupdate(sql);
consql.close();
return flag;
}
/**
*
* @param id
* @return flag
* 如果删除新闻成功,返回1,否则返回0;
*/
public int newsDel(int id){
int flag=0;
String sql="delete from tb_news where id='"+id+"'";
ConnectionSql consql=new ConnectionSql();
flag=consql.executeupdate(sql);
consql.close();
return flag;
}
/**
*
* @return businesslist 产品列表
* 返回产品列表
*/
public List<Business> selectBusinessAll(){
List<Business> businesslist=new ArrayList<Business>();
String sql="select * from tb_business";
try{
ConnectionSql consql=new ConnectionSql();
ResultSet rs=consql.executequery(sql);
while(rs.next()){
Business business=new Business();
business.setBusinessid(rs.getInt("id"));
business.setCategory(rs.getString("category"));
business.setImg(rs.getString("img"));
business.setMs(rs.getString("ms"));
business.setName(rs.getString("name"));
business.setSubmittime(rs.getString("submittime"));
businesslist.add(business);
}
consql.close();
}catch(SQLException e){
e.printStackTrace();
}
return businesslist;
}
/**
*
* @return 产品个数
* 返回产品个数
*/
public int getBusinessCount(){
int count=0;
String sql="select count(*) from tb_business";
try{
ConnectionSql consql=new ConnectionSql();
ResultSet rs=consql.executequery(sql);
while(rs.next()){
count=rs.getInt(1);
}
rs.last();
consql.close();
}catch(SQLException e){
e.printStackTrace();
}
return count;
}
/**
*
* @return 返回所有产品记录集
* 返回所有产品记录集
*/
public ResultSet selectbusiness(){
ResultSet rs=null;
try{
ConnectionSql consql=new ConnectionSql();
String sql="select * from tb_business";
rs=consql.executequery(sql);
rs.last();
consql.close();
}catch(Exception e){
e.printStackTrace();
}
//connsqlserver.close();
return rs;
}
/**
* 按所分页码的要求查询相应产品信息
* @param page
* @return 记录集
*/
public List<Business> selestBsinessByPage(int page){
List<Business> businesslist=new ArrayList<Business>();
CountPage count=new CountPage();
ConnectionSql consql=new ConnectionSql();
String sql="select top "+5+" * from tb_business where id not in(select top "+count.getPagesize()*page+" id from tb_business order by id)order by id";
ResultSet rs=consql.executequery(sql);
try {
while(rs.next()){
Business business=new Business();
business.setBusinessid(rs.getInt("id"));
business.setCategory(rs.getString("category"));
business.setImg(rs.getString("img"));
business.setMs(rs.getString("ms"));
business.setName(rs.getString("name"));
business.setSubmittime(rs.getString("submittime"));
businesslist.add(business);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return businesslist;
}
/**
* 实现商品的注册
* @param business
* @return
*/
public int businessAdd(Business business){
int flag=0;
ConnectionSql consql=new ConnectionSql();
String sql="insert into tb_business(name,img,ms,category) values('"+business.getName()+"','"+business.getImg()+"','"+business.getMs()+"','"+business.getCategory()+"')";
flag=consql.executeupdate(sql);
consql.close();
return flag;
}
/**
* 检索所有目录列表
* @return 目录列表
*/
public List<Category> selectCategoryAll(){
List<Category> categorylist=new ArrayList<Category>();
String sql="select * from tb_category";
try{
ConnectionSql consql=new ConnectionSql();
ResultSet rs=consql.executequery(sql);
while(rs.next()){
Category category=new Category();
category.setId(rs.getInt("id"));
category.setCategoryname(rs.getString("categoryname"));
category.setSubmittime(rs.getString("submittime"));
categorylist.add(category);
}
consql.close();
}catch(SQLException e){
e.printStackTrace();
}
return categorylist;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
企业门户网站jsp+javabean+css和sql2000 (138个子文件)
ExecuteSQL.class 7KB
ConnectionSql.class 2KB
CountPage.class 2KB
CodeFilter.class 1KB
Business.class 1KB
News.class 1KB
Category.class 960B
User.class 918B
MyEncoder.class 802B
.classpath 826B
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 973B
Thumbs.db 199KB
Thumbs.db 115KB
Thumbs.db 27KB
Thumbs.db 27KB
Thumbs.db 23KB
Thumbs.db 6KB
5.gif 57KB
4.gif 56KB
ht03.gif 52KB
2.gif 49KB
5.gif 49KB
4.gif 49KB
7.gif 46KB
3.gif 30KB
4.gif 27KB
1.gif 27KB
3.gif 25KB
4.gif 24KB
ht05.gif 23KB
ht05new2.gif 23KB
32.gif 23KB
31.gif 22KB
33.gif 22KB
30.gif 21KB
ht06.gif 21KB
2.gif 13KB
ht02.gif 13KB
10.gif 11KB
5.gif 11KB
8.gif 10KB
ht01.gif 10KB
5.gif 10KB
8.gif 10KB
7.gif 10KB
14.gif 10KB
9.gif 10KB
4.gif 10KB
6.gif 10KB
6.gif 10KB
6.gif 8KB
3.gif 7KB
8.gif 7KB
7.gif 6KB
1.gif 6KB
ht046.gif 6KB
11.gif 6KB
ht04.gif 6KB
ht043.gif 6KB
ht045.gif 6KB
ht042.gif 6KB
ht044.gif 6KB
ht041.gif 5KB
5.gif 2KB
2.gif 2KB
1.gif 2KB
12.gif 2KB
3.gif 1KB
1.gif 1KB
16.gif 946B
15.gif 857B
7.gif 645B
8.gif 635B
2.gif 519B
8.gif 517B
2.gif 517B
3.gif 517B
13.gif 484B
9.gif 458B
6.gif 456B
1.gif 456B
11.gif 456B
9.gif 403B
10.gif 264B
17.gif 231B
6.gif 225B
12.gif 223B
7.gif 157B
分隔符.gif 43B
分隔符.gif 43B
分隔符.gif 43B
分隔符.gif 43B
gswh.html 3KB
jszc.html 3KB
msbase.jar 280KB
commons-beanutils-1.7.0.jar 184KB
commons-io-1.3.2.jar 86KB
mssqlserver.jar 66KB
msutil.jar 58KB
共 138 条
- 1
- 2
资源评论
- Aa35002012-12-13在filter中codefilter文件中内容错误很多。运行不起来。整个网页不是居中显示的,看起来不是很美观。。。
jingangbuhuaizhishen
- 粉丝: 13
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功