16 dataSource.url=jdbc\:mysql\://localhost\:3307/spring useUnicode\=true&characterEncoding\=UTF-8
17 dataSource.username=root
18 dataSource.password=root
19 dataSource.initialSize=1
20 dataSource.maxActive=300
21 dataSource.maxIdle=2
22 dataSource.minIdle=1
23
24 dataSource.driverClassName对于dataSource必须是在此xml配置文件中可以找到的bean,
25 否则程序会出错。
26 -->
27
28
29
31
32
33
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
50 hibernate.hbm2ddl.auto=update
51 hibernate.show_sql=true
52 hibernate.format_sql=true
53 hibernate.cache.use_second_level_cache=true
54 hibernate.cache.use_query_cache=false
55 hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
56
57
58
59
60
61
62
64
65
66
67
68
69
70
71
/spring+hibernate/src/jdbc.properties
1 driverClassName=org.gjt.mm.mysql.Driver
2 url=jdbc\:mysql\://localhost\:3307/spring useUnicode\=true&characterEncoding\=UTF-8
3 username=root
4 password=root
5 initialSize=1
6 maxActive=300
7 maxIdle=2
8 minIdle=1
运行结果:
1 log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
2 log4j:WARN Please initialize the log4j system properly.
3 Hibernate:
4 select
5 max(id)
6 from
7 person
8 Hibernate:
9 insert
10 into
11 spring.person
12 (name, age, sex, id)
13 values
14 ( , , , )
15 Hibernate:
16 select
17 person0_.id as id0_0_,
18 person0_.name as name0_0_,
19 person0_.age as age0_0_,
20 person0_.sex as sex0_0_
21 from
22 spring.person person0_
23 where
24 person0_.id=
25 Hibernate:
26 select
27 person0_.id as id0_0_,
28 person0_.name as name0_0_,
29 person0_.age as age0_0_,
30 person0_.sex as sex0_0_
31 from
32 spring.person person0_
33 where
34 person0_.id=
35 Hibernate:
36 select
37 person0_.id as id0_,
38 person0_.name as name0_,
39 person0_.age as age0_,
40 person0_.sex as sex0_
41 from
42 spring.person person0_
43 *******************
44 2 hanyuan 21 男
45 3 hongten 21 男
46 Hibernate:
47 select
48 person0_.id as id0_0_,
49 person0_.name as name0_0_,
50 person0_.age as age0_0_,
51 person0_.sex as sex0_0_
52 from
53 spring.person person0_
54 where
55 person0_.id=