JAVA编程常见错误集锦(1)

项目中遇到的错误(c9bcf64c) 
sql错误

找不到列 
Unknown column 'fillMen' in 'field list'

2.列名在sql语句中写了2次 
Column 'fillMan' specified twice


3.下面2条 数据库插入对应的列都是int类型的 所插入的数据类型不符合要求时报错 
Data truncated for column 'gatheringMoney' at row 1

Data truncation: Out of range value adjusted for column 'amount' at row 1


4. 
Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause


5.修改一个表时无法取得同一个表的数据 
ERROR 1093 (HY000): You can't specify target table 'context' for update in FROM 
clause

6.主键 未自动增长 
ERROR 1062 :

7.int 类型字符过长 
com.mysql.jdbc.exceptions.MySQLDataException: '2.5026744582E10' in column '1' is outside valid range for the datatype INTEGER.


8.没找到错误 没影响数据读取 
java.sql.SQLException: Operation not allowed after ResultSet closed

9.类型错误 最常见的是数字类型错误 
Data truncated for column 'gatheringMoney' at row 1

10.换另一个项目时 数据库连接池没换 (未解) 
Name java: is not bound in this Context 
换了之后 似乎还是不行 
===== 
java:/comp/env/jdbc/ConnSqlSer 
前面多了一个'/' 
应为java:comp/env/jdbc/ConnSqlSer 
======= 
11.\(未解) 
java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in

12.executeQuery()方法改成execute()(未解) 
Can not issue data manipulation statements with executeQuery().

Can not issue data manipulation statements with executeQuery().

struts错误

Failed to obtain specified collection 下拉框没值 
警告: No FormBeanConfig found under 'yuanLiaoRuKuForm' 配置文件Form出错


Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope 
<html:text >标签外面没有嵌套<html:form >标签

No getter method for property: "outDate" of bean: "com.System.storage.form.YuanliaoPandianForm" 
在form里面没有定义 此字段的get方法


Cannot get a connection, pool error Timeout waiting for idle object 数据库错误

Operation not allowed after ResultSet closed 可能是结果集关闭了


//在Action里面调用的DAO类 没有进行重新实例化 
2008-5-12 20:02:09 org.apache.struts.action.RequestProcessor processException 
警告: Unhandled Exception thrown: class java.lang.NullPointerException 
2008-5-12 20:02:09 org.apache.catalina.core.StandardWrapperValve invoke 
严重: Servlet.service() for servlet action threw exception 
java.lang.NullPointerException 
at com.System.storage.action.FinishedAction.finishedCheckAdd(FinishedAction.java:151) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

//在C标签里从一个对象里取值时 , 所请求的是对象里没有的属性 
An error occurred while evaluating custom action attribute "value" with value "${rows.storageAmount}": Unable to find a value for "storageAmount" in object of class "com.System.storage.domain.Finished" using operator "." (null)


forward 转向 连接到了一个还没开始写的action里面 而那个action所对应的jsp页面还没改 
Resources cannot be null.

找不到下面这个action 
Cannot retrieve mapping for action /finished/finishedChuKuSearch 
Cannot retrieve mapping for action /purveyAdd 如果把jsp页面的action写错了 就这样报

/jspfinance/client/ShouKuanJiLu_Sel.jsp(172,0) The end tag "</html:form" is unbalanced

类型转换错误 一般是参数类型写错 在公共方法或者配置文件里面找 
com.System.finance.client.form.GatheringForm cannot be cast to com.System.finance.client.form.InvoiceForm

struts标签里面 写进了html标签内的属性 
/jspclient/KeHuDangAn_Ins.jsp(44,88) equal symbol expected 
/jspfinance/client/TuiHuanHuo_Ins.jsp(70,42) quote symbol expected 
/jspstorage/material/YuanLiaoChuKu_Ins.jsp(84,31) equal symbol expected 
org.apache.jasper.JasperException: /scDept/dingDanXinZeng.jsp(333,167) equal symbol expected


jsp页面上action写错了 
Cannot retrieve mapping for action /finished/finishedCheckAdd


配置文件出错 
The content of element type "action-mappings" must match "(action)*".


java常见错误以及可能原因集锦

2008-07-08 15:550、 需要标识符 
a) 不在函数内

1、 非法表达式开始 
b) 可能:丢失括号 .

2. no data found 
a) 可能:setInt(1,100)中,没有100这个值

3. 找不到符号 
a) 可能:没导入包

4. 指定了无效URL 
a) 可能:数据库名或IP错误,即连接出错

5. 类路径没有找到 
a) 可能: ClassNotFoundException: oracle.jdbc.driver.OracleDriver 
b) 原因: 一般是指包名写错,或者没有import包,或者没有在类路径中找到jar文件 
c) 解决: 没有加载Oracle驱动jar,在.bash_profile中把ojdbc14.jar加进来

6. 空指针异常 
a) 可能: 数据源错误 比如数据库名或IP错误

7. 不能执行查询 
a) 可能: 数据库中表的问题,比如列名不存在

8. invalid identity 
a) 可能: 列名出错

9. 若在数据库中创建了 两个sequence ,运行时出现异常可能是先后执行了多次select语句,导致与原有的序列号产生冲突

10. 表名或列名不存在 
a) 可能:表不存在或者没有插入数据到表中

11. 不支持的类,类的版本错误 
a) 可能:没有导入jdk5.0,或者编译器仍为1.4

12. MappingNotFoundException 
a) Maybe: In the Eclipse Not refersh , or not exist in the dirctory

13. HibernateException: /hibernate.cfg.xml not found 
a) Maybe1: hibernate.cfg.xml not in the root directory 
b) Maybe2: Could not parse configuration . 
c) resolve: database not connect or use another database

14. ConstraintViolationException 
a) Maybe: used a not true database

15. 驱动没有找到 或者 JDBC Driver not found 
可能:连接数据库的驱动jar包不存在或者版本不一致,比如将旧的版本换成新的会造成该类错误 
16. 空指针异常 , java.lang.NullPointerException 
a) 可能1:数据库连接出错,比如在hibernate.cfg.xml中的数据错误会导致异常。

17. 数据插入异常 ,GenericJDBCException: could not insert 
a) 可能1:没有建立表或者表中没有任何数据 
b) 可能2:插入数据后没有执行提交语句:commit

18. LazyInitializationException 或者延迟加载异常 
a) 可能1:没有在查询语句中加fetch

19. IdentifierGenerationException 
a) 可能1:高位表没有初始化(比如hi_value中没有记录)

20. could not initialize a collection: [hibernate.entity.Role.modules#32768] Syntax error: Encountered "-" at line 1, column 132. 
a) 错误原因:><set name="modules" table="module-role" lazy="false">红色字部分中“-”为非法字符,替换为module_role

21. could not insert collection rows: [hibernate.entity.Module.roles#1] 
在Module.hbm.xml文件的如下配置中加入inverse=”true” 
<set name="roles" table="module_role" inverse="true">

22.在部署Struts时,出现如下错误信息: 
HTTP Status 404 - Servlet action is not available

type Status report 
message Servlet action is not available 
description The requested resource (Servlet action is not available) is not available. 
问题原因: 
1.、web.xml文件中未配置ActionServlet。 
2、struts-config.xml文件未配置你要访问的Action。 
3、你的jsp文件form标记中action属性的路径名称错误。 
4、非以上三种情况。 
针对以上4种情况相应的解决方案如下: 
1、在web.xml文件中加上ActionServlet的配置信息 
?????? /WEB-INF/struts-config.xml? 
?2、在struts-config.xml文件检查你要访问的Action配置文件。 
3、检查jsp文件form标记中action属性的路径名称是否与struts-config.xml文件中action标记的path属性的路径名称一致。 
4、非以上情况的解决办法就是检查web容器的log日志,如果时tomcat则检查下logs目录下的localhost_log文件,看里边是否记录有错误信息,然后根据错误信息提示将其纠正。

23.java.lang.NoClassDefFoundError: org/apache/commons/beanutils/Converter 
缺少spring-framework-2.0.3\lib\jakarta-commons\commons-beanutils.jar

24. 
ava 代码Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/Type 
缺少spring-framework-2.0.3\lib\asm\asm-2.2.2.jar包,版本不同,该包的名字有相应的区别

java 代码Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException 
缺少spring-framework-2.0.3\lib\dom4j\dom4j-1.6.1.jar包,版本不同,该包的名字有相应的区别 
把这个包进去就可以了:\Spring206\lib\dom4j、dom4j-1.6.1.jar

java 代码Caused by: java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap 
缺少spring-framework-2.0.3\lib\jakarta-commons\commons-collections.jar包,版本不同,该包的名字有相应的区别

java 代码Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter 
缺少spring-framework-2.0.3\lib\cglib\cglib-nodep-2.1_3.jar包,版本不同,该包的名字有相应的区别

java 代码Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor 
缺少hibernate-3.2\lib\asm.jar包,版本不同,该包的名字有相应的区别

java 代码 
org.hibernate.exception.SQLGrammarException: could not load an entity: [www.proudsoul.xml.User#1] 
JAVA工程与WEB工程包的区别:一个是asm.jar,一个是jta.jar

java 代码Caused by: java.lang.NoClassDefFoundError: javax/transaction/TransactionManager 
缺少spring-framework-2.0.3\lib\j2ee\jta.jar包,版本不同,该包的名字有相应的区别此种错误请检查相应的***.hbm.xml配置文件的配置

25, 
Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not get next sequence value; nested exception is org.hibernate.exception.SQLGrammarException: could not get next sequence value 
Caused by: org.hibernate.exception.SQLGrammarException: could not get next sequence value 
原因:没有加Sequence或者数据库的方言写错了

26, 
我的配置文件 
<id name="id" column="id"> 
<generator class="native" /> 
</id> 
然后我运行保存一条数据进去 
The database returned no natively generated identity value 
就会报这个错误 
因为你native是根据看底层数据库的能力选择identity, sequence 或者hilo中的一个 
而我建表的时候id没有指定 
alter table `student` change `id` `id` int auto_increment 
我们把我们的表的结构小小的改动一下就没问题了

27, 
UpdateManager无法启动2007-08-09 15:21如果在应用程序安装过程中,暴力中断安装程序,会出现如下状况:1.apt-get remove 和dpkg --remove 无法删除软件 2.UpdateManager无法启动3.新立得软件包管理程序无法启动 
以上可能是deb损坏之类造成的 
sudo dpkg -r sqldveloper 
正在读取软件包列表... 完成 
正在分析软件包的依赖关系树... 完成 
E: 软件包 sqldeveloper 需要重新安装,但是我无法找到相应的安装文件。 
解决方法:1.从 /var/lib/dpkg/status 中把对应的段删掉 
重要:修改之前请先备份 
在status中找到你对应的包删除就OK了...

28, 
Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ANTLRException 
少了antlr-2.7.5H3.jar包,从D:\eclipse\eclipse\plugins\com.genuitec.org.hibernate.eclipse_4.1.1\myeclipse-data\3.0\lib

29, 
Caused by: 
java.lang.NoClassDefFoundError: javax/transaction/Synchronization 
缺少Spring206\lib\j2ee\jta.jar

30, 
Caused by: 
java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [business.impl.PriceBiz] for property 'priceBiz': no matching editors or conversion strategy found 
在java类中设置priceBiz时应该设置的是接口PriceBizIf,而非实现类

31, 数组越界 
可能1: 在命令行后面需要加入参数. 
可能2:加入的参数错误

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值