作业帮 > 综合 > 作业

org.hibernate.exception.SQLGrammarException:could not execut

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/04/28 22:37:33
org.hibernate.exception.SQLGrammarException:could not execute query异常
代码如下:public class IndexAction extends Action {
.
.
String hql = " from UserInfo where username='" + username + "'";
Hibernate hn = new Hibernate();
UserInfo info = (UserInfo) hn.queryOne(hql);
.
.
}
public class Hibernate {
...
public Object queryOne(String hql) {
this.openSession();
Object obj = null;
try {
obj = (Object) session.createQuery(hql).setMaxResults(1).
uniqueResult();
} catch (Exception e) {
System.out.println("------在检索对象时抛出异常,内容如下:");
e.printStackTrace();
}
this.closeSession();
return obj;
}
...
}
执行try {
obj = (Object) session.createQuery(hql).setMaxResults(1).
uniqueResult();
} catch (Exception e) {
System.out.println("------在检索对象时抛出异常,内容如下:");
e.printStackTrace();
}
时总是捕捉到异常,然后就提示错误,
我是从mySql数据库改为orcle的 是不是连接的错误啊?
oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@localhost:1521:orcl
org.hibernate.dialect.OracleDialect
LIUGUOQI
liuguoqi
这是我的配置信息,
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
jkems
jdbc:oracle:thin:@192.168.5.245:1521:oracle
org.hibernate.dialect.Oracle9Dialect
MyOracle Conection
123456
oracle.jdbc.driver.OracleDrive