项目要求
31管家婆项目文档讲义.doc
管家婆part1
GJiaPo.zip
SQL文件
用可视化工具导入即可
gjp.sql
数据库代码
可用dos命令直接写入数据库
/*SQLyog Ultimate v11.24 (32 bit)MySQL - 5.7.20-log : Database - gjp**********************************************************************//*!40101 SET NAMES utf8 */;/*!40101 SET SQL_MODE=''*/;/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;CREATE DATABASE /*!32312 IF NOT EXISTS*/`gjp` /*!40100 DEFAULT CHARACTER SET utf8 */;USE `gjp`;/*Table structure for table `gjp_zhangwu` */DROP TABLE IF EXISTS `gjp_zhangwu`;CREATE TABLE `gjp_zhangwu` ( `zwid` int(11) NOT NULL AUTO_INCREMENT, `flname` varchar(200) DEFAULT NULL, `money` double DEFAULT NULL, `zhanghu` varchar(100) DEFAULT NULL, `createtime` date DEFAULT NULL, `description` varchar(1000) DEFAULT NULL, PRIMARY KEY (`zwid`)) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;/*Data for the table `gjp_zhangwu` */insert into `gjp_zhangwu`(`zwid`,`flname`,`money`,`zhanghu`,`createtime`,`description`) values (2,'工资收入',12345,'现金','2016-03-15','开工资了'),(3,'服装支出',1998,'现金','2016-04-02','买衣服'),(4,'吃饭支出',325,'现金','2016-06-18','朋友聚餐'),(5,'股票收入',8000,'工商银行','2016-10-28','股票大涨'),(6,'股票收入',5000,'工商银行','2016-10-28','股票又大涨'),(7,'工资收入',5000,'交通银行','2016-10-28','又开工资了'),(8,'礼金支出',5000,'现金','2016-10-28','朋友结婚'),(9,'其他支出',1560,'现金','2016-10-29','丢钱了'),(10,'交通支出',2300,'交通银行','2016-10-29','油价还在涨啊'),(11,'吃饭支出',1000,'工商银行','2016-10-29','又吃饭'),(12,'工资收入',1000,'现金','2016-10-30','开资'),(13,'交通支出',2000,'现金','2016-10-30','机票好贵'),(14,'工资收入',5000,'现金','2016-10-30','又开资');/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
C3P0
c3p0-config.xml
<?xml version="1.0" encoding="UTF-8"?><c3p0-config> <!-- 使用默认的配置读取连接池对象--> <default-config> <!-- 连接参数 --> <property name="drierClass">com.mysql.jdbc.Driver</property> <property name="jdbcUrl">jdbc:mysql://localhost:3306/gjp</property> <property name="user">root</property> <property name="password">root</property> <!-- 连接池参数 --> <!-- 初始连接数 --> <property name="initialPoolSize">5</property> <!-- 最大连接数 --> <property name="maxPoolSize">10</property> <!-- 最大等待时间 --> <property name="checkoutTimeout">2000</property> <!-- 最大空闲回收时间 --> <property name="maxIdleTime">1000</property> </default-config></c3p0-config>
c3p0Utils.java
package com.xx.JdbcUtils.study;import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.sql.DataSource;import com.mchange.v2.c3p0.ComboPooledDataSource;/* * C3P0连接池 */public class JunitSourceDemo { //创建一个连接池 private static final ComboPooledDataSource dataSource = new ComboPooledDataSource(); //获得链接 public static Connection getConnection() throws SQLException { return dataSource.getConnection(); } //获得连接池 public static DataSource getDataSource() { return dataSource;} //释放资源 public static void release(Statement stmt,Connection conn) throws SQLException { stmt.close(); conn.close(); } public static void release(ResultSet rs,Statement stmt,Connection conn) throws SQLException { rs.close(); stmt.close(); conn.close(); }}