Hi, everyone! hope you people are doing well.
I am new to hibernate. I am trying to simply save an object. I found everything correct. SessionFactory object and session object are created. But I am getting some strage exception as log shown bellow. Please somebody help me to fix this problem. ================================================================================== code:
user = new User(userName, fullName, password, emailAddress); try { SessionFactory factory = HibernateUtils.getSessionFactory(); System.out.println("session factory created : " + factory); Session session = factory.openSession(); System.out.println("session created : " + session); Transaction tx = session.beginTransaction(); System.out.println("Transaction created : " + tx); session.save(user); tx.commit(); session.close(); } catch (Exception e) { // TODO: handle exception System.out.println("Error occured in addUser method"); e.printStackTrace(); } ================================================================================== Thank You Regards Kuldeep Singh
session factory created : org.hibernate.impl.SessionFactoryImpl@16f361b session created : org.hibernate.impl.SessionImpl(PersistentContext[entitiesByKey={}] ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]]) Mar 30, 2013 10:23:43 PM org.hibernate.util.JDBCExceptionReporter logExceptions WARNING: SQL Error: 0, SQLState: 08S01 Mar 30, 2013 10:23:43 PM org.hibernate.util.JDBCExceptionReporter logExceptions SEVERE: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream
** BEGIN NESTED EXCEPTION **
java.io.IOException MESSAGE: Unexpected end of input stream
STACKTRACE:
java.io.IOException: Unexpected end of input stream at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:1096) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:626) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1562) at com.mysql.jdbc.Connection.<init>(Connection.java:491) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346) at java.sql.DriverManager.getConnection(DriverManager.java:579) at java.sql.DriverManager.getConnection(DriverManager.java:190) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110) at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:410) at org.hibernate.jdbc.JDBCContext.connect(JDBCContext.java:141) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:88) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:49) at org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19) at org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:204) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1014) at appUtils.UserUpdates.addUser(UserUpdates.java:60) at appUtils.UserUpdates.main(UserUpdates.java:43)
** END NESTED EXCEPTION **
Error occured in addUser method User with 0 is added to databaseorg.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92) at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:413) at org.hibernate.jdbc.JDBCContext.connect(JDBCContext.java:141) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:88) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:49) at org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19) at org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:204) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1014) at appUtils.UserUpdates.addUser(UserUpdates.java:60) at appUtils.UserUpdates.main(UserUpdates.java:43) Caused by: java.sql.SQLException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream
** BEGIN NESTED EXCEPTION **
java.io.IOException MESSAGE: Unexpected end of input stream
STACKTRACE:
java.io.IOException: Unexpected end of input stream at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:1096) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:626) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1562) at com.mysql.jdbc.Connection.<init>(Connection.java:491) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346) at java.sql.DriverManager.getConnection(DriverManager.java:579) at java.sql.DriverManager.getConnection(DriverManager.java:190) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110) at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:410) at org.hibernate.jdbc.JDBCContext.connect(JDBCContext.java:141) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:88) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:49) at org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19) at org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:204) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1014) at appUtils.UserUpdates.addUser(UserUpdates.java:60) at appUtils.UserUpdates.main(UserUpdates.java:43)
** END NESTED EXCEPTION **
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:699) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1562) at com.mysql.jdbc.Connection.<init>(Connection.java:491) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346) at java.sql.DriverManager.getConnection(DriverManager.java:579) at java.sql.DriverManager.getConnection(DriverManager.java:190) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110) at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:410) ... 8 more
|