2024年4月12日发(作者:)

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

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

0、需要标识符

a) 不在函数内

1、非法表达式开始

b) 可能:丢失括号 .

2. no data found

a) 可能:setInt(1,100)中,没有100这个值

3. 找不到符号

a) 可能:没导入包

4. 指定了无效URL

a) 可能:数据库名或IP错误,即连接出错

5. 类路径没有找到

a) 可能: ClassNotFoundException:

Driver

b) 原因: 一般是指包名写错,或者没有import包,或者没有在类路

径中找到jar文件

c) 解决: 没有加载Oracle驱动jar,在.bash_profile中把

加进来

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: / not found

a) Maybe1: 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.

ption

a) 可能1:数据库连接出错,比如在中的数据

错误会导致异常。

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

Syntax

collection:

error: [s#32768]

Encountered "-" at line 1, column 132.

a) 错误原因:红色字部分中“-”为非法字符,替换为

空指针异常,

/doc/,interExce