- 浏览: 391129 次
- 性别:
- 来自: 昆明
文章分类
- 全部博客 (198)
- java (28)
- J2EE (19)
- struts (33)
- sping (13)
- hibernate (18)
- mybatis (15)
- connection pool (3)
- DB (26)
- SQL (21)
- html (13)
- js (7)
- json (3)
- jquery (2)
- document (17)
- linux (15)
- C# (1)
- url (2)
- eweb4j (1)
- Turbine (1)
- 框架 (11)
- jdbcTemplate (3)
- aop (2)
- windows (2)
- ubuntu (1)
- eclipse (11)
- JPA (8)
- svn (4)
- get 传值 (2)
- mysql (5)
- oracle (2)
- hadoop (1)
- MongoDB (2)
- spring (1)
- python (1)
最新评论
-
jcbingjc:
楼主,你好,按照上面的配置,我报如下错误:Missing Pe ...
[properJavaRDP]在网页中实现远程连接 -
sucful:
折腾了半天跑不通 ,要传就搞个完整的吧
Struts2 <sx:div/>实现页面模块异步刷新 -
Kattou:
你好! 看了你写的这个分页 感觉很好, 但是不怎么会用么,请指 ...
jsp分页控件 -
我叫PSB:
地址完全用不了
eclipse中的安装 jseclipse -
1111emotion:
我的工程里还是有乱码的情况,我该改的地方都改了。
Eclipse/MyEclipse更改默认字符集 设置UTF-8
1、proxool连接池配置文件proxool.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" destroy-method="close"> <!--驱动类--> <property name="driver"> <value>com.mysql.jdbc.Driver</value> </property> <!--url连接串--> <property name="driverUrl"> <value>jdbc:mysql://192.168.1.17:3306/ibatisTest</value> </property> <!--用户名--> <property name="user"> <value>root</value> </property> <!--密码--> <property name="password"> <value>root</value> </property> <!--数据源的别名--> <property name="alias"> <value>bst</value> </property> <!--最少保持的空闲连接数(默认 2 个)--> <property name="prototypeCount"> <value>1</value> </property> <!--最大连接数(默认 5 个),超过了这个连接数,再有请求时,就排在队列中等候,最大 的等待请求数由 maximum-new-connections 决定 --> <property name="maximumConnectionCount"> <value>2</value> </property> <!--最小连接数(默认 2 个)--> <property name="minimumConnectionCount"> <value>1</value> </property> <!--如果housekeeper(毫秒) 检测到某个线程的活动时间大于这个数值.它将会杀掉这个线程. 所以确认一下你的服务器的带宽.然后定一个合适的值.默认是5分钟.--> <property name="maximumActiveTime"> <value>60000</value> </property> <!-- <property name="houseKeepingSleepTime"> <value>9999</value> </property>--> <!--如果为true,那么每个被执行的SQL语句将会在执行期被log记录(DEBUG LEVEL). 你也可以注册一个ConnectionListener (参看ProxoolFacade)得到这些信息.--> <property name="trace"> <value>true</value> </property> <property name="verbose"> <value>true</value> </property> </bean> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <!--引入ibatis关系对象映射文件--> <property name="configLocation" value="ibatisConfig.xml"/> <property name="dataSource" ref="dataSource"/> </bean> </beans>
2、ibatis开源框架配置文件ibatisConfig.xml <?xml version = "1.0" encoding = "UTF-8" ?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <sqlMap resource = "model/User.xml" /> </sqlMapConfig>
3、User.java
package model; import java.io.Serializable; public class User implements Serializable { private static final long serialVersionUID = 1L; private Integer id; private String name_s; private Integer sex; public User() { } public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } public String getName_s() { return name_s; } public void setName_s(String name_s) { this.name_s = name_s; } public Integer getSex() { return this.sex; } public void setSex(Integer sex) { this.sex = sex; } }
4、User.xml
<?xml version = "1.0" encoding = "UTF-8" ?> <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd"> <sqlMap namespace = "User" > <typeAlias alias = "user" type = "model.User" /> <select id = "User.getUser" parameterClass = "java.lang.String" resultClass = "user" > select name_s,sex from t_useR where name_s = #name# </select> <select id = "getAllUser" resultClass = "user" > select id, name_s from t_useR </select> <update id = "updateUser" parameterClass = "user" > UPDATE t_useR SET name_s=#name_s#, sex=#sex# WHERE id = #id# </update> <insert id = "insertUser" parameterClass = "user" > INSERT INTO t_useR ( name_s, sex) VALUES ( #name_s#, #sex# ) </insert> <delete id = "deleteUser" parameterClass = "java.lang.String" > delete from t_useR where id=#value# </delete> </sqlMap>
5、Main.java public class Main{
public static void main(String[] args){ ApplicationContext context = new ClassPathXmlApplicationContext("proxool3.xml"); SqlMapClient sqlMapClient = (SqlMapClient) context.getBean("sqlMapClient"); User u = (User) sqlMapClient.queryForObject("User.getUser", "3"); System.out.println("sex:" + u.getSex()); } }
6、web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>proxooladmin</servlet-name> <servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>proxooladmin</servlet-name> <url-pattern>/proxooladmin</url-pattern> </servlet-mapping> <!-- 配置受保护域,只有Tomcat管理员才能察看连接池的信息 --> <security-constraint> <web-resource-collection> <web-resource-name>proxool</web-resource-name> <url-pattern>/proxooladmin</url-pattern> </web-resource-collection> <auth-constraint> <role-name>manager</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>proxool manager Application</realm-name> </login-config> <security-role> <description>The role that is required to log in to the Manager Application</description> <role-name>manager</role-name> </security-role> <error-page> <error-code>401</error-code> <location>/error/401.jsp</location> </error-page> </web-app>
7、401.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <% response.setHeader("WWW-Authenticate", "Basic realm=\"Tomcat Manager Application\""); %> </body> </html>
所需jar包:commons-logging-api-1.1.jar、ibatis-2.3.3.720.jar、log4j-1.2.11.jar、mysql-connector-java-5.1.9.jar、proxool-0.9.1.jar、proxool-cglib.jar、spring.jar
发表评论
-
Mybatis配置文件修改后自动加载
2017-05-01 13:35 856Mybatis的mapper文件中的sql语句被修改后, ... -
SpringMvc+MyBatis+Freemarker 配置
2017-04-06 09:32 23321、引入Jar包: spring所有jar文件 my ... -
Mybatis执行SQL语句的方式
2012-07-02 10:30 2575最近在玩Mybatis,感觉官方文档对于通过执行mapper接 ... -
Struts2整合Spring、JPA
2012-02-27 09:46 1879一直觉得JPA很神秘,最近抽空看了下,下面贴出刚才做的St ... -
spring mvc 配置
2011-11-28 14:14 13831、/WEB-INF/web.xml <ser ... -
spring jdbcTemplate调用存储过程
2011-11-27 21:36 1404第一种方式: List<Map<String,Ob ... -
spring3之JdbcTemplate AOP 事务
2011-11-27 01:36 7411一、applicationContext.xml配置:定义事务 ... -
Spring AOP代理时 ClassCastException: $Proxy0 cannot be cast to (类型转换错误)
2011-11-27 01:37 1441Spring AOP代理时 ClassCastExce ... -
spring3之JdbcTemplate详解
2011-11-27 01:36 33741、JdbcTemplate操作数据库 Spring ... -
JAVA三大框架的各自作用
2011-11-25 00:04 3149一、Spring Spring是 ... -
mybatis简单运用(基于Annotation)
2011-11-24 00:17 1354本文主要介绍了如何使用mybatis进行简单的数据库操 ... -
使用SSH到底是为了快速开发,还是为了标准?
2011-11-25 00:00 2425使用SSH到底是为了快速开发,还是为了标准? 使用S ... -
Struts2、Spring、Hibernate 高效开发的最佳实践
2011-11-26 00:16 1223引言 SSH(Struts2+Spring+Hi ... -
hibernate c3p0配置
2011-11-14 08:56 1125<?xml version="1.0& ... -
集成struts2 spring hibernate,使用注解
2011-11-14 08:56 1477集 成struts,spring,hibernate时,对于 ... -
proxool配置与使用
2011-11-16 00:07 3144其实网上的资料很全~ 不过写一下自己的,以便后面有得 ... -
Ibatis的两表联查问题
2011-11-17 09:06 1695实体类: 多方: public class ... -
IBatis 怎样直接执行SQL语句
2011-11-17 09:07 2366先到ibatis的配置文件中加入 <statemen ... -
iBatis动态SQL标签用法
2011-11-17 09:07 20661、动态SQL片段 通过SQL片段达到代码复用 ... -
Ibatis调用存储过程
2011-11-18 10:01 1056Ibatis调用存储过程 procedure.xml ...
相关推荐
spring ibatis整合所需jar包
简单的 struts2 spring ibatis 整合架构
struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码
struts2 spring ibatis 项目整合源码
Struts2 Spring Ibatis实例整合 里面实现了用户登录注册查询删除 认真体会里面的架构
spring与ibatis整合集成实例 spring与ibatis整合集成实例
spring ibatis 配置spring ibatis 配置spring ibatis 配置spring ibatis 配置
Spring对IBatis的整合 10.3 Spring对IBatis的支持 Spring对IBatis提供了完善的内建支持。使用Spring提供的IBatis辅助类,可以大大简化原有的IBatis访问代码。这些辅助类位于org.springframework.orm.ibatis包下,...
iBatis和Spring整合 iBatis和Spring整合
maven 整合spring springmvc ibatis
Spring iBatis WebWork 整合
ibatis与spring 框架整合
spring整合ibatis的详细配置步骤
spring_ibatis整合案例
亲手做的一个spring ibatis整合,刚刚接触ibatis,二话不说,ibatis环境先搭建好。
Struts2 Spring iBATIS 架构 实现 Struts2 Spring iBATIS 架构 实现 Struts2 Spring iBATIS 架构 实现 Struts2 Spring iBATIS 架构 实现
Spring与iBATIS的集成 iBATIS似乎已远离众说纷纭的OR框架之列,通常人们对非常流行的Hibernate情有独钟。但正如Spring A Developer's Notebook作者Bruce Tate 和Justin Gehtland所说的那样,与其他的OR框架相比...
springMVC spring ibatis整合jar
spring3.2与Ibatis整合,在servlet中获取bean
里面有spring+struts2+ibatis整合的jar包,