I'm using swing with hibernate.
So when I enter button it connect but again I press the button it does repeating connectivity and that take few seconds to perform connectivity.
I do not use @annotations
SessionFactory sessionFactory = new
Configuration().configure().buildseseienFactery ();
public Registration Login(String username, String password) {
Session session = sessionFactory.openSession ();
Criteria criteria = session.createCriteria(Registration.cLass);
criteria.add(Restrictions.eq ("username", username));
criteria.add (Restrictions.eg ("password", password));
Registration registration (Registration) criteria.uniqueResult();
session.close();
return registration;
}
I supposed above block performing connectivity only once but when Login()
method call it does perform again.
So how can I perform connectivity only once?
Log is as following:
Sep 15, 2019 12:07:21 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
Sep 15, 2019 12:07:21 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.1.Final}
Sep 15, 2019 12:07:21 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Sep 15, 2019 12:07:21 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Sep 15, 2019 12:07:21 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Sep 15, 2019 12:07:21 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Sep 15, 2019 12:07:22 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/cpos/pojo/Registration.hbm.xml
Sep 15, 2019 12:07:22 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/cpos/pojo/Sales.hbm.xml
Sep 15, 2019 12:07:22 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/cpos/pojo/Items.hbm.xml
Sep 15, 2019 12:07:22 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/cpos/pojo/Customers.hbm.xml
Sep 15, 2019 12:07:22 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/cpos/pojo/Receivings.hbm.xml
Sep 15, 2019 12:07:22 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/cpos/pojo/Salestransaction.hbm.xml
Sep 15, 2019 12:07:22 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/cpos/pojo/Suppliers.hbm.xml
Sep 15, 2019 12:07:22 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/cpos/pojo/Rctransaction.hbm.xml
Sep 15, 2019 12:07:22 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Sep 15, 2019 12:07:22 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
INFO: HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/CPOS?zeroDateTimeBehavior=convertToNull
Sep 15, 2019 12:07:22 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
INFO: HHH000046: Connection properties: {user=root}
Sep 15, 2019 12:07:22 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
INFO: HHH000006: Autocommit mode: false
Sep 15, 2019 12:07:22 PM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
Sep 15, 2019 12:07:22 PM com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10]
Sep 15, 2019 12:07:22 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@5aa87035 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@27bcd446 [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> z8kfsxa5ebtiu21xhrse6|7a3dc7, idleConnectionTestPeriod -> 0, initialPoolSize -> 5, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@cfc29f4 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> z8kfsxa5ebtiu21xhrse6|1a8ed8f, jdbcUrl -> jdbc:mysql://localhost:3306/CPOS?zeroDateTimeBehavior=convertToNull, properties -> {user=******} ], preferredTestQuery -> null, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> z8kfsxa5ebtiu21xhrse6|12fe1cf, numHelperThreads -> 3 ]
Sep 15, 2019 12:07:23 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Sep 15, 2019 12:07:23 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
Sep 15, 2019 12:07:23 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Sep 15, 2019 12:07:23 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Is there any reason for delaying? How to get rid of it?