首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

怎么解决:net.sf.hibernate.JDBCException: Could not execute query?

2014-01-26 
报出异常:net.sf.hibernate.JDBCException: Could not execute query连上数据库没有问题的请看代码:private

报出异常:net.sf.hibernate.JDBCException: Could not execute query

连上数据库没有问题的
  请看代码:
  private void test() throws HibernateException,QueryException{
  System.out.println("testing the hibernate.....");
  Session session = HibernateSessionFactory.currentSession();
  Transaction transaction = session.beginTransaction();
  Query query = session.createQuery("from jiveid");
  System.out.println("flag in action");
  for(Iterator iterator = query.iterate();iterator.hasNext();){
  System.out.println("flag in for statemant");
  Jiveid jiveid =(Jiveid)iterator.next();
  System.out.println("idtype is :" + jiveid.getIdtype());
  }
  // System.out.println("ifConnected: " + session.isConnected());
  // System.out.println("ifOpen :" + session.isOpen());
  // System.out.println("ifDirty :" + session.isDirty());
  // List l = session.find("FROM jiveid");
  // //List l = q.list();
  // for (int i=0; i< l.size(); i++) {
  // Long id = (Long) l.get(i);
  // System.out.println(id.longValue());
  // }
  transaction.commit();
  HibernateSessionFactory.closeSession();
  }

------解决方法--------------------------------------------------------
Query query = session.createQuery("from jiveid");
 
  改成
 
  Query query = session.createQuery("select jiveid from Jiveid as jiveid");试试!!

        

热点排行