/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Mybean;
import java.sql.*;
/**
*
* @author hejie
*/
public class dbcon {
String user="root";
String password="123";
String driverName="com.mysql.jdbc.Driver";
String connectURL="jdbc:mysql://localhost:3306/news";
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
public dbcon()
{
try{
Class.forName(driverName);
conn=DriverManager.getConnection(connectURL,user,password);
conn.setAutoCommit(true);
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
System.out.println("数据库连接成功");
}
catch(Exception e)
{
System.out.println("数据库连接错误"+e.getMessage());
}
}
public ResultSet executeQuery(String sql)
{
try{
rs=stmt.executeQuery(sql);
}
catch(SQLException ex)
{
System.out.println("数据库查询错误"+ex.getMessage());
}
return rs;
}
public int executeUpdate(String sql)
{
try{
int i=stmt.executeUpdate(sql);
return i;
}
catch(SQLException ex)
{
System.out.println("执行更新错误:"+ex.getMessage());
return -1;
}
}
public Connection getcon()
{
return conn;
}
public void closedb(){
try
{
conn.close();
stmt.close();
System.out.println("数据库关闭成功");
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("数据库关闭失败");
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
jsp新闻网站 新闻发布 新闻修改删除等操作
共57个文件
jsp:30个
xml:9个
jar:3个
4星 · 超过85%的资源 需积分: 10 32 下载量 177 浏览量
2010-05-08
14:53:59
上传
评论
收藏 2.05MB RAR 举报
温馨提示
jsp新闻网站 非常小 初学者练手用啊 只用几个mysql数据表 包括登陆 新闻发布 新闻修改删除等操作
资源推荐
资源详情
资源评论
收起资源包目录
shiyan1.rar (57个子文件)
shiyan1
test
dist
shiyan1.war 1.07MB
src
conf
MANIFEST.MF 25B
java
mysql-connector-java-5.0.7-bin.jar 524KB
Mybean
dbcon.java 2KB
charsetConvert.java 1KB
usdb.java 2KB
web
login.jsp 3KB
tianjia.jsp 1KB
WEB-INF
web.xml 491B
index.jsp 1KB
META-INF
context.xml 88B
newslist.jsp 5KB
image
top.jpg 9KB
register.jsp 2KB
newsmodify.jsp 4KB
image.jsp 2KB
checkregister.jsp 3KB
top.jsp 860B
denglu.jsp 2KB
newsadd.jsp 3KB
left.jsp 1KB
main.jsp 2KB
newsdisplay.jsp 1KB
check.jsp 2KB
build
web
login.jsp 3KB
tianjia.jsp 1KB
WEB-INF
web.xml 491B
lib
mysql-connector-java-5.0.7-bin.jar 524KB
classes
mysql-connector-java-5.0.7-bin.jar 524KB
Mybean
charsetConvert.class 1KB
usdb.class 2KB
dbcon.class 2KB
.netbeans_automatic_build 0B
index.jsp 1KB
META-INF
context.xml 88B
MANIFEST.MF 25B
newslist.jsp 5KB
image
top.jpg 9KB
register.jsp 2KB
newsmodify.jsp 4KB
image.jsp 2KB
checkregister.jsp 3KB
top.jsp 860B
denglu.jsp 2KB
newsadd.jsp 3KB
left.jsp 1KB
main.jsp 2KB
newsdisplay.jsp 1KB
check.jsp 2KB
build.xml 3KB
nbproject
build-impl.xml 43KB
private
private.xml 211B
private.properties 2KB
ant-deploy.xml 2KB
project.properties 2KB
project.xml 925B
genfiles.properties 455B
共 57 条
- 1
资源评论
- gaoyangqinqin2012-06-11没太看懂,感觉不全是jsp的内容,还是谢谢楼主,对我还是有些帮助的
shiyanming1223
- 粉丝: 30
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功