标签:连接池 str 分享图片 conf set 开发环境 imp ace only
1 jdbc.driver=com.mysql.jdbc.Driver 2 jdbc.url=jdbc:mysql://localhost:3306/java505?useSSL=true&characterEncoding=utf8&useSSL=true 3 jdbc.username=root 4 jdbc.password=root
1 <?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE configuration 3 PUBLIC "-//mybatis.org//DTD Config 3.0//EN" 4 "http://mybatis.org/dtd/mybatis-3-config.dtd"> 5 <configuration> 6 <properties resource="db.properties"/> 7 <!-- 用于指定使用哪个开发 8 用于指定使用的环境id 9 --> 10 <environments default="dev"> 11 <!-- 用于配置开发环境 12 id:环境的唯一识别码 13 --> 14 <environment id="dev"> 15 <!-- 事务管理器 16 type:用于设定mybatis采用什么方式管理事务 17 JDBC表示和JDBC一样事务的管理方式 18 --> 19 <transactionManager type="JDBC"/> 20 <!-- 数据源/连接池 21 用于配置链接池和数据库链接的参数 22 type:用于设置mybatis是否采用链接池技术 23 连接池:用来存数据库链接的,减少数据库的频繁开关 24 POOLED表示mybatis采用连接池技术 25 --> 26 <dataSource type="POOLED"> 27 <property name="driver" value="${jdbc.driver}"/> 28 <property name="url" value="${jdbc.url}"/> 29 <property name="username" value="${jdbc.username}"/> 30 <property name="password" value="${jdbc.password}"/> 31 </dataSource> 32 </environment> 33 </environments> 34 <!-- 扫描mapper文件 --> 35 <!-- 文件的全限制路径要用/ --> 36 <mappers> 37 <mapper resource="com/bjsxt/mapper/UserMapper.xml"/> 38 </mappers> 39 </configuration>
1 <?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE mapper 3 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 4 "http://mybatis.org/dtd/mybatis-|3-mapper.dtd"> 5 <!-- namespa:命名空间,可以随意定义,一般情况下要写全限定路径(包名加类) 6 MyBatis管理SQL语句是通过namespace+id来定位的 7 --> 8 <mapper namespace="com.bjsxt.mapper.UserMapper"> 9 <!-- select标签用于编写查询语句 10 id:sql语句的唯一的标识,类比为方法名 11 resultType:用于设定返回结果的类型(全限定路径) 12 如果返回结果是集合,要写集合泛型的类型 13 --> 14 <select id="sellAll" resultType="com.bjsxt.pojo.User"> 15 select * from t_user 16 </select> 17 <select id="selOne" resultType="com.bjsxt.pojo.User"> 18 select * from t_user where id=1 19 </select> 20 </mapper>
1 package com.bjsxt.pojo; 2 3 import java.io.Serializable; 4 5 public class User implements Serializable { 6 private int id; 7 private String username; 8 private String password; 9 public String toString() { 10 return "User [id=" + id + ", username=" + username + ", password=" 11 + password + "]"; 12 } 13 public int hashCode() { 14 final int prime = 31; 15 int result = 1; 16 result = prime * result + id; 17 result = prime * result + ((password == null) ? 0 : password.hashCode()); 18 result = prime * result + ((username == null) ? 0 : username.hashCode()); 19 return result; 20 } 21 public boolean equals(Object obj) { 22 if (this == obj) 23 return true; 24 if (obj == null) 25 return false; 26 if (getClass() != obj.getClass()) 27 return false; 28 User other = (User) obj; 29 if (id != other.id) 30 return false; 31 if (password == null) { 32 if (other.password != null) 33 return false; 34 } else if (!password.equals(other.password)) 35 return false; 36 if (username == null) { 37 if (other.username != null) 38 return false; 39 } else if (!username.equals(other.username)) 40 return false; 41 return true; 42 } 43 public int getId() { 44 return id; 45 } 46 public void setId(int id) { 47 this.id = id; 48 } 49 public String getUsername() { 50 return username; 51 } 52 public void setUsername(String username) { 53 this.username = username; 54 } 55 public String getPassword() { 56 return password; 57 } 58 public void setPassword(String password) { 59 this.password = password; 60 } 61 public User(int id, String username, String password) { 62 super(); 63 this.id = id; 64 this.username = username; 65 this.password = password; 66 } 67 public User() { 68 super(); 69 } 70 71 }
1 # Set root category priority to INFO and its only appender to CONSOLE. 2 log4j.rootCategory=DEBUG, CONSOLE 3 #log4j.rootCategory=INFO, CONSOLE, LOGFILE 4 5 # 单独设置sql语句的输出级别为debug 6 #方法级别 7 #log4j.logger.com.bjsxt.mapper.UserMapper.selAll=DEBUG 8 #类级别 9 #log4j.logger.com.bjsxt.mapper.UserMapper=DEBUG 10 #包级别 11 log4j.logger.com.bjsxt.mapper=DEBUG 12 13 # LOGFILE is set to be a File appender using a PatternLayout. 14 log4j.appender.LOGFILE=org.apache.log4j.FileAppender 15 #存的位置 16 log4j.appender.LOGFILE.File=axis.log 17 log4j.appender.LOGFILE.Append=true 18 log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout 19 log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
标签:连接池 str 分享图片 conf set 开发环境 imp ace only
原文地址:https://www.cnblogs.com/wq-9/p/10206458.html