Home Tutorialhelp Comment Problem in running sample Hibernate code

 
 

Comment

Sam
Problem in running sample Hibernate code,
November 27, 2009 at 3:15 PM

Im new to this hibernate.

When i try to run the FirstExample.java class im getting the followning error ::: Cannot open connection



I have change my hibernate.cfg.xml file as like this ::


<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@10.90.1.7:1521:DEVEL</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">lion</property>
<property name="hibernate.connection.pool_size">5</property>
<property name="show_sql">true</property>
<property name="dialect"> org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="roseindia.contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>


and i have the FirestExample.java code is:

Session session = null;
//Transaction trans =null;
try{
/** This step will read hibernate.cfg.xml and prepare hibernate for use**/

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session=sessionFactory.openSession();
Transaction tx=session.beginTransaction();

System.out.println("Inserting Record");
Contact contact=new Contact();

contact.setFirstName("Deepak");
contact.setLastName("kumar");
contact.setEmail("pra@yahoo.com");
contact.setId(3);
session.save(contact);
System.out.println("Done");
tx.commit();
}catch(Exception e){
System.out.println("Exception Occured::: " +e.getMessage());
//trans.rollback();
}finally{
/**Actual contact insertion will happen at this step**/

session.close();


}





plz suggest me how to run thhe hibernate code.


View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Hibernate Questions

hibernate firstExample not inserting data - Hibernate
hibernate firstExample not inserting data  hello all , i followed... in the firstExample as below. I will later post the actual code issue later. here i am... problem is data is not inserting into DB even though the program is executed 

Hibernate Questions

Problem in running first hibernate program.... - Hibernate
Problem in running first hibernate program....  Hi...I am using... programs.It worked fine.To run a hibernate sample program,I followed the tutorial below.../FirstExample Exception in thread "main" " http://www.roseindia.net/hibernate/runninge 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem  Hi, This is Birendra Pradhan.I want... in the DAO.Can it be possibe. Please send some sample code.. thanks & Regards Birendra  Hi friend, For solving the problem visit 

Hibernate Questions

hibernate firstexample - Hibernate
hibernate firstexample  Hi all. i m new with hibernate,when i m trying to run my first application i m getting following exception. Error reading resource: Employee.hbm.xml give me the solution. Thank you 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem  how to write hibernate Left outer join program 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem   Hi This is Raju I tried the first example of hibernate course material.This is to insert a record into CONTACT table.Is Hibernate code automatically creates the CONTACT table and then insert 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem  Hi This is Raju.I tried the first example of Hibernate material what u have given. I have written contact.java... problem please send me code. Visit for more information. http 

Hibernate Questions

hibernate code problem - Hibernate
hibernate code problem  suppose i want to fetch a row from the table... . Please visit for more information. http://www.roseindia.net/hibernate/selectclause.shtml If you have any problem this send me detail and source code 

Hibernate Interview Questions

Hibernate sample code - Hibernate Interview Questions
Hibernate sample code  Hi Can any body tell me how to persist inner class,abstract class,final class,and interface in hibernate. From... Hibernet.org.The Hibernate 3.0 core is 68,549 lines of Java code together with 27,948 lines 

Hibernate Questions

hibernate code problem - Hibernate
hibernate code problem  String SQL_QUERY =" from Insurance...: " + insurance. getInsuranceName()); } in the above code,the hibernate... thanks shakti  Hi friend, Your code is : String SQL_QUERY =" from 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem  Hai, iam working on simple login application using hibernate in spring. I've used Spring dependency injection too.I.... Please find my src code here... ----------------controller Layer 

Hibernate Questions

Hibernate - Hibernate
Hibernate  Hai this is jagadhish while running a Hibernate... for me to provide you the solution if problem is clear. please post all code...:11 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute INFO: Running hbm2ddl 

Hibernate Questions

hibernate problem
:12) i am getting this prob while running my hibernate program in Eclips please...hibernate problem  please help me.... log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code  firstExample code that you have given for hibernate to insert the record in contact table,that is not happening neither it is giving... inserted in the database from this file. http://www.roseindia.net/hibernate 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code   I am facing a problem in hibernate program. Error is ::: Error in reading contact.hbm.xml contact.hbm.xml is my hibernate mapping file.  Hi Friend, check whether you have specified correct path 

Hibernate-Tutorials

hibernate sample code
This section contains a simple Hibernate 4 example using Annotation with source code. The eclipse id and Apache Tomcat is used in this example 

Hibernate Questions

hibernate - Hibernate
hibernate  Hai,This is jagadhish I have a problem while developing insert application of Hibernate.The application is compiled,while running..., As per your problem exception is related to ant.Plz check the lib for Ant 

Hibernate Interview Questions

Hibernate Code - Hibernate Interview Questions
Hibernate Code  This is the question asked in CAPEGEMINI Write a sample code how to persist inner class,interface,final class and how to invoke stored procedure in hibernate? From Surjeet 

Hibernate Questions

Java Compilation error. Hibernate code problem. Struts first example - Hibernate
Java Compilation error. Hibernate code problem. Struts first example  Java Compilation error. Hibernate code problem. Struts first example 

Hibernate Questions

Java - Hibernate
(); } } } --------------------------- Simple problem in your code. please change the setId..., this type of output. ---------------------------- Inserting Record Done Hibernate... FirstExample { public static void main(String[] args) { Session session = null 

Hibernate-Tutorials

HQL Sample
HQL Sample In this site there are many tutorials and example of HQL. These examples comes with HQL sample code that you can download and run on your computer and learn the HQL by modifying and executing these examples. The HQL Sample 

Hibernate Questions

hibernate configuration with eclipse 3.1 - Hibernate
project.its not running. so i want to about the whole process. i have simple hibernate program code and with struts also. so please tell me the step...hibernate configuration with eclipse 3.1  Dear Sir, i got your mail 

Hibernate Questions

Hibernate @ManyToOne persisting problem - Hibernate
Hibernate @ManyToOne persisting problem  hello, In my apllication, there are students and classes. a student can take many classes. So... wrote the code (summary) below.. class Class: @Id @GeneratedValue @Column 

Hibernate Questions

Hibernate tutorial - Hibernate
Hibernate tutorial  can u provide me some material in hibernate.  Hello Rohin,You can learn Hibernate within 10 days from our website. In our hibernate tutorial you will find many examples with running code. You can 

Hibernate Questions

Problem with open connection - Hibernate
Problem with open connection  Hi Team, I am running one hibernate application and the database is ORACLE 10g.I am getting the below error.I connected to the database by using JDBC(with same driver and url).Please tell me 

Hibernate Questions

Hibernate error - Hibernate
Hibernate error  I hava following error while running hibernate.../tutorial/hibernate. But I have following error. log4j:WARN No appenders...(FirstExample.java:35) /hibernate.cfg.xml not found Please solve this problem 

Hibernate Questions

hibernate
hibernate   i am using hibernate3.2.5 and oracle9i. First i set classpath to ojdbc14.jar and all the hibernate jar files to path env variable.After... version " please give me the suggestion to sort out the problem 

Hibernate Questions

Hibernate delete a row error - Hibernate
simple problem in your code. Query query = sess.createQuery(hql); int row...Hibernate delete a row error  Hello, I been try with the hibernate delete example (http://www.roseindia.net/hibernate/hibernate-delete.shtml 

Hibernate Questions

Hibernate
of Hibernate. I followed all th steps as given in the tutorial, but a build error... hibernate library files are not included in the project build path. Please download the example from Hibernate Getting Started Tutorial. Please follow the steps 

Hibernate Questions

j2eee(Hibernate) - Hibernate
any problem. Please specify in detail and send me code. I am sending you...j2eee(Hibernate)  Hi, This is jagadhish.Iam learning Hibernate.I... relations in Hibernate(with examples).But not showing the link available 

Hibernate Questions

hibernate code - Hibernate
hibernate code  while generating the hibernate code i got the error like org.hibernate.MappingException 

Hibernate Questions

Hibernate Code - Hibernate
Hibernate Code   How to Invoke Stored Procedure in Hibernate???????? Plz provide details code 

Hibernate Questions

hibernate code - Hibernate
hibernate code  How to store a image in mysql or oracle db using struts &hibernate 

Hibernate Questions

hibernate insertion problem - Hibernate
hibernate insertion problem  Hi , Thanks for the material .Its very gud . when i run FirstExample.java i get the message insertion has been done int the table contact . but whne i look into database data is not inserted 

Hibernate Questions

HIBERNATE CODE - Hibernate
HIBERNATE CODE  Dear sir, I am working with MyEclipse IDE.I want to connect with MYSQL using Hibernate. What is the Driver Template and URL of MYSQL toconnect using Hibernate 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code  can you show the insert example of Hibernate other than session.save(obj);  Hi I am sending a link where u can find lots of example related to hibernate... http://www.roseindia.net/hibernate 

Java Beginners

Hibernate code
Hibernate code  programm 4 hibernate  Hi, Read hibernate tutorial at http://www.roseindia.net/hibernate/ Thanks   please read at the the link http://www.roseindia.net/hibernate 

Hibernate Questions

hibernate
hibernate  what is problem of tree loading 

Hibernate Questions

Struts Hibernate Spring - Login and User Registration - Hibernate
/hibernate-spring/index. shtml) but the problem is that Registration doesn't register... is running, caa you send me code and explain in detail. I am sending you a link. I hope...Struts Hibernate Spring - Login and User Registration  Hi All, I 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code   how to write hql query for retriveing data from multiple tables 

Hibernate Tutorial Example

Running First Hibernate 3.0 Example
Running First Hibernate 3.0 Example       Hibernate is free open source software it can... Hibernate 3.0. You can download the Hibernate and install it yourself. But I have 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code   example code of how insert data in the parent table and child tabel coloums at a time in hibernate  Hi friend, I am...: http://www.roseindia.net/hibernate/insert-data-database.shtml Thanks 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code   Hi How to intract struts , spring and Hibernet. Explain architecture flow.   Hi Friend, Please visit the following link: http://www.roseindia.net/struts/hibernate-spring/index.shtml Here 

Hibernate Tutorial Example

Hibernate Tutorials
This section describes you how to develop sample Hibernate Application... code to select the data from Insurance table using Hibernate Select Clause... Hibernate Tutorials       Deepak Kumar Deepak 

Hibernate Questions

Hibernate error in eclipse
Hibernate error in eclipse   Hi... while running my application i got... are trying to submit the null value. So, review your code again or send your full code........ I will try to short out your problem 

Hibernate Tutorial Example

Running First Hibernate 3.0 Example
Running First Hibernate 3.0 Example       Hibernate is free open source software it can... of database. After running the code example you may check your MySQL database 

Hibernate Questions

Hibernate - Hibernate
Hibernate  What is a lazy loading in hibernate?i want one example of source code?plz reply 

Hibernate Questions

hibernate code - Hibernate
hibernate code  sir, i have tried ur hibernate 3.0 firt example code, i have done as u have told in the tutorial like import all the related jar files,made asimple java project and copied the two xml files into src/bin 

Hibernate Interview Questions

Hibernate Code - Hibernate Interview Questions
Hibernate Code   Hi Friends, In Hibernate, wat is Annotation. There is no need of hibernate configuration file in hibernate version 3 - right . but hbm is necessary for all versions 

Hibernate Questions

hibernate - Hibernate
hibernate  what is hibernate and how to make a pc hibernating?  Hi friend, Hibernate is based on object oriented concept like java... .properties file and in hibernate we use .xml file ,which is a better approach. We 

Hibernate Questions

hibernate pojo setter method problem
hibernate pojo setter method problem  how to pass a date type variable to a setter method in hibernate pojo class? //this is my pojo class import... class code import org.hibernate.*; import org.hibernate.cfg.*; public class 

Development process Questions

spring hibernate
table through jsp using spring an hibernate....and the fields in the registration jsp are in different tables???can any one help or is there any sample code... the following link: http://www.roseindia.net/hibernate/HibernateSpring.shtml 

Development process Questions

spring hibernate
table through jsp using spring an hibernate....and the fields in the registration jsp are in different tables???can any one help or is there any sample code... the following link: http://www.roseindia.net/hibernate/HibernateSpring.shtml 

Hibernate Questions

hibernate code - Hibernate
hibernate code  well deepak,Regarding the inputs u asked for my fisr question, i have downloaded the complete project from the roseindia site...{ // This step will read hibernate.cfg.xml and prepare hibernate for use SessionFactory 

Hibernate Questions

Hibernate - Hibernate
Hibernate SessionFactory  Can anyone please give me an example of Hibernate SessionFactory?  Hi friend,package roseindia;import... { } }}--------------------------  This is mapping code,<?xml version=" 

Hibernate Questions

Hibernate - Hibernate
Hibernate  when I run Hibernate Code Generation wizard in eclipse I'm getting the following error. I added ojdbc14.jar to my build path. Still I'm.../hibernate/index.shtml Hope that it will be helpful for you. Thanks 

Hibernate Questions

Problem in updating query in Hibernate - Hibernate
Problem in updating query in Hibernate  Hi, I have used a query to update the existing columns of one table. The query updates the records..., Please visit the following link: http://www.roseindia.net/hibernate 

Hibernate Tutorial Example

Hibernate Mapping
 

Hibernate Tutorial Example

Hibernate Mapping
Hibernate Mapping In this Hibernate Mapping tutorials series you will learn Hibernate in depth. We will show everything on Hibernate Mappings with running code example. We have used easy to learn examples that will help you understand 

Hibernate Questions

Hibernate - Hibernate
Hibernate  Hai this is jagadhish, while executing a program in Hibernate in Tomcat i got an error like this HTTP Status 500.... Hopefully this will solve your problem. Regards Deepak Kumar 

Hibernate Questions

in connectivity - Hibernate
the hibernate and postgresql that progrram is running while showing no error... insertted  Hi friend, This is connectivity and hibernate configuration code com.mysql.jdbc.Driver jdbc:mysql://localhost 

Hibernate Questions

Hibernate compilation - Hibernate
Hibernate compilation  please explain how to compile and run Hibernate at command prompt ( in dos) with sample example 

Hibernate Questions

Problem with Hibernate or 11g
Problem with Hibernate or 11g  Hi I am using Hibernate and 11g in my project. The problem I am facing is I am executing a query from java class... on Created date column by using hibernate query language. The Problem is every 

Hibernate Questions

Eclipse hibernate problem
Eclipse hibernate problem  hie..i've just started a basic hibernate application using eclipse helios.I have added the jars,configured the xml files...;Hibernate Eclipse Integration Hibernate Tutorials 

Java-Tutorials

Hibernate Tutorial
Hibernate Tutorial This section contains the various aspects of Hibernate. Here we will read What is Hibernate, Features of Hibernate, Compatibility with the various databases, Hibernate dialect of various databases, Architecture 

Hibernate Questions

myfaces,hibernate and spring integration - Hibernate
myfaces,hibernate and spring integration  sorry, in the previous.../myfacesspring/downloadcode.shtml the code given in this url : http...). i wll be obliged.   Might be you have deploying problem. deploy 

Hibernate Questions

server problem - Hibernate
server problem  dear sir please give me best soloution how run hibernate and spring application on jboss and weblogic10.1.0 sever and compile thanks 

Spring Framework Questions

spring with hibernate - Spring
spring with hibernate   Hi, I need the sample code for user registration using spring , hibernate with my sql. Please send the code as soon as possible. I need Spring with Hibernate code not struts. Thanks, Valarmathi 

Hibernate Tutorial Example

Hibernate Getting Started
Hibernate Getting Started       Hibernate Getting Started In this Hibernate Getting Started you will quickly download the a Hibernate running example project and run 

Development process Questions

sample application using hibernate and wicket framework in net beans IDE
sample application using hibernate and wicket framework in net beans IDE  where can i get sample applications/ projects using hibernate and wicket framework in net beans IDE 

Java Beginners

Running problem with NoughtsAndCrossesGame in blank
Running problem with NoughtsAndCrossesGame in blank  Hi i was having problem created NoughtsAndCrossesGame in end the it works but i runs the gui... main(String[] args) { // TODO code application logic here 

Hibernate Tutorial Example

Hibernate 4.2 Tutorial
Hibernate 4.2 Tutorial - Learn how to use Hibernate 4.2.8 in your applications In this section you will find the latest tutorials of using Hibernate 4.2 for writing the persistence layer for applications. The Hibernate 4.2.x comes 

Hibernate Questions

org.hibernate.exception.GenericJDBCException - Hibernate
org.hibernate.exception.GenericJDBCException  Hi friends, how to invoke remote database from my system.in my code i wrote like this jdbc:mysql... system the application running but in remote system it giving exception like 

Hibernate Questions

this is a hibernate question
this is a hibernate question  connection pooling code in hibernate 

Hibernate Questions

this is a hibernate question
this is a hibernate question  connection pooling code in hibernate 

Hibernate Questions

this is a hibernate question
this is a hibernate question  connection pooling code in hibernate 

Hibernate Questions

Hibernate 4.3 JPA 2.1
version of Hibernate is 4.3 and JPA is JPA 2.1. My problem is to write the integrated code to use Hibernate 4.3 through JPA 2.1 in my application. Thanks...Hibernate 4.3 JPA 2.1  How to create a Java program using Hibernate 

Hibernate Questions

Hibernate 1 - Hibernate
Hibernate 1  what is a fetchi loading in hibernate?i want source code?plz reply 

Hibernate Questions

Hibernate delete example program
() method of the Session object. Here is the sample code: //Delete the object...Hibernate delete example program  How to delete an object in Hibernate? In my program I have to write program to delete the data using Hibernate 

Hibernate Questions

hibernate update problem
hibernate update problem  HI, I integrated the struts and hibernate and wrote the following query in the databean to update the user table login time SessionFactory sessionFactory = (SessionFactory)context.getAttribute 

Hibernate Questions

Compilation error. Hibernate code - Hibernate
Compilation error. Hibernate code   Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.hibernate.cfg.Configuration.(Configuration.java:152) at com.sat.Manager.main(Manager.java:10 

Hibernate Tutorial Example

Complete Hibernate 3.0 and Hibernate 4 Tutorial
to develop sample Hibernate Application. Also see Hibernate Getting Started... will show you how to run the example code.   Hibernate Introduction... with running code example. About 

Hibernate Questions

delete query problem - Hibernate
correctly , the problem is only delete query. 2) query.executeUpate(); ->...(); Read for more information. http://www.roseindia.net/hibernate Thanks 

Hibernate Questions

spring hibernate - Hibernate
with hibernate?  Hi friend, For solving the problem Spring with Hibernate visit to : http://www.roseindia.net/spring/index.shtml http://www.roseindia.net/struts/hibernate-spring/index.shtml Thanks 

Spring Framework Questions

spring with hibernate - Spring
spring with hibernate   Hi, I need the sample code for user registration using spring , hibernate with my sql. Please send the code as soon... the following link: http://www.roseindia.net/struts/hibernate-spring/user-registration 

Hibernate Questions

Hibernate error - Hibernate
Hibernate error  I had run hibernate first example but it an error..., Please explain in detail your problem so that we can discuss and solve it. If you want more examples of Hibernate please visit the following link. http 

Hibernate Interview Questions

Hibernate:What is Hibernate proxy?
is created by default by Hibernate, for mapping a class to a file. The code to invoke...Hibernate:What is Hibernate proxy?  What is Hibernate proxy?   Proxy means the authority to represent someone else In hibernate, you can 

Hibernate Questions

Hibernate Annotattions - Hibernate
Hibernate Annotattions  Can anybody tell me here how we can use hibernate annotations which is a new facility in hibernate 3.2 any tutorial and what.... The Hibernate Annotations is the powerful way to provide the metadata for the Object 

Hibernate-Tutorials

Complete Hibernate 4.0 Tutorial
hibernate by example hibernate repository hibernate sample code... This section contains the Complete Hibernate 4.0 Tutorial. Complete Hibernate 4.0 Tutorial Hibernate is a Object-relational mapping 

Hibernate Interview Questions

Transparent Persistence - Hibernate Interview Questions
Transparent Persistence  Hi friends, can u explain Transparent Persistence in hibernate with sample code. Thanks Prakash 

Programming Tutorials

HIBERNATE- BASICS
HIBERNATE- BASICS  (R.S.Ramaswamy)- ( in 3 parts) (part-1) ( CMP-EJB vs. HIBERNATE) (published in DeveloperIQ-July-2005... is agog with excitement about a very popular open-source technology , Hibernate 

Blog

Sitemap Hibernate Tutorial
; Tutorial Section Introduction to Hibernate 3.0 | Hibernate Architecture | First Hibernate Application | Running the Example in Eclipse | Understanding Hibernate O/R Mapping | Understanding Hibernate <generator> element 

Hibernate Questions

jsp-Hibernate Error - Hibernate
jsp-Hibernate Error  hi, my problem is, I designed an Interface where i am tring to listing the all rows of a table using Iterator and putted a link for deleting each row. I am deleteing row using row id of that record.it delete 

Hibernate Questions

Hibernate+JSF+Spring - Hibernate
Hibernate+JSF+Spring  i am facing the same problem. i have invited in Gtalk for chating. u can suggest ur convenience time to chat, so that i can ask my queries directly. i will be highly obliged 

Hibernate Questions

Hibernate nullpointer exception - Hibernate
Hibernate nullpointer exception  Hi, I am using eclipse IDE.I copied hibernate example from roseindia.net. I am using MYSQL as my database. 1.In... modifications in those files and placed in src as well as bin folder. 6.While running 

Hibernate Interview Questions

HIBERNATE
HIBERNATE   What is difference between Jdbc and Hibernate 

Hibernate Interview Questions

hibernate
hibernate  what is hibernate flow 

Hibernate Questions

hibernate
hibernate  what is hibernate listeners 

Hibernate Questions

Dynamic-update not working in Hibernate.
Dynamic-update not working in Hibernate.  Why is dynamic update not working in hibernate?   Dynamic-update is not working. It means when you are running your update, new data is added in your table in place 

Hibernate Questions

Need for hibernate - Hibernate
Need for hibernate  Can anyone say why should we go for hibernate?   Hi friend, Advantages of hibernate : It is based on object... solution. In Jdbc we use .properties file and in hibernate we use .xml file 

Advertisements Advertisements
 

 

 

DMCA.com