session.createQuery()不执行和java.lang.reflect.InvocationTargetException
今天写SSH的工程的时候,执行到一个DAO中的Query query = session.createQuery(hql)的时候,没有成功执行,直接跳到了finally,然后前台报了500和java.lang.reflect.InvocationTargetException的错误。
代码如下:
package dao; import java.util.List; import model.AccountInfo; import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction; import util.HibernateUtil; public class AccountDao {
public Boolean checkPassword(String account,String password){
Session session = HibernateUtil.getSession();
Transaction tran = null;
List<AccountInfo> list = null;
try{
tran = session.beginTransaction();
String hql="from AccountInfo as a where a.account=:username";
Query query = session.createQuery(hql);
query.setString("username",account);
list = query.list();
tran.commit();
}catch(HibernateException he){
tran.rollback();
he.printStackTrace();
}finally{
session.close();
}
if( list.size()==0 || !password.equals(list.get(0).getPassword()) )
return false;
else
return true;
}
}
然而实际上跟代码没有卵关系"( ̄▽ ̄)"""。是我用MyEclipse安装的hibernate4的lib的antlr-2.7.7.jar和struts2的lib的antlr-2.7.2.jar冲突了,删除后者即可。
session.createQuery()不执行和java.lang.reflect.InvocationTargetException的更多相关文章
- java.lang.reflect.InvocationTargetException at shade.com.datastax.spark.connector.google.common.base.Throwables.propagate(Throwables.java160)
org.apache.spark.SparkException: Job aborted due to stage failure: Task 1 in stage 29.1 failed 4 tim ...
- 错误: java.lang.reflect.InvocationTargetException
错误: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(N ...
- 关于java.lang.reflect.InvocationTargetException
今天遇到java.lang.reflect.InvocationTargetException错误,卡了好一会儿,报错代码 try { Class<?> c= Class.forName( ...
- json解析异常 - net.sf.json.JSONException: java.lang.reflect.InvocationTargetException
注:在项目中, 我使用原生的ajax请求数据的时候, JSONObject没能帮我解析, 当却不给我报错, 我是在junit单元测试中测试的时候, 发现的.发现好多时候, 特别是通过ajax请求, 不 ...
- mavne install 报错org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException
maven install 报错 org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.Invoc ...
- 在 Linux 环境下报错 java.lang.reflect.InvocationTargetException
今天开发了一个 excel 导出数据的功能,放到 linux 服务器上后发现报错. 捕获到 java.lang.reflect.InvocationTargetException 异常,这个异常不太常 ...
- 关于java.lang.reflect.InvocationTargetException(jar 包缺少或者冲突)的错误
我在合肥那边运行了的是湖北石首市的项目没有错 可是回武汉之后 运行这个项目 点击这里的时候 就报错java.lang.reflect.InvocationTargetException 不是数据库 ...
- java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException是什么情况?java.lang.reflect.InvocationTargetExceptionat sun.r ...
- HTTP Status 500 - java.lang.reflect.InvocationTargetException
type Exception report message java.lang.reflect.InvocationTargetException description The server enc ...
随机推荐
- Java学习笔记-File类的基本方法
要渐渐养成写博客的习惯-----> 前段时间看Mars的java中的I/O流没怎么懂,发现I/O流好难啊.今天重新看一遍其他教学,还有书籍,做些笔记,记录下每天的学习生活. File类的一些方法 ...
- oracle update语句的几点写法
update两表关联的写法包括字查询 1.update t2 set parentid=(select ownerid from t1 where t1.id=t2.id); 2. update tb ...
- su 切换用户
大部分Linux发行版的默认账户是普通账户,而更改系统文件或者执行某些命令,需要root身份才能进行,这就需要从当前用户切换到root用户,Linux中切换用户的命令是su或su - 前者只是切换ro ...
- windows如何获取Win10 Win8 Win8.1版本
GetVersionEx 在win8 win8.1 win10 之后已经无法使用,如果非要使用的话需要让exe嵌入manifest,mainfest如下.这个文件需要已utf-8存储. <?xm ...
- SQL Server中使用md5的方式
在SQl2005下自带的函数hashbytes() ,此函数是微软在SQL SERVER 2005中提供的,可以用来计算一个字符串的 MD5 和 SHA1 值,使用方法如下: --获取123456的M ...
- codeforces 659F . Polycarp and Hay 搜索
题目链接 遍历每个点, 如果这个点的值能被k整除并且k/a[i][j]后小于等于n*m, 那么就对这个点进行搜索. 将这个点加入队列, 将周围的所有大于等于这个点的值的点也加入队列. 不断重复, 直到 ...
- Built-in Functions学习
abs(x) :返回一个数字的绝对值,可以是整形也可以是浮点型. all(iterable):返回True,如果所以迭代对象的元素为true,或者可迭代对象为空. any(iterable):如果可迭 ...
- CSS自学笔记(4):CSS样式表的使用
当浏览器读到一个样式表时,浏览器会根据这个样式表来格式化html文档,从而表现出各式各样的网页. 想要浏览器读到样式表,有三种方法: 1.外部样式表 外部样式表可以理解为.CSS文件.当多个页面使用同 ...
- android 栈方式退出
介于list退出方式会使内存溢出,使用自己维护栈的方式. 参考: http://www.2cto.com/kf/201312/265523.html http://www.cnblogs.com/ma ...
- 供应类型与计划分类一致性检查(INV)
应用 Oracle Inventory 层 Level Function 函数名 Funcgtion Name CUXINVIMM 表单名 Form Name CUXINVIMM 说明 Descrip ...