异常处理

来源:互联网 发布:mybatis中sql拼装时间 编辑:程序博客网 时间:2024/06/05 21:06
1、 [状态:已解决] org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory
(Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
202.197.208.46:1521:hkdlzxt
错误原因:Oracle中的SID不对。改成相应的SID就行了。
解决方法:将hkdlzxt改成项目中的HKDYWK就正常了。
2、[状态:已解决]org.springframework.dao.DataIntegrityViolationException:Could not executeJDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
出现此错误的原因一般出现在数据库的设置上。
我出现了此错误的原因是因为数据库中不存在序列,所以报错。
3、 [状态:已解决] 使用Ext保存数据时,出现了以下错误:   org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException:    org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException:    org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException问题原因:不详...解决方法:  1、检查 package继承json-default。 action结果类型为json。  2、去掉Service或者DAO得get方法。 我使用第二种方法得以解决。4、[状态:已解决] svn: Aborting commit: 'D:\web\java\HKDLZXT\WebRoot\index.jsp' remains in conflict  出现此问题是因为多个用户对同一文件进行了修改并且提交到了服务器端,造成版本不一致而引起的。  要想提交成功,必须先更新版本,删除生成的三个临时文件,这样就可以成功提交。5、[状态:已解决] 使用Ext时,前台无法显示数据库中的记录。   在Action中,需要有root变量的getter方法。如果没有此方法,记录则无法显示,系统也不会报任何的错误。
6、[状态:已解决] Unable to instantiate Action, zcjfAction, defined for 'zcjfList' in namespace '/tbgl'Error creating bean with name 'zcjfAction': Injection of resource methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.hnjh.po.tbgl.Zcjf] is defined: Unsatisfied dependency of type [class com.hnjh.po.tbgl.Zcjf]: expected at least 1 matching bean
错误原因:在Action中我使用了new直接生成了一个对象,而后在get方法上,我又使用了@Resource注解,这样就造成了有两个Zcjf的实例。
解决办法:把new实例化的定义去掉即可。
7、 [状态:已解决] java.lang.NoSuchMethodException: com.hnjh.action.tbgl.ZcjfAction.findAll()   错误原因:在Action中没有定义findAll()方法。   解决方法:如果出现此错误,请检查Action本身实例化的对象名称是否存在。如果Action本身已经有正确的定义,那么还需要检查定义的方法,方法定义不能有任何的参数,只能是一个不带参数的方法。还需要检查方法定义的方法是公有方法还是私有的方法,如果是私有方法请更改成公有方法。   我出现此错误的原因是因为将方法定义成私有的,以致于外面的包不能访问此方法。
8、[状态:已解决] -20110425-15:59:54 Could not synchronize database state with sessionorg.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update  出现此错误的原因一般出现在数据库的设置上。
我出现了此错误的原因是因为数据库中不存在序列,所以报错。
9、[状态:已解决] ExtJS 给textfield赋值的方法总结

var value="值";

(1) fs.form.findField(id/name).setValue(value);

(2) Ext.get(id/name).setValue(value);

(3) Ext.getCmp(id).setValue(value);

获取form里面的field的三种方法

(1)Ext.getCmp('id');

(2)FormPanel.getForm().findField('id/name');

(3)Ext.get('id/name');//前提是FormPanel在界面上显示出来了

 

10、[状态:已解决] Ext中如何隐藏TextFiled的方法

Ext.get("sh").hide(true);

Ext.get("sh").setVisible(false);

 

11、[状态:已解决] java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0

在使用split将字符串拆成数组时出现这个错误。在Java中,如果字符串有特殊字符时,必须对这些特殊字符特殊对待。对待的方法就是在split中使用[]或者\\即可。形如:split("[+]"); +号是一个特殊符号,通过+号相连的字符串。

 

12、[状态:已解决] Java中应该注意的一些特殊字符

replace ,replaceAll 两者都是由正则表达式类库实现的,但是 replace 采用的是字符串原有的意思来替换,而 replaceAll 则是按照正则表达式的字符串来
替换,正则表达式中有 15 个元字符,是有特殊意义的,使用时需要转义,这 15 个字符分别是: ( [ { \ ^ - $ ** } ] ) ? * + . 转义时可以采用两种方式: 1、正则表达式中表述上述字符,需要在前面加上“\”,但是“\”是 Java 中的特殊字符,在 Java 代码中用“\\”表示正则表达式中的“\”。 2、在需要保留本身意义的前后加上 \Q 和 \E,把特殊字符放在这里面就成普通字符了。 PS:若想表示一个“\”,在 Java 代码中需要使用“\\\\” :)
5、[状态:已解决] Java通过Java.util.properties读取文件信息
Properties properties = new Properties();public void readProperties(String filename) throws IOException{
//FileInputStream fileInputStream = new FileInputStream(this.getClass().getClassLoader().getResource("/").getPath()+"/KqExportMapping.properties");//System.out.println(this.getClass().getClassLoader().getResource("/").getPath());
以上备注的可以读取到KqExportMapping.properties文件中的内容。只是在输出中文的时候,出现乱码。网上找过很多的方法,但是都是通过编码的转换去实现。不过我亲自实验过,没有成功。还有一种方法是使用工具,把中文汉字转成二进制流字符。
以下是另一种实现方法,可以正常读取到KqExportMapping.properties中的中文字符。
InputStreamReader inputStreamReader = new InputStreamReader(KqReadProperties.class.getClassLoader().getResourceAsStream(filename), "UTF-8");properties.load(inputStreamReader);}public String getProperties(String input) throws IOException{//System.out.println(new String(properties.getProperty(input).getBytes("ISO-8859-1"), "GB2312")); ====> 此处就是编码的转换。并没在成功。return properties.getProperty(input);}
13、[状态:已解决] java中如何获取路径(此路径是指的项目中的 web-inf/classes)方法一:
this.getClass().getClassLoader().getResource("/").getPath()+"/KqExportMapping.properties"
KqExportMapping.properties位于D:\web\java\HKDLZXT\WebRoot\WEB-INF\classes目录中。
方法二:
KqReadProperties.class.getClassLoader().getResourceAsStream( KqExportMapping.properties)
KqReadProperties表示类名。filename
原创粉丝点击