package com.util;
import java.sql.*;
import javax.activation.DataSource;
import java.sql.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.*;
public class DBO {
private Connection conn;
private Statement stmt;
private DataSource ds;
public DBO()
{
open();
}
/**
打开数据库
*/
public void open()
{
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://127.0.0.1:3306/jspkeyun?characterEncoding=gb2312&mysqlEncoding=gb2312";
// MySQL配置时的用户名
String user = "root";
// MySQL配置时的密码
String password = "abc123";
try {
Class.forName(driver);
conn = DriverManager.getConnection(url, user, password);
stmt=conn.createStatement();
System.out.println("打开数据库连接");
}
catch (Exception ex)
{
System.err.println("打开数据库时出错: " + ex.getMessage());
}
}
/**
关闭数据库,将连接返还给连接池
*/
public void close()
{
try
{
// connMgr.freeConnection("java", conn);
conn.close();
System.out.println ("释放连接");
}
catch (SQLException ex)
{
System.err.println("返还连接池出错: " + ex.getMessage());
}
}
/**
执行查询
*/
public ResultSet executeQuery(String sql) throws SQLException
{
ResultSet rs = null;
rs = stmt.executeQuery(sql);
System.out.println ("执行查询");
return rs;
}
public ResultSet query(String sql) throws SQLException
{
ResultSet rs = null;
System.out.println(sql);
rs = stmt.executeQuery(sql);
System.out.println ("执行查询");
return rs;
}
/**
执行增删改
*/
public int executeUpdate(String sql) throws SQLException
{
int ret = 0;
ret = stmt.executeUpdate(sql);
System.out.println ("执行增删改");
return ret;
}
public int update(String sql) throws SQLException
{
int ret = 0;
ret = stmt.executeUpdate(sql);
System.out.println ("执行增删改");
return ret;
}
/**
将SQL语句加入到批处理
*/
public void addBatch(String sql) throws SQLException
{
stmt.addBatch(sql);
}
/**
执行批处理
*/
public int [] executeBatch() throws SQLException
{
boolean isAuto=conn.getAutoCommit();
conn.setAutoCommit(false);
int [] updateCounts = stmt.executeBatch();
// conn.commit();
// conn.setAutoCommit(isAuto);
//conn.setAutoCommit(true);
return updateCounts;
}
public boolean getAutoCommit() throws SQLException
{
return conn.getAutoCommit();
}
public void setAutoCommit(boolean auto) throws SQLException
{
conn.setAutoCommit(auto);
}
public void commit() throws SQLException
{
conn.commit();
// this.close();
}
public void rollBack() throws SQLException
{
conn.rollback();
// this.close();
}
public static void main(String[] args) {
DBO con= new DBO();
//con.open();
// ResultSet rs=null;
// String sql="select id dd from didian";
// List list=new ArrayList();
// //ResultSet rs=null;
//
//
// try{
// rs=con.executeQuery(sql);
// }catch(Exception e){
// System.out.println(e.toString());
//
// }
con.close();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一、源码特点 java客运管理系统是一套完善的java web信息管理系统,对理解JSP java编程开发语言有帮助,系统具有完整的源代码和数据库,系统主要采用B/S模式开发。开发环境为 TOMCAT7.0,Myeclipse8.5开发,数据库为Mysql5.0,使用java语言开发。 二、功能介绍 对应博客已经介绍 三、注意事项 1、管理员账号:admin密码:admin 数据库配置文件DBO.java 2、开发环境为TOMCAT7.0,Myeclipse8.5开发,数据库为Mysql5.0,使用java语言开发。 3、数据库文件名是jspkeyun.sql ,系统名称keyun 4、系统首页地址:http://127.0.0.1:8080/keyun/login.jsp 不含人工调试服务,需要 联系作者购买
资源推荐
资源详情
资源评论
收起资源包目录
java客运管理系统Myeclipse开发mysql数据库web结构java编程计算机网页项目源码 (119个子文件)
admin.css.bak 4KB
DBO.class 3KB
StaticMethod.class 3KB
.classpath 526B
pintuer.css 111KB
component.css 17KB
admin.css 4KB
global.css 2KB
style.css 1KB
icomoon.eot 2KB
icomoon.eot@ 2KB
list-item-cover.gif 2KB
mysql-connector-java-5.0.8-bin.jar 528KB
jspsmart.jar 12KB
DBO.java 3KB
StaticMethod.java 2KB
bg.jpg 101KB
11.jpg 32KB
noimage.jpg 11KB
y.jpg 6KB
passcode.jpg 4KB
jquery.js 94KB
pintuer.js 16KB
xianlu.jsp 7KB
qcxxlist.jsp 7KB
xianlulist.jsp 7KB
yonghulist.jsp 7KB
xlzdlist.jsp 6KB
zhandianlist.jsp 6KB
glylist.jsp 6KB
zhandian.jsp 6KB
gonggaolist.jsp 6KB
list.jsp 6KB
left.jsp 5KB
modify.jsp 5KB
yonghuupdate.jsp 5KB
xianluupdate.jsp 4KB
zhuce.jsp 4KB
qcxxupdate.jsp 4KB
xianluadd.jsp 4KB
yonghuadd.jsp 4KB
qcxxadd.jsp 4KB
xianludetail.jsp 4KB
login.jsp 3KB
modify.jsp 3KB
zhandianupdate.jsp 3KB
gonggaoupdate.jsp 3KB
glyupdate.jsp 3KB
qcxxdetail.jsp 3KB
xlzdupdate.jsp 3KB
yonghudetail.jsp 3KB
gonggaoadd.jsp 3KB
zhandianadd.jsp 3KB
glyadd.jsp 3KB
xlzdadd.jsp 3KB
zhandiandetail.jsp 2KB
gonggaodetail.jsp 2KB
glydetail.jsp 2KB
xlzddetail.jsp 2KB
qcxx_add.jsp 2KB
yonghu_add.jsp 2KB
do.jsp 2KB
gly_add.jsp 1KB
xianlu_update.jsp 1KB
qcxx_update.jsp 1KB
update.jsp 1KB
yonghu_update.jsp 1KB
xlzd_add.jsp 1KB
xianlu_add.jsp 1KB
zhandian_update.jsp 1KB
gonggao_update.jsp 1KB
update.jsp 1KB
gly_update.jsp 1KB
logincheck.jsp 1KB
zhandian_add.jsp 1KB
xlzd_update.jsp 1KB
gonggao_add.jsp 1KB
main.jsp 1KB
zhandiandelete.jsp 866B
gonggaodelete.jsp 863B
xianludelete.jsp 860B
xlzddelete.jsp 860B
yonghudelete.jsp 860B
qcxxdelete.jsp 860B
glydelete.jsp 854B
index.jsp 834B
jscsscommon.jsp 726B
fsession.jsp 529B
session.jsp 370B
MANIFEST.MF 36B
.mymetadata 288B
logo.png 6KB
icon-shijie.png 6KB
icon-china.png 5KB
icon-shandong.png 3KB
icon-qz.png 3KB
icon-taiwan.png 2KB
icon-mp.png 2KB
icon-zyx.png 1KB
ad_ctr.png 1KB
共 119 条
- 1
- 2
资源评论
qq_251836457
- 粉丝: 4206
- 资源: 557
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功