Guest User

Untitled

a guest
Aug 30th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.34 KB | None | 0 0
  1. i can't insert to database
  2. 16 mai 2011 17:21:39 net.sf.hibernate.cfg.Environment <clinit>
  3. INFO: Hibernate 2.1.6
  4. 16 mai 2011 17:21:39 net.sf.hibernate.cfg.Environment <clinit>
  5. INFO: hibernate.properties not found
  6. 16 mai 2011 17:21:39 net.sf.hibernate.cfg.Environment <clinit>
  7. INFO: using CGLIB reflection optimizer
  8. 16 mai 2011 17:21:39 net.sf.hibernate.cfg.Configuration configure
  9. INFO: configuring from resource: /hibernate/hibernate.cfg.xml
  10. 16 mai 2011 17:21:39 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
  11. INFO: Configuration resource: /hibernate/hibernate.cfg.xml
  12. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration addResource
  13. INFO: Mapping resource: hibernate/Timesheet.hbm.xml
  14. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Binder bindRootClass
  15. INFO: Mapping class: hibernate.Timesheet -> timesheet
  16. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration doConfigure
  17. INFO: Configured SessionFactory: null
  18. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration secondPassCompile
  19. INFO: processing one-to-many association mappings
  20. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration secondPassCompile
  21. INFO: processing one-to-one association property references
  22. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration secondPassCompile
  23. INFO: processing foreign key constraints
  24. 16 mai 2011 17:21:40 net.sf.hibernate.dialect.Dialect <init>
  25. INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect
  26. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
  27. INFO: Maximim outer join fetch depth: 2
  28. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
  29. INFO: Use outer join fetching: true
  30. 16 mai 2011 17:21:40 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
  31. INFO: Using Hibernate built-in connection pool (not for production use!)
  32. 16 mai 2011 17:21:40 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
  33. INFO: Hibernate connection pool size: 20
  34. 16 mai 2011 17:21:40 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
  35. INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/timesheet
  36. 16 mai 2011 17:21:40 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
  37. INFO: connection properties: {user=root, password=manel}
  38. 16 mai 2011 17:21:40 net.sf.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
  39. INFO: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
  40. 16 mai 2011 17:21:40 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
  41. INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
  42. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
  43. INFO: Use scrollable result sets: true
  44. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
  45. INFO: Use JDBC3 getGeneratedKeys(): true
  46. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
  47. INFO: Optimize cache for minimal puts: false
  48. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
  49. INFO: Query language substitutions: {}
  50. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.SettingsFactory buildSettings
  51. INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
  52. 16 mai 2011 17:21:40 net.sf.hibernate.cfg.Configuration configureCaches
  53. INFO: instantiating and configuring caches
  54. 16 mai 2011 17:21:40 net.sf.hibernate.impl.SessionFactoryImpl <init>
  55. INFO: building session factory
  56. 16 mai 2011 17:21:40 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
  57. INFO: Not binding factory to JNDI, no JNDI name configured
  58.  
  59. <!-- local connection properties -->
  60. <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/timesheet</property>
  61. <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
  62. <property name="hibernate.connection.username">root</property>
  63. <property name="hibernate.connection.password">manel</property>
  64. <!-- property name="hibernate.connection.pool_size"></property -->
  65.  
  66. <!-- dialect for MySQL -->
  67. <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
  68.  
  69. <property name="hibernate.show_sql">false</property>
  70. <property name="hibernate.use_outer_join">true</property>
  71. <property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
  72.  
  73.  
  74. <mapping resource="hibernate/Timesheet.hbm.xml"/>
  75.  
  76. </session-factory>
  77.  
  78. try {
  79.  
  80. Timesheet time = new Timesheet();
  81. Session session = SessionHibernate.getSession();
  82.  
  83. time.setAction(action);
  84. time.setDate(date);
  85. time.setHeure(heure);
  86. time.setId(id);
  87. net.sf.hibernate.Transaction tx = session.beginTransaction();
  88. getSession().save(time);
  89. getSession().flush();
  90. tx.commit();
  91.  
  92.  
  93. } catch (HibernateException e) {
  94.  
  95. } finally {
  96. try {
  97. SessionHibernate.closeSession();
  98. } catch (HibernateException e1) {
  99. e1.printStackTrace();
  100. }
  101. }
  102.  
  103. private static String CONFIG_FILE_LOCATION = "/hibernate/hibernate.cfg.xml";
  104. private static final ThreadLocal threadLocal = new ThreadLocal();
  105. private static net.sf.hibernate.cfg.Configuration configuration = new Configuration();
  106. private static net.sf.hibernate.SessionFactory sessionFactory;
  107. private static String configFile = CONFIG_FILE_LOCATION;
  108.  
  109. public SessionHibernate() {
  110. }
  111.  
  112. @SuppressWarnings("unchecked")
  113. public static Session getSession() throws HibernateException {
  114. Session session = (Session) threadLocal.get();
  115.  
  116. if (session == null || !session.isOpen()) {
  117. if (sessionFactory == null) {
  118. rebuildSessionFactory();
  119. }
  120. session = (Session) ((sessionFactory != null) ? sessionFactory.openSession()
  121. : null);
  122. threadLocal.set(session);
  123. }
  124.  
  125. return session;
  126. }
  127.  
  128. /**
  129. * Rebuild hibernate session factory
  130. *
  131. */
  132. public static void rebuildSessionFactory() {
  133. try {
  134. configuration.configure(configFile);
  135. sessionFactory = configuration.buildSessionFactory();
  136. } catch (Exception e) {
  137. System.err
  138. .println("%%%% Error Creating SessionFactory %%%%");
  139. e.printStackTrace();
  140. }
  141. }
  142.  
  143. /**
  144. * Close the single hibernate session instance.
  145. *
  146. * @throws HibernateException
  147. * @throws net.sf.hibernate.HibernateException
  148. */
  149. @SuppressWarnings("unchecked")
  150. public static void closeSession() throws HibernateException, net.sf.hibernate.HibernateException {
  151. Session session = (Session) threadLocal.get();
  152. threadLocal.set(null);
  153.  
  154. if (session != null) {
  155. session.close();
  156. }
  157. }
  158.  
  159. /**
  160. * return session factory
  161. *
  162. */
  163. public static net.sf.hibernate.SessionFactory getSessionFactory() {
  164. return sessionFactory;
  165. }
  166.  
  167. /**
  168. * return session factory
  169. *
  170. * session factory will be rebuilded in the next call
  171. */
  172. public static void setConfigFile(String configFile) {
  173. SessionHibernate.configFile = configFile;
  174. sessionFactory = null;
  175. }
  176.  
  177. /**
  178. * return hibernate configuration
  179. *
  180. */
  181. public static Configuration getConfiguration() {
  182. return configuration;
  183. }
Add Comment
Please, Sign In to add comment