Problems when data save on database by Hibernate

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-03-16T22:59:18Z Indexed on 2010/03/16 23:01 UTC
Read the original article Hit count: 312

Filed under:
|

Hi;

I'm trying do save data to database by help of Hibernate , in Java. But when i run codes , i had lot of problems. Can anyone help me about that? Thanks...

My code: package org.ultimania.model;

import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration;

public class Test {

public static void main(String[] args) { Session session = null; SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session = sessionFactory.openSession(); Transaction transaction = session.getTransaction();

BusinessCard card = new BusinessCard(); card.setId(1); card.setName("Özgür"); card.setDescription("Aciklama");

try{ transaction.begin(); session.save(card); transaction.commit();

} catch(Exception e){ e.printStackTrace(); } finally{ session.close(); }

}

}

Problems : SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255) at org.hibernate.cfg.Configuration.(Configuration.java:152) at org.ultimania.model.Test.main(Test.java:14) Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 8 more

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate