Looking for help with an intermittent error. Following extract is from the log file. Can't think what else to add but I will add more if needed.
13 Oct 2015 14:37:43,691 2746599 [pool-1-thread-1] INFO snbts.proteus.integrationengine.IntegrationThread - Processing batch: 16888445 on integration Queue 1
13 Oct 2015 14:37:46,831 2749739 [pool-1-thread-2] INFO snbts.proteus.integrationengine.IntegrationThread - Queue 2 is alive.
13 Oct 2015 14:37:52,706 2755614 [pool-1-thread-1] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 17401, SQLState: 99999
13 Oct 2015 14:37:52,706 2755614 [pool-1-thread-1] ERROR org.hibernate.util.JDBCExceptionReporter - Protocol violation: [6, 7, 0]
13 Oct 2015 14:37:52,706 2755614 [pool-1-thread-1] INFO org.hibernate.event.def.DefaultLoadEventListener - Error performing load command
org.hibernate.exception.GenericJDBCException: could not load an entity: [snbts.proteus.dataaccess.IntegrationQueue#2]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:82)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:820)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:62)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
at snbts.proteus.dataaccess.IntegrationQueue$$EnhancerByCGLIB$$14c8fbf7.setStatus(<generated>)
at snbts.proteus.integrationengine.IntegrationThread.setStatus(IntegrationThread.java:109)
at snbts.proteus.integrationengine.IntegrationThread.run(IntegrationThread.java:48)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: Protocol violation: [6, 7, 0]
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:464)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1044)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1199)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1289)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
... 24 more
13 Oct 2015 14:37:52,706 2755614 [pool-1-thread-1] ERROR snbts.proteus.integrationengine.IntegrationThread - Problem updating database: could not load an entity: [snbts.proteus.dataaccess.IntegrationQueue#2]
13 Oct 2015 14:37:54,752 2757660 [pool-1-thread-1] WARN com.mchange.v2.c3p0.impl.NewPooledConnection - [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
13 Oct 2015 14:37:54,752 2757660 [pool-1-thread-1] WARN com.mchange.v2.c3p0.impl.NewPooledConnection - [c3p0] Another error has occurred [ java.sql.SQLException: Protocol violation ] which will not be reported to listeners!
java.sql.SQLException: Protocol violation
at oracle.jdbc.driver.T4CTTIiov.unmarshalV10(T4CTTIiov.java:210)
at oracle.jdbc.driver.T4C8Oall.readIOV(T4C8Oall.java:592)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:325)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:884)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1167)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1289)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:82)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:820)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:62)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
at snbts.proteus.dataaccess.IntegrationQueue$$EnhancerByCGLIB$$14c8fbf7.toString(<generated>)
at java.util.Formatter$FormatSpecifier.printString(Unknown Source)
at java.util.Formatter$FormatSpecifier.print(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.lang.String.format(Unknown Source)
at snbts.proteus.integrationengine.queue.QueueItem.build(QueueItem.java:72)
at snbts.proteus.integrationengine.IntegrationThread.processIntegrationQueue(IntegrationThread.java:58)
at snbts.proteus.integrationengine.IntegrationThread.run(IntegrationThread.java:49)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Versions we are using:
Java 6
Hibernate 3.1.3
ojdbc6 11.2.0.4.0
Oracle 10g EE 10.2.0.5.0 64bit
Method attempting to load the entity:
private boolean setStatus(final String status) {
LOGGER.trace(String.format("Setting status to: %s on %s", status, integrationQueue.getDescription()));
boolean hasDbConnection = true;
try {
final Session session = CustomSessionFactory.getSessionFactory().getSession();
session.beginTransaction();
LOGGER.trace(CustomSessionFactory.TRANSACTION_BEGUN);
this.integrationQueue = (IntegrationQueue)session.load(IntegrationQueue.class, integrationQueue.getId());
integrationQueue.setStatus(status);
session.update(integrationQueue);
session.flush();
LOGGER.trace(String.format("Session Object Update: Integration Queue %d", integrationQueue.getId()));
session.getTransaction().commit();
LOGGER.trace(CustomSessionFactory.TRANSACTION_COMMITTED);
LOGGER.trace(String.format("Status set to: %s on %s", status, integrationQueue.getDescription()));
} catch (org.hibernate.exception.JDBCConnectionException e) {
LOGGER.error(String.format("Database Connection Problem: %s", e.getMessage()));
CustomSessionFactory.getSessionFactory().removeSession();
hasDbConnection = false;
} catch (GenericJDBCException e) {
LOGGER.error(String.format("Problem updating database: %s", e.getMessage()));
}
return hasDbConnection;
Entity:
public class IntegrationQueue implements Serializable {
public static final String STATUS_SHUTDOWN = "Shutdown";
public static final String STATUS_ACTIVE = "Active";
public static final String STATUS_IDLE = "Idle";
public static final String STATUS_ERROR_WC = "Error - Wrong Configuration";
private long id;
private String description;
private String status;
private IntegrationEngine integrationEngine;
public IntegrationQueue() {
}
public long getId() {
return id;
}
public void setId(final long id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(final String description) {
this.description = description;
}
public IntegrationEngine getIntegrationEngine() {
return integrationEngine;
}
public void setIntegrationEngine(final IntegrationEngine integrationEngine) {
this.integrationEngine = integrationEngine;
}
public String getStatus() {
return status;
}
public void setStatus(final String status) {
this.status = status;
}
public String toString(){
return String.format("Integration Queue: %d - %s", id, status);
}
}
HBM File:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="snbts.proteus.dataaccess.IntegrationQueue" table="INTEGRATIONQUEUE">
<id name="id" type="long" column="INTEGRATIONQUEUE_ID">
<generator class="assigned"/>
</id>
<property name="description" type="string" column="DESCRIPTION">
<meta attribute="field-description">
The description of the record.
</meta>
</property>
<property name="status" type="string" column="STATUS">
<meta attribute="field-description">
The status of the record.
</meta>
</property>
<many-to-one name="integrationEngine" class="snbts.proteus.dataaccess.IntegrationEngine"
column="INTEGRATIONENGINE_ID" not-null="true"/>
</class>
</hibernate-mapping>
Related
This question already has answers here:
MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES)
(43 answers)
java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
(1 answer)
Closed 5 years ago.
i am a beginner.when i use hibernate in eclipse,it shows :
ERROR: Access denied for user 'root '#'localhost' (using password:
YES) org.hibernate.exception.GenericJDBCException: Could not open
connection
i am a beginner.please help me,i don't konw what's wrong,and i counld not find a suitable answer throught the Internet or other answers on the stack overflow for my project.
Screenshot:
here is my code:
hibernate.properties:
hibernate.connection.driver_class = com.mysql.jdbc.Driver
hibernate.connection.url = jdbc:mysql://127.0.0.1:3306/db_test
hibernate.connection.username = root
hibernate.connection.password = root
hibernate.show_sql=true
hibernate.dialect = org.hibernate.dialect.MySQLDialect
hibernate.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- 映射文件 -->
<mapping resource="product/Product.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Product.java:
package product;
public class Product {
private int id;
private String name;
private Double price;
private String factory;
private String remark;
public int getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public String getFactory() {
return factory;
}
public void setFactory(String factory) {
this.factory = factory;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
Product.hbm.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="product.Product" table="product">
<id name="id" column="id" type="int">
<generator class="native"/>
</id>
<property name="name" type="string" length="16">
<column name="name"/>
</property>
<property name="price" type="double">
<column name="price"/>
</property>
<property name="factory" type="string" length="25">
<column name="factory"/>
</property>
<property name="remark" type="string" length="60">
<column name="remark"/>
</property>
</class>
</hibernate-mapping>
HibernateUtil.java:
package com.wgh.hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistryBuilder;
public class HibernateUtil {
private static final ThreadLocal<Session> threadLocal = new ThreadLocal <Session>();
private static SessionFactory sessionFactory = null; //SessionFactory对象
//静态块
static {
try {
Configuration cfg = new Configuration().configure(); //加载Hibernate配置文件
sessionFactory = cfg.buildSessionFactory(new ServiceRegistryBuilder().buildServiceRegistry());
} catch (Exception e) {
System.err.println("创建会话工厂失败");
e.printStackTrace();
}
}
/**
* 获取Session
* #return Session
* #throws HibernateException
*/
public static Session getSession() throws HibernateException {
Session session = (Session) threadLocal.get();
if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession(): null;
threadLocal.set(session);
}
return session;
}
/**
* 重建会话工厂
*/
public static void rebuildSessionFactory() {
try {
Configuration cfg = new Configuration().configure(); //加载Hibernate配置文件
sessionFactory = cfg.buildSessionFactory(new ServiceRegistryBuilder().buildServiceRegistry());
} catch (Exception e) {
System.err.println("创建会话工厂失败");
e.printStackTrace();
}
}
/**
* 获取SessionFactory对象
* #return SessionFactory对象
*/
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
/**
* 关闭Session
* #throws HibernateException
*/
public static void closeSession() throws HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(null);
if (session != null) {
session.close(); //关闭Session
}
}
}
servlet: QueryEmployee.java:
package servlet;
import java.io.IOException;
import product.*;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import com.wgh.hibernate.HibernateUtil;
/**
* Servlet implementation class QueryEmployee
*/
#WebServlet("/QueryEmployee")
public class QueryEmployee extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* #see HttpServlet#HttpServlet()
*/
public QueryEmployee() {
super();
// TODO Auto-generated constructor stub
}
/**
* #see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request,response);
}
/**
* #see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
#SuppressWarnings({ "unchecked" })
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
List<Product> product_list = new ArrayList<Product>();//实例化List信息集合
Session session = null;// 实例化session对象
try {
session = HibernateUtil.getSession();// 获得session对象
String hql = "from Product";// 查询HQL语句
Query q = session.createQuery(hql);// 执行查询操作
product_list = q.list();//将返回的对象转化为List集合
} catch (HibernateException e) {
e.printStackTrace();
} finally {
HibernateUtil.closeSession();// 关闭session
}
request.setAttribute("product_list", product_list);
RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/index.jsp");
rd.forward(request, response);
}
}
index.jsp:
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
table {
border-left:5px solid #ffffff;
border-collapse: collapse;
}
td {
font: normal 12px/ 17px Arial;
padding: 2px;
}
th {
font: bold 12px/ 17px Arial;
padding: 4px;
border-bottom: 1px solid #333;
}
body {
font-size: 14px;
}
#main{
width:500px;
border:solid 1px #000000;
}
</style>
</head>
<body>
<div id="main">
<table>
<tr>
<th width="30px">编号</th>
<th width="30px">书名</th>
<th width="30px" align="center">价格</th>
<th width="80px">生产商</th>
<th width="135px">备注</th>
</tr>
<c:forEach items="${product_list}" var="list">
<tr>
<td align="center">${list.id}</td>
<td>${list.name}</td>
<td>${list.price}</td>
<td>${list.factory}</td>
<td>${list.remark}</td>
</tr>
</c:forEach>
</table>
<form action="QueryEmployee" method="post">
<input type="submit" value="查看" >
</form>
</div>
</body>
</html>
here is the whole error message:
org.hibernate.exception.GenericJDBCException: Could not open connection
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.extractPhysicalConnection(ConnectionProxyHandler.java:82)
at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at com.sun.proxy.$Proxy8.prepareStatement(Unknown Source)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:147)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:166)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:145)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1711)
at org.hibernate.loader.Loader.doQuery(Loader.java:828)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
at org.hibernate.loader.Loader.doList(Loader.java:2438)
at org.hibernate.loader.Loader.doList(Loader.java:2424)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2254)
at org.hibernate.loader.Loader.list(Loader.java:2249)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1248)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at servlet.QueryEmployee.doPost(QueryEmployee.java:59)
at servlet.QueryEmployee.doGet(QueryEmployee.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1457)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: Access denied for user 'root '#'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:951)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1717)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1276)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2395)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2428)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2213)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:797)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:281)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
... 46 more
九月 16, 2017 9:24:26 上午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 1045, SQLState: 28000
九月 16, 2017 9:24:26 上午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Access denied for user 'root '#'localhost' (using password: YES)
org.hibernate.exception.GenericJDBCException: Could not open connection
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.extractPhysicalConnection(ConnectionProxyHandler.java:82)
at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at com.sun.proxy.$Proxy8.prepareStatement(Unknown Source)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:147)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:166)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:145)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1711)
at org.hibernate.loader.Loader.doQuery(Loader.java:828)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
at org.hibernate.loader.Loader.doList(Loader.java:2438)
at org.hibernate.loader.Loader.doList(Loader.java:2424)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2254)
at org.hibernate.loader.Loader.list(Loader.java:2249)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1248)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at servlet.QueryEmployee.doPost(QueryEmployee.java:59)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1457)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: Access denied for user 'root '#'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:951)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1717)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1276)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2395)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2428)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2213)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:797)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:281)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
... 45 more
九月 16, 2017 9:27:26 上午 org.apache.catalina.core.StandardContext reload
信息: Reloading Context with name [/my_hibernate] has started
九月 16, 2017 9:27:26 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
警告: The web application [my_hibernate] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
九月 16, 2017 9:27:27 上午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
九月 16, 2017 9:27:27 上午 org.apache.catalina.core.StandardContext reload
信息: Reloading Context with name [/my_hibernate] is completed
You don't have mysql server running or your mysql server does not have username=root or password=root, or you do not have access from the host that hibernate is running.
Check your mysql server's user accounts for 'root'.
I'm getting weird problem. I'm trying to do an integration testing but the Entity Manager creator is not working.
<? xml version = "1.0" encoding = "UTF-8"?>
<persistence xmlns = "http://java.sun.com/xml/ns/persistence"
xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi: schemaLocation = "http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version = "2.0">
<persistence-unit name = "db-test" transaction-type = "RESOURCE_LOCAL">
<provider> org.hibernate.jpa.HibernatePersistenceProvider </ provider>
<class> br.com.e2pd.model.Grupo </ class>
<properties>
<property name = "javax.persistence.jdbc.url" value = "jdbc: hsqldb: mem: db-test" />
<property name = "javax.persistence.jdbc.user" value = "sa" />
<property name = "javax.persistence.jdbc.password" value = "" />
<property name = "javax.persistence.schema-generation.database.action" value = "drop-and-create" />
<property name = "hibernate.show_sql" value = "true" />
<property name = "hibernate.hbm2ddl.auto" value = "update" />
</ properties>
</ persistence-unit>
</ persistence>
public class RepositoryTest {
protected static EntityManagerFactory factory;
protected static EntityManager em;
#BeforeClass
public static void setUpPersistence() {
factory = Persistence.createEntityManagerFactory("db-test");
em = factory.createEntityManager();
em.getTransaction().begin();
}
#AfterClass
public static void tearDown() {
em.getTransaction().commit();
em.close();
factory.close();
}
}
public class GrupoRepositoryTest extends RepositoryTest {
private GrupoRepository repository;
#Before
public void setUp() {
this.repository = new GrupoRepositoryImpl(em);
}
}
#Entity
#Table(name = "grupos")
public class Grupo implements Model{
#Id
#GeneratedValue
#Column(name = "id")
private Long id;
#Column(name = "nome")
private String nome;
public Grupo() {
}
public Grupo(Long id, String nome) {
this.id = id;
this.nome = nome;
}
//gets and sets
}
The log comes up here:
20: 53: 28.484 INFO [LogHelper] HHH000204: Processing PersistenceUnitInfo [
name: DB-test
...]
20: 53: 28.582 INFO [Version] HHH000412: Hibernate Core 5.0.2.Final {}
20: 53: 28.584 INFO [Environment] HHH000206: hibernate.properties not found
20: 53: 28.586 INFO [Environment] HHH000021: Bytecode provider name: Javassist
20: 53: 39.198 INFO [Version] HCANN000001: Hibernate Commons Annotations 5.0.0.Final {}
20: 55: 45.714 WARN [DriverManagerConnectionProviderImpl] HHH000402: Using Hibernate built-in connection pool (not for production use!)
20: 55: 45.732 INFO [DriverManagerConnectionProviderImpl] HHH000401: using driver [null] at URL [jdbc: hsqldb: mem: db-test]
20: 55: 45.733 INFO [DriverManagerConnectionProviderImpl] HHH000046: Connection properties: user = {s}
20: 55: 45.733 INFO [DriverManagerConnectionProviderImpl] HHH000006: Autocommit mode: false
20: 55: 45.740 INFO [DriverManagerConnectionProviderImpl] HHH000115: Hibernate connection pool size: 20 (min = 1)
STOPS HERE!
And gives the exception Caused by: java.sql.SQLException: No suitable driver found for jdbc: hsqldb: mem: db-test.
To solve this exception I did it in the setUpPersistence() ( even not knowing if it is the best solution ):
try {
Class.forName ("org.hsqldb.jdbcDriver");
connection = DriverManager.getConnection ("jdbc: hsqldb: mem: db-test", "sa", "");
} Catch (Exception ex) {
ex.printStackTrace ();
}
Thereafter when road testing gives the error:
java.lang.NoSuchMethodError: javax.persistence.Table.indexes () [Ljavax / persistence / Index;
at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:1080)
at org.hibernate.cfg.AnnotationBinder.bindClass (AnnotationBinder.java:765)
at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:245)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:222)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:265)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:770)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:797)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
at javax.persistence.Persistence.createEntityManagerFactory (Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory (Persistence.java:47)
at unit.br.com.e2pd.common.RepositoryTest.setUpPersistence (RepositoryTest.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
at java.lang.reflect.Method.invoke (Unknown Source)
org.junit.runners.model.FrameworkMethod at $ 1.runReflectiveCall (FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run (ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively (FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate (RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate (RunAfters.java:27)
at org.junit.runners.ParentRunner.run (ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run (TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java:192)
java.lang.NullPointerException
at unit.br.com.e2pd.common.RepositoryTest.tearDown (RepositoryTest.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
at java.lang.reflect.Method.invoke (Unknown Source)
org.junit.runners.model.FrameworkMethod at $ 1.runReflectiveCall (FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run (ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively (FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunAfters.evaluate (RunAfters.java:33)
at org.junit.runners.ParentRunner.run (ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run (TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java:192)
Maybe this one is related to JPA version, see this question NoSuchMethodError in javax.persistence.Table.indexes()[Ljavax/persistence/Index
Hope helps
I'am learning to use java since few weeks et i want to use Hibernate in simple Java console application.
I download the last version of Hibernate ORM (4.3.8)
I add this Jars in my ClassPath :
com.mysql.jdbc_5.1.5.jar
sqlite-jdbc-3.8.7.jar
Hibernate Library\antlr-2.7.7.jar
Hibernate Library\dom4j-1.6.1.jar
Hibernate Library\hibernate-commons-annotations-4.0.5.Final.jar
Hibernate Library\hibernate-core-4.3.8.Final.jar
Hibernate Library\hibernate-jpa-2.1-api-1.0.0.Final.jar
Hibernate Library\jandex-1.1.0.Final.jar
Hibernate Library\javassist-3.18.1-GA.jar
Hibernate Library\jboss-logging-3.1.3.GA.jar
Hibernate Library\jboss-logging-annotations-1.2.0.Beta1.jar
Hibernate Library\jboss-transaction-api_1.2_spec-1.0.0.Final.jar
My Class :
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name = "STUDENT_INFORMATIONS")
public class Student_Info {
#Id
private int rollNo;
private String name;
public int getRollNo() {
return rollNo;
}
public void setRollNo(int rollNo) {
this.rollNo = rollNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
My Main Code :
Student_Info student = new Student_Info();
student.setName("Fabien");
student.setRollNo(1);
SessionFactory sessionFactory;
ServiceRegistry serviceRegistry;
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
configuration.getProperties()).build();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
Session session = sessionFactory.openSession();
session.beginTransaction();
session.save(student);
session.getTransaction().commit();
session.close();
sessionFactory.close();
SQLite
First i create an hibernate.cfg.xml configuration for SQLite with dialect property to "util.SQLiteDialect"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="dialect">util.SQLiteDialect</property>
<property name="connection.driver_class">org.sqlite.JDBC</property>
<property name="connection.url">jdbc:sqlite:SQLiteJDBC.sqlite</property>
<property name="connection.username"></property>
<property name="connection.password"></property>
<!-- create / update -->
<property name="hibernate.hbm2ddl.auto">create</property>
<!-- Liste des classes à Mapper en base de données -->
<!-- <mapping resource="User.hbm.xml"/> -->
<mapping class="com.hibernate.Student_Info"/>
</session-factory>
</hibernate-configuration>
When i run my main program i have this error :
...
INFO: HHH000006: Autocommit mode: false
janv. 10, 2015 4:23:40 PM org.hibernate.engine.jdbc.connections.internal.DriverM
anagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
Exception in thread "main" org.hibernate.boot.registry.selector.spi.StrategySele
ctionException: Unable to resolve name [util.SQLiteDialect] as strategy [org.hib
ernate.dialect.Dialect]
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStr
ategyImplementor(StrategySelectorImpl.java:128)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveDe
faultableStrategy(StrategySelectorImpl.java:155)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveSt
rategy(StrategySelectorImpl.java:136)
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.constructDiale
ct(DialectFactoryImpl.java:78)
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(D
ialectFactoryImpl.java:68)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesIm
pl.java:165)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureSe
rvice(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService
(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(Abstra
ctServiceRegistryImpl.java:206)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:18
87)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
at com.hibernate.Main.main(Main.java:26)
MySql
After i tried with a mysql Database
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hierbnate</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<!-- JDBC Connection pool -->
<property name="connection.pool_size">1</property>
<!-- SQL Dialect -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_cass">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- create / update -->
<property name="hibernate.hbm2ddl.auto">create</property>
<!-- Liste des classes à Mapper en base de données -->
<!-- <mapping resource="User.hbm.xml"/> -->
<mapping class="com.hibernate.Student_Info"/>
</session-factory>
</hibernate-configuration>
When i run my main programm i have this error :
...
janv. 10, 2015 4:41:43 PM org.hibernate.engine.jdbc.connections.internal.DriverM
anagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://local
host:3306/hierbnate]
janv. 10, 2015 4:41:43 PM org.hibernate.engine.jdbc.connections.internal.DriverM
anagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {user=root, password=****}
janv. 10, 2015 4:41:43 PM org.hibernate.engine.jdbc.connections.internal.DriverM
anagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
janv. 10, 2015 4:41:43 PM org.hibernate.engine.jdbc.connections.internal.DriverM
anagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
Exception in thread "main" org.hibernate.exception.SQLGrammarException: Error ca
lling Driver#connect
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLState
ConversionDelegate.java:123)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.co
nvert(BasicConnectionCreator.java:118)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.conver
tSqlException(BasicConnectionCreator.java:140)
at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeC
onnection(DriverConnectionCreator.java:58)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.create
Connection(BasicConnectionCreator.java:75)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProvid
erImpl.configure(DriverManagerConnectionProviderImpl.java:106)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureSe
rvice(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService
(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(Abstra
ctServiceRegistryImpl.java:206)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAcces
s(JdbcServicesImpl.java:260)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesIm
pl.java:94)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureSe
rvice(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService
(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(Abstra
ctServiceRegistryImpl.java:206)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:18
87)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
at com.hibernate.Main.main(Main.java:25)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown da
tabase 'hierbnate'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1031)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:894)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3808)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1256)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2032)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:729)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:283)
at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeC
onnection(DriverConnectionCreator.java:55)
... 13 more
1 - Do you know if is it possible to use hibernate on SQLite ?
2 - If yes, do you know why it doesn't works ?
3 - For MySql, what is the problem ?
thank you very much !!
Thanks to Todd for my Syntaxe Error (MySql).
For SQLite, the dialect is not present in hibernate 4.3. So i found and adapt a classe for use SQLite with Hibernate 4.3.8 :
/*
* The author disclaims copyright to this source code. In place of
* a legal notice, here is a blessing:
*
* May you do good and not evil.
* May you find forgiveness for yourself and forgive others.
* May you share freely, never taking more than you give.
*
*/
package org.hibernate.dialect;
import java.sql.Types;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.type.IntegerType;
import org.hibernate.type.StringType;
import org.hibernate.Hibernate;
public class SQLiteDialect extends Dialect {
public SQLiteDialect() {
registerColumnType(Types.BIT, "integer");
registerColumnType(Types.TINYINT, "tinyint");
registerColumnType(Types.SMALLINT, "smallint");
registerColumnType(Types.INTEGER, "integer");
registerColumnType(Types.BIGINT, "bigint");
registerColumnType(Types.FLOAT, "float");
registerColumnType(Types.REAL, "real");
registerColumnType(Types.DOUBLE, "double");
registerColumnType(Types.NUMERIC, "numeric");
registerColumnType(Types.DECIMAL, "decimal");
registerColumnType(Types.CHAR, "char");
registerColumnType(Types.VARCHAR, "varchar");
registerColumnType(Types.LONGVARCHAR, "longvarchar");
registerColumnType(Types.DATE, "date");
registerColumnType(Types.TIME, "time");
registerColumnType(Types.TIMESTAMP, "timestamp");
registerColumnType(Types.BINARY, "blob");
registerColumnType(Types.VARBINARY, "blob");
registerColumnType(Types.LONGVARBINARY, "blob");
// registerColumnType(Types.NULL, "null");
registerColumnType(Types.BLOB, "blob");
registerColumnType(Types.CLOB, "clob");
registerColumnType(Types.BOOLEAN, "integer");
registerFunction( "concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", "") );
registerFunction( "mod", new SQLFunctionTemplate( IntegerType.INSTANCE, "?1 % ?2" ) );
registerFunction( "substr", new StandardSQLFunction("substr", StringType.INSTANCE) );
registerFunction( "substring", new StandardSQLFunction( "substr", StringType.INSTANCE ) );
}
public boolean supportsIdentityColumns() {
return true;
}
/*
public boolean supportsInsertSelectIdentity() {
return true; // As specify in NHibernate dialect
}
*/
public boolean hasDataTypeInIdentityColumn() {
return false; // As specify in NHibernate dialect
}
/*
public String appendIdentitySelectToInsert(String insertString) {
return new StringBuffer(insertString.length()+30). // As specify in NHibernate dialect
append(insertString).
append("; ").append(getIdentitySelectString()).
toString();
}
*/
public String getIdentityColumnString() {
// return "integer primary key autoincrement";
return "integer";
}
public String getIdentitySelectString() {
return "select last_insert_rowid()";
}
public boolean supportsLimit() {
return true;
}
protected String getLimitString(String query, boolean hasOffset) {
return new StringBuffer(query.length()+20).
append(query).
append(hasOffset ? " limit ? offset ?" : " limit ?").
toString();
}
public boolean supportsTemporaryTables() {
return true;
}
public String getCreateTemporaryTableString() {
return "create temporary table if not exists";
}
public boolean dropTemporaryTableAfterUse() {
return false;
}
public boolean supportsCurrentTimestampSelection() {
return true;
}
public boolean isCurrentTimestampSelectStringCallable() {
return false;
}
public String getCurrentTimestampSelectString() {
return "select current_timestamp";
}
public boolean supportsUnionAll() {
return true;
}
public boolean hasAlterTable() {
return false; // As specify in NHibernate dialect
}
public boolean dropConstraints() {
return false;
}
public String getAddColumnString() {
return "add column";
}
public String getForUpdateString() {
return "";
}
public boolean supportsOuterJoinForUpdate() {
return false;
}
public String getDropForeignKeyString() {
throw new UnsupportedOperationException("No drop foreign key syntax supported by SQLiteDialect");
}
public String getAddForeignKeyConstraintString(String constraintName,
String[] foreignKey, String referencedTable, String[] primaryKey,
boolean referencesPrimaryKey) {
throw new UnsupportedOperationException("No add foreign key syntax supported by SQLiteDialect");
}
public String getAddPrimaryKeyConstraintString(String constraintName) {
throw new UnsupportedOperationException("No add primary key syntax supported by SQLiteDialect");
}
public boolean supportsIfExistsBeforeTableName() {
return true;
}
public boolean supportsCascadeDelete() {
return false;
}
#Override
public boolean bindLimitParametersInReverseOrder() {
return true;
}
}
I think you might have just spelled "hibernate" wrong...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'hierbnate'
Try changing this:
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hierbnate</property>
To this:
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate</property>
(Unless your db is really called hierbnate, and then I'll just delete this answer).
My XML and Bean has perfect match for property "CostCenter" but still am having thiss issue .Please help to solve this.
Exception :
Sep 13, 2013 4:25:23 PM org.apache.commons.digester3.Digester endElement
SEVERE: End event threw exception
java.lang.NoSuchMethodException: Bean has no property named CostCenter
at org.apache.commons.digester3.BeanPropertySetterRule.end(BeanPropertySetterRule.java:206)
at org.apache.commons.digester3.Digester.endElement(Digester.java:1097)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.commons.digester3.Digester.parse(Digester.java:1588)
at org.apache.commons.digester3.Digester.parse(Digester.java:1557)
at ecnet.yes.po.digester.DigestPO.digest(DigestPO.java:80)
at ecnet.yes.po.digester.DigestPO.main(DigestPO.java:16)
Sep 13, 2013 4:25:23 PM org.apache.commons.digester3.Digester parse
SEVERE: An error occurred while parsing XML from 'file:/D:/workspace/Digester/src/ecnet/yes/po/digester/YES_PO.xml', see nested exceptions
DigestPO.java
Digester digester = new Digester();
//Push the current object onto the stack
digester.push(this);
digester.addSetProperties("ECnetPO");
//Creates a new instance of the YESBarePO class
digester.addObjectCreate("ECnetPO/Header", YESBarePO.class );
//Uses setName method of the YESBarePO instance
//Uses tag name as the property name
digester.addBeanPropertySetter("ECnetPO/Header/PONumber","PONumber");
digester.addBeanPropertySetter("ECnetPO/Header/CostCenter","CostCenter");
xml :
<ECnetPO>
<Header>
<PONumber>PONUMB0116</PONumber>
<CostCenter>Cost Center 20</CostCenter>
</Header>
<Header>
<PONumber>PONUMB0116</PONumber>
<CostCenter>Cost Center 20</CostCenter>
</Header>
</ECnetPO>
YESBarePO.java
private String PONumber;
private String CostCenter;
public String getPONumber()
{
return PONumber;
}
public void setPONumber(String pONumber)
{
PONumber = pONumber;
}
public String getCostCenter()
{
return CostCenter;
}
public void setCostCenter(String costCenter)
{
CostCenter = costCenter;
}
Just a guess, but does it make a difference if you rename the instance variable YESBarePO.CostCenter to be YESBarePO.costCenter instead? Unlike .NET, for instance, the standard Java idiom is to use lowerCamelCase for instance variables and my experience suggests that some bean mappers require this convention to be honoured in order to work.
My DAO layer code is as follows:
package com.app.dao;
import javax.annotation.Resource;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import com.app.pojo.InterviewerPojo;
#Repository("interviewer_details_dao")
public class InterviewerDetailsDaoImpl implements InterviewerDetailsDao {
#Resource(name="sessionFactory")
private SessionFactory factory;
/*private HibernateTemplate template;
public void setSessionFactory(){
template = new HibernateTemplate(factory);
}*/
/*private HibernateTemplate template = new HibernateTemplate(sessionFactory);*/
#Override
public void saveInterviewDetails(InterviewerPojo interviewerPojo) {
/* Session sess = factory.getCurrentSession();
try{
sess.getTransaction().wasCommitted();
Transaction trans = sess.beginTransaction();
System.out.println("a");
sess.saveOrUpdate(interviewerPojo);
sess.getTransaction().commit();}
catch(Exception e){
throw e;
}*/
System.out.println("b");
factory.getCurrentSession().save(interviewerPojo);
/* System.out.println(interviewerPojo);
template.saveOrUpdate(interviewerPojo);
System.out.println("b");*/
System.out.println("done");
}
}
the same code as above was running if i am getting the values from database as follows
sessionFactory.getCurrentSession().createQuery("select m from emp m).list;
But as I writing another page to insert values then it is having problem
*As you can see i used same concept, I populated MODEL(POJO) class by another MODEL(pojo) which i have taken from database by above query*
and now debugging goes upto "template.saveOrUpdate" and throws exception as follows
org.hibernate.exception.SQLGrammarException: You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'value for
hibernate_sequence' at line 1 at
org.hibernate.exception.internal.SQLStateConverter.convert(SQLStateConverter.java:100)
at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy24.executeQuery(Unknown Source) at
org.hibernate.id.SequenceGenerator.generateHolder(SequenceGenerator.java:112)
at
org.hibernate.id.SequenceHiLoGenerator$1.getNextValue(SequenceHiLoGenerator.java:85)
at
org.hibernate.id.enhanced.OptimizerFactory$LegacyHiLoAlgorithmOptimizer.generate(OptimizerFactory.java:350)
at
org.hibernate.id.SequenceHiLoGenerator.generate(SequenceHiLoGenerator.java:82)
at
org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:120)
at
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:204)
at
org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
at
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:189)
at
org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
at
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:642)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:635) at
org.hibernate.internal.SessionImpl.save(SessionImpl.java:631) at
com.app.dao.InterviewerDetailsDaoImpl.saveInterviewDetails(InterviewerDetailsDaoImpl.java:40)
at
com.app.service.SaveInterviewerDetailsServiceImpl.saveDetails(SaveInterviewerDetailsServiceImpl.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy19.saveDetails(Unknown Source) at
com.app.controllers.EmployeePromoteController.validateDetails(EmployeePromoteController.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source) Caused by:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'value for
hibernate_sequence' at line 1 at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source) at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source) at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) at
com.mysql.jdbc.Util.getInstance(Util.java:382) at
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593) at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525) at
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986) at
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140) at
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626) at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2111)
at
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2273)
at
org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at
org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
... 61 more
POJO source code:
package com.app.pojo;
import java.io.Serializable;
import javax.persistence.*;
#SuppressWarnings("serial")
#Entity #Table(name="interviewer")
public class InterviewerPojo implements Serializable {
private int eid;
private int vid;
#Id #GeneratedValue(strategy=GenerationType.SEQUENCE)
private int i_eid;
private String i_name;
private String password;
public int getEid() {
return eid;
}
public void setEid(int eid) {
this.eid = eid;
}
}
Hibernate config:
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.formatsql">true</prop>
<prop key="hibernate.showsql">true</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
</props>
</property>
In your error log, it showed that you're using MySQL. However, you configured Hibernate dialect was HSQLDialect.
org.hibernate.dialect.HSQLDialect
You should remove this dialect property, Hibernate can automatically detect the right dialect through JDBC driver. Or you modify to the correct dialect on your own.