I have tried to get any hibernate tutorial to work but have failed every time. So today i tried a mysql+hibernate tutorial. It was possible to download everything. So i did and i just changed the hibernate.cfg.xml mysql user and password and created the database and tables. Still i can`t get the program to work. I must be doing something wrong. It can't be so ridiculously hard. This is what i get.
15:12:45,057 INFO Environment:464 - Hibernate 3.0.5
15:12:45,061 INFO Environment:477 - hibernate.properties not found
15:12:45,063 INFO Environment:510 - using CGLIB reflection optimizer
15:12:45,065 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
15:12:45,131 INFO Configuration:1110 - configuring from resource: /hibernate.cfg.xml
15:12:45,132 INFO Configuration:1081 - Configuration resource: /hibernate.cfg.xml
15:12:45,280 INFO Configuration:444 - Mapping resource: de/laliluna/example/Honey.hbm.xml
15:12:45,407 INFO HbmBinder:260 - Mapping class: de.laliluna.example.Honey -> honey
15:12:45,419 INFO Configuration:1222 - Configured SessionFactory: null
15:12:45,421 DEBUG InitSessionFactory:113 - classic factory
15:12:45,422 INFO Configuration:875 - processing extends queue
15:12:45,422 INFO Configuration:879 - processing collection mappings
15:12:45,422 INFO Configuration:888 - processing association property references
15:12:45,422 INFO Configuration:917 - processing foreign key constraints
15:12:45,492 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
15:12:45,493 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
15:12:45,493 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
15:12:45,515 INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/firsthibernate
15:12:45,515 INFO DriverManagerConnectionProvider:86 - connection properties: {user=ivar, password=****}
15:12:45,838 WARN SettingsFactory:103 - Could not obtain connection metadata
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 1 ms ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2104)
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(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
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 java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
at de.laliluna.hibernate.InitSessionFactory.initSessionFactory(InitSessionFactory.java:114)
at de.laliluna.hibernate.InitSessionFactory.getInstance(InitSessionFactory.java:60)
at de.laliluna.example.TestExample.createHoney(TestExample.java:80)
at de.laliluna.example.TestExample.main(TestExample.java:33)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:209)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2027)
... 19 more
15:12:45,876 INFO Dialect:92 - Using dialect: org.hibernate.dialect.MySQLDialect
15:12:45,881 INFO TransactionFactoryFactory:34 - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
15:12:45,883 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
15:12:45,884 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
15:12:45,884 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
15:12:45,887 INFO SettingsFactory:144 - Scrollable result sets: disabled
15:12:45,888 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
15:12:45,888 INFO SettingsFactory:160 - Connection release mode: null
15:12:45,889 INFO SettingsFactory:184 - Maximum outer join fetch depth: 2
15:12:45,889 INFO SettingsFactory:187 - Default batch fetch size: 1
15:12:45,889 INFO SettingsFactory:191 - Generate SQL with comments: disabled
15:12:45,890 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
15:12:45,890 INFO SettingsFactory:334 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
15:12:45,892 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
15:12:45,892 INFO SettingsFactory:203 - Query language substitutions: {}
15:12:45,893 INFO SettingsFactory:209 - Second-level cache: enabled
15:12:45,893 INFO SettingsFactory:213 - Query cache: disabled
15:12:45,893 INFO SettingsFactory:321 - Cache provider: org.hibernate.cache.EhCacheProvider
15:12:45,895 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
15:12:45,895 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
15:12:45,960 INFO SettingsFactory:257 - Echoing all SQL to stdout
15:12:45,965 INFO SettingsFactory:261 - Statistics: disabled
15:12:45,965 INFO SettingsFactory:265 - Deleted entity synthetic identifier rollback: disabled
15:12:45,966 INFO SettingsFactory:279 - Default entity-mode: pojo
15:12:46,106 INFO SessionFactoryImpl:152 - building session factory
15:12:46,109 DEBUG CacheManager:191 - Creating new CacheManager with default config
15:12:46,112 DEBUG CacheManager:164 - Configuring ehcache from classpath.
15:12:46,114 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/home/ivar_m/workspace/FirstHibernateExample/lib/hibernate/ehcache-1.1.jar!/ehcache-failsafe.xml
15:12:46,120 DEBUG Configuration$DiskStore:185 - Disk Store Path: /tmp
15:12:46,394 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
15:12:46,395 INFO SessionFactoryImpl:379 - Checking 0 named queries
Exception in thread "main" org.hibernate.HibernateException: No TransactionManagerLookup specified
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:503)
at de.laliluna.example.TestExample.createHoney(TestExample.java:80)
at de.laliluna.example.TestExample.main(TestExample.java:33)
|