feezh

我们之所以努力赚钱,是为了让父母为自己买东西时能像给我们买东西时一样大方!
随笔 - 7, 文章 - 0, 评论 - 10, 引用 - 0
数据加载中……

2012年10月12日

eclipse 汉化方法

突然想汉化eclips试试,发现这篇文章,
http://blog.csdn.net/gqqnb/article/details/6412364
,才知道eclipse有语言包,汗。。。
按照文章所说,在
http://www.eclipse.org/babel/downloads.php页面发现

点Eclipse help菜单---> software update

 选Available Software选项卡,点击add site 新建新的地址资源,在地址里面填 相应版本地址安装即可。

posted @ 2012-10-12 14:48 feezh 阅读(720) | 评论 (1)编辑 收藏

2012年7月19日

Servlet简单封装

     摘要: 封装类Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->package com.weidu.servlet;import java.io.IOException;import javax.servlet.ServletException;import j...  阅读全文

posted @ 2012-07-19 09:10 feezh 阅读(2081) | 评论 (1)编辑 收藏

2012年6月12日

[java经典算法题]有n个人围成一圈,顺序排号。从第一个人开始报数(从1到3报数),凡报到3的人退出圈子,问最后留下的是原来第几号的那位?

题目:有n个人围成一圈,顺序排号。从第一个人开始报数(从1到3报数),凡报到3的人退出圈子,问最后留下的是原来第几号的那位?
 1package com.weidu.algorithms;
 2
 3import java.util.Arrays;
 4import java.util.Scanner;
 5
 6/**
 7 * @Title:
 8 * @Description:
 9 * @author Afei
10 * @date: 日期:2012-6-10 时间:下午05:41:04
11 * @Copyright:西北师范大学纬度工作室 Copyright (c) 2012
12 * @version:1.0
13 */

14public class Qu3 {
15
16    /**
17     * 功能说明:1、 有n个人围成一圈,顺序排号。从第一个人开始报数(从1到3报数),凡报到3的人退出圈子,<br>
18     * 问最后留下的是原来第几号的那位。
19     * 
20     * @Afei 2012-6-10
21     * @param args
22     */

23
24    public static void main(String[] args) {
25        // TODO Auto-generated method stub
26        Scanner input = new Scanner(System.in);
27        System.out.print("请输入总人数:");
28        int p = input.nextInt();
29        /**** 初始化人员 ***/
30        boolean[] per = new boolean[p];// boolean数组表示站成一圈的人,false表示退出
31        for (int i = 0; i < per.length; i++{
32            per[i] = true;
33        }

34
35        /**** 报号 ***/
36        int t = 0, len = per.length;
37        while (len > 1{
38            for (int i = 0; i < per.length; i++{
39
40                if (per[i]) {
41                    t++;
42                    if (t == 3{
43                        t = 0;
44                        per[i] = false;
45                        len--;
46                    }

47                }

48            }

49        }

50        /***** 结果 *****/
51        System.out.println("最后的情况:" + Arrays.toString(per));
52        for (int i = 0; i < per.length; i++{
53            if (per[i]) {
54                System.out.println("原来喊的数:" + (i + 1% 3);
55            }

56        }

57    }

58}

59


posted @ 2012-06-12 00:08 feezh 阅读(30728) | 评论 (7)编辑 收藏

2012年5月29日

Java树形数据(或者说级联)分类

- 这几天做东西时遇到一个树形数据(或者说级联,不会描述了,就这么叫吧)分类的问题,开始有点纠结,后想到了一种方法实现,先分享出来,高手勿喷。

正文开始
现有三个类:分别是Chapter.java Section.java KnowledgePoint.java
Chapter.java
private Set sections = new HashSet(0);
public Set getSections() {
        
return this.sections;
    }


public void setSections(Set sections) {
        
this.sections = sections;
    }

Section.java
private Chapter chapter;
private Set knowledgePoints = new HashSet(0);
public Chapter getChapter() {
       
return this.chapter;
    }


public void setChapter(Chapter chapter) {
       
this.chapter = chapter;
    }

public Set getKnowledgePoints() {
       
return this.knowledgePoints;
    }


public void setKnowledgePoints(Set knowledgePoints) {
       
this.knowledgePoints = knowledgePoints;
    }


KnowledgePoint.java
private Section section;
public Section getSection() {
       
return this.section;
    }


public void setSection(Section section) {
       
this.section = section;
    }


可以看出 章节 有多个小节,小节有多个知识点。当取得知识点后怎么根据不同的章节和小节分类呢?

List<KnowledgePoint> kps = this.allService.getKnowledgePointService()
                .findPoints(kpIds);
//取得所选择的知识点
            /********** 根据小节分类知识点 **********/            Map<Integer, Section> map = new HashMap<Integer, Section>();
       
for (int i = 0; i < kps.size(); i++) {
            Section section
= kps.get(i).getSection();
            Integer key
= section.getId();
           
if (!map.containsKey(key)) {
                section.getKnowledgePoints().clear();
                map.put(key, section);
            }

            map.get(key).getKnowledgePoints().add(kps.get(i));
        }

       
/********** 根据章节分类小节 **********/
            Map
<Integer, Chapter> cpMap = new HashMap<Integer, Chapter>();
        Iterator
<Section> it = map.values().iterator();
       
while (it.hasNext()) {
            Section section
= it.next();
            Chapter chapter
= section.getChapter();
            Integer key
= chapter.getId();
           
if (!cpMap.containsKey(key)) {
                chapter.getSections().clear();
                cpMap.put(key, chapter);
            }

            cpMap.get(key).getSections().add(section);
        }



posted @ 2012-05-29 21:41 feezh 阅读(2586) | 评论 (1)编辑 收藏

远程备份数据库到本地

1.共享备份目录

(要共享的目录)右键——共享——特定用户
说明:在次选择的用户为下面建立通信时的用户名
 

2.建立通信

1master..xp_cmdshell   'net   use  \\计算机名\共享名   密码   /user:计算机名\用户名'

3.备份数据库

1DECLARE @PATH NVARCHAR(2000)
2SET @PATH ='\\计算机名\共享名\' +Convert(Nvarchar,getDate(),112)+'.bak'
3backup database 数据库名 to disk=@PATH '

4.删除通信

 

1master..xp_cmdshell   'net  use  \\计算机名\共享名  /delete '

实现自动备份
SQL SERVER代理——作业——新建作业
第一步:常规:填写作业名称

第二步:步骤:填写步骤名称,选择类型为t-sql,填写sql命令。按前面步骤分开填写步骤。
注意:最后一步: 修改成功时要执行的操作:
第三步:计划——新建,根据需要设置。
第四五六。。根据需要设置。

posted @ 2012-05-29 21:00 feezh 阅读(1675) | 评论 (0)编辑 收藏

2012年5月28日

【转】org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): ***(POJO类,及持久化类名)

错误篇1:
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): ***(POJO类,及持久化类名)

分析及解决:

你要操作的数据表中的id(即主键)的类型设置成了“自动增长类型”,而在你的

hibernate.cfg.xml中,id的生成方式是assigned,即
<id name="id" type="integer">
            <column name="id" />
            <generator class="assigned" />
</id>
这种搭配是矛盾的!

主键的assigned生成方式由程序自动生成表的主键,即在你的测试程序中要调用setId()方法,且必

须在调用save()前调用(或者说在调用save()前必须指定id,其实就是说,主键值不能为空!)。
把主键的生成方式改为native,它的特征是能够根据底层数据库自动选择主键生成方式。
转自:http://www.iteye.com/topic/201035

posted @ 2012-05-28 10:14 feezh 阅读(3465) | 评论 (0)编辑 收藏

解决 java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lan

原因:spring2与hibernate3有asm-2.2.3.jar的冲突


解决方法:删除asm-2.2.3.jar


完整异常信息:

org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in ServletContext
resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method
failed; nested exception is org.hibernate.HibernateException: Unable to
instantiate default tuplizer
[org.hibernate.tuple.entity.PojoEntityTuplizer]
Caused by:

org.hibernate.HibernateException: Unable to instantiate default tuplizer
[org.hibernate.tuple.entity.PojoEntityTuplizer]
at
org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
at
org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at
org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at
org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:323)
at
org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:433)
at
org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at
org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at
org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:231)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1313)
at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at
org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1203)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)
at
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)
at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by:
java.lang.reflect.InvocationTargetException
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
...
47 more
Caused by:java.lang.NoSuchMethodError:
org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V

at
net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)
at
net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:173)
at
net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at
net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at
net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at
net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at
net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at
net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at
net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at
org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
at
org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
at
org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:188)
at
org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:128)
at
org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:78)
...
52 more
2012-3-8 16:28:53 org.apache.catalina.core.StandardContext
listenerStart
严重: Exception sending context initialized event to listener
instance of class
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in ServletContext
resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method
failed; nested exception is org.hibernate.HibernateException: Unable to
instantiate default tuplizer
[org.hibernate.tuple.entity.PojoEntityTuplizer]
Caused by:
org.hibernate.HibernateException: Unable to instantiate default tuplizer
[org.hibernate.tuple.entity.PojoEntityTuplizer]
at
org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
at
org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at
org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at
org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:323)
at
org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:433)
at
org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at
org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at
org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:231)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1313)
at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at
org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1203)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)
at
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)
at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by:
java.lang.reflect.InvocationTargetException
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
...
47 more
Caused by:java.lang.NoSuchMethodError:
org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V

at
net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)
at
net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:173)
at
net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at
net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at
net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at
net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at
net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at
net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at
net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at
org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
at
org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
at
org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:188)
at
org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:128)
at
org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:78)
...
52 more


认真阅读错误信息,一般在最后都能找到答案的!

posted @ 2012-05-28 00:25 feezh 阅读(3499) | 评论 (0)编辑 收藏