org.hibernate.exception.SQLGrammarException:could not execut
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/09/21 23:26:19
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
代码如下: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
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
org.hibernate.exception.SQLGrammarException:could not execut
org.hibernate.HibernateException: Could not find datasource
Exception in thread "main" org.hibernate.HibernateException:
org.hibernate.mappingException:Could not read mappings from
org.hibernate.HibernateException:createCriteria is not valid
org.hibernate.Session是什么
org.hibernate.hql.ast.QuerySyntaxException:3Q
javax.persistence.PersistenceException: org.hibernate.except
org.hibernate.hql.ast.QuerySyntaxException: expecting OPEN,
org.hibernate.hql.ast.QuerySyntaxException:, found '>' near
Could not read mappings from resource:com/sooyie/hibernate/o
Could not parse multipart servlet request; nested exception