2011年4月14日
posted @ 2011-05-08 23:16 jack zhai 阅读(203) | 评论 (0) | 编辑 收藏
beans.xml
beans<?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"> <context:annotation-config /> <context:component-scan base-package="cc.rm" /> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>classpath:jdbc.properties</value> </property> </bean> <bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <!--DataSource --> <bean id="sf" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan"> <list> <value>cc.rm.vo</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sf"></property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sf" /> </bean> <aop:config> <aop:pointcut id="bussinessService" expression="execution(public * cc.rm.*.*(..))" /> <aop:advisor pointcut-ref="bussinessService" advice-ref="txAdvice" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> </beans>
jdbc.properties
propertiesjdbc.driverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://127.0.0.1:3306/ll jdbc.username=root jdbc.password=1244
在web.xml里加入
web.xml<context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/:beans.xml,</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
posted @ 2011-05-01 14:26 jack zhai 阅读(224) | 评论 (0) | 编辑 收藏
需要先安装ODBC,才可以使用ODBC连接方式连接数据库
下载地址:mysql-connector-odbc-5.1.8-win32.msi
1
2
3
4
5
posted @ 2011-04-29 13:13 jack zhai 阅读(424) | 评论 (0) | 编辑 收藏
posted @ 2011-04-29 08:09 jack zhai 阅读(326) | 评论 (0) | 编辑 收藏
<?xml version='1.0' encoding='gb2312'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!--显示执行的SQL语句--> <property name="show_sql">true</property> <!--连接字符串--> <property name="connection.url">jdbc:mysql://localhost:3306/Test</property> <!--连接数据库的用户名--> <property name="connection.username">sa</property> <!--数据库用户密码--> <property name="connection.password">sa</property> <!--数据库驱动--> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <!--JDBC连接池(使用内置的连接池)--> <property name="connection.pool_size">1</property> <!--设置Hibernate自动管理上下文的策略--> <property name="current_session_context_class">thread</property> <!--选择使用的方言--> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!--在启动时删除并重新创建数据库--> <property name="hbm2ddl.auto">create</property> <mapping resource="events/User.hbm.xml"/> <mapping resource="events/Student.hbm.xml"/> </session-factory> </hibernate-configuration>
posted @ 2011-04-28 18:25 jack zhai 阅读(289) | 评论 (0) | 编辑 收藏
interfacepackage List; public interface IList { boolean isEmpty(); int size(); void add(ZNode newNode); void insert(int index , ZNode newNode) throws Exception; void delete(int index) throws Exception ; void replace(int index,Object obj) throws Exception; ZNode getByIndx(int index) throws Exception; int getIndex(ZNode node) throws Exception; void display() throws Exception; }
implementpackage List; public class ZList implements IList { private ZNode head = null; public ZList(){ } @SuppressWarnings("null") @Override public void add(ZNode newNode) { // TODO Auto-generated method stub ZNode z = head ; if(!isEmpty()){ while(z.getNext()!=null){ z = z.getNext(); } z.setNext(newNode); }else{ head = newNode ; } } @Override public void insert(int index, ZNode newNode) throws Exception { // TODO Auto-generated method stub ZNode frontNode = getByIndx(index-1) ; ZNode afterNode = getByIndx(index); frontNode.setNext(newNode); newNode.setNext(afterNode); } @Override public void delete(int index) throws Exception { // TODO Auto-generated method stub ZNode frontNode = getByIndx(index-1) ; ZNode currentNode = getByIndx(index) ; ZNode afterNode = currentNode.getNext() ; frontNode.setNext(afterNode) ; currentNode = null ; } @Override public void replace(int index,Object obj) throws Exception { // TODO Auto-generated method stub ZNode current = getByIndx(index); current.setData(obj); } /** * index >= 0 */ @Override public ZNode getByIndx(int index) throws Exception { // TODO Auto-generated method stub if(isEmpty()) throw new Exception("The List is null!"); ZNode z = head ; while(index>0 ){ if(z==null) throw new Exception("the index is out of index"); z = z.getNext(); index--; } return z; } @Override public int getIndex(ZNode node) throws Exception { // TODO Auto-generated method stub if(isEmpty()) throw new Exception("The List is null!"); ZNode z = head ; int index = 0 ; do{ if(z.equals(node)) break; index ++ ; z = z.getNext(); }while(z!=null); return index; } @Override public boolean isEmpty() { // TODO Auto-generated method stub return (null == this.head) ? true:false; } @Override public int size() { // TODO Auto-generated method stub ZNode z = head; int sz = 0; if(null != z) { do{ sz++; }while((z = z.getNext())!=null); } return sz; } @Override public void display() throws Exception { // TODO Auto-generated method stub if(isEmpty()) throw new Exception("The List is null!"); ZNode z = head ; int index = 0 ; do{ System.out .println("index:" + index + " " + z.getData().toString()); index++ ; z = z.getNext() ; }while(z!= null) ; } }
nodepackage List; public class ZNode { private Object data ; private ZNode next ; public ZNode(Object data, ZNode next) { super(); this.data = data; this.next = next; } public ZNode() { this.data = null ; this.next = null ; } public Object getData() { return data; } public void setData(Object data) { this.data = data; } public ZNode getNext() { return next; } public void setNext(ZNode next) { this.next = next; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((data == null) ? 0 : data.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ZNode other = (ZNode) obj; if (data == null) { if (other.data != null) return false; } else if (!data.equals(other.data)) return false; return true; } @Override public String toString() { // TODO Auto-generated method stub return "data are : " + data.toString() ; } }
posted @ 2011-04-26 05:57 jack zhai 阅读(259) | 评论 (0) | 编辑 收藏
一、web.xml中的配置
二、可选配置tools.xml
posted @ 2011-04-14 08:45 jack zhai 阅读(2596) | 评论 (0) | 编辑 收藏
Powered by: BlogJava Copyright © jack zhai