Home Tutorialhelp Comment client code not correct

 
 

Comment

appaji
client code not correct ,
November 18, 2008 at 6:25 AM

hi
client code(main is not correct) bcz you are not begin Transaction and close the Transaction . here find the correct code



package roseindia.tutorial.hibernate;

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


/**
* @author appaji
*
* http://www.roseindia.net
* Hibernate example to inset data into Contact table
*/
public class FirstExample {
public static void main(String[] args) {
Session session = null;

try{
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
Transaction ts=session.beginTransaction();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println("Inserting Record");
Contact contact = new Contact();
//contact.setId(6);
contact.setId(81);
contact.setFirstName("first");
contact.setLastName("last");
contact.setEmail("ramojo");

session.save(contact);
ts.commit();
System.out.println("Done");
}catch(HibernateException he) {
System.out.println("hibernate exception occured");
he.printStackTrace();

}catch(Exception e){
System.out.println("exception occured--->");
//e.printStackTrace();
System.out.println(e.getMessage());
}finally{
// Actual contact insertion will happen at this step

session.flush();
session.close();

}

}
}

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

hibernate
hibernate  how to impot mysql database client jar file into eclipse for hibernate configuration   Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate/runninge-xample.shtml Thanks 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code  firstExample code that you have given for hibernate... inserted in the database from this file. http://www.roseindia.net/hibernate/runninge-xample.shtml Thanks 

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 Questions

hibernate code - Hibernate
hibernate code  well deepak,Regarding the inputs u asked for my fisr...{ // This step will read hibernate.cfg.xml and prepare hibernate for use SessionFactory... the correct host address of the database, correct table name, correct column name 

JDBC Questions

code
code to create the RMI client on the local machine: import java.rmi.*; public... the correct code... = (Hello)Naming.lookup("server"); System.out.println("Client: Hello 

Java Beginners

Correct errors - Java Beginners
Correct errors  Identify and correct the errors in the following program: public java Method { public static method1(int n, m) { n += m... Friend, Try the following code: public class Example{ public static void main 

Programming Tutorials

Chapter 5. Client View of an Entity
Chapter 5. Client View of an EntityPrev Part I. Exam Objectives Next     Chapter 5. Client View of an EntityIdentify correct and incorrect statements or examples about the client 

JDBC Questions

correct the sql error
correct the sql error  i am getting a SQL Error while retriving data from access to jframe called "datatype mismatch in criteria expression" plez do... jButton4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here 

Java Beginners

Plz Provide correct program code for all questions.
Plz Provide correct program code for all questions.   Write a program to find the difference between sum of the squares and the square of the sums... the following code: 1) import java.util.*; class FindDifference { public static 

Programming Tutorials

Identify correct and incorrect statements or examples about the client's view of exceptions received from an enterprise bean invocation.
; Identify correct and incorrect statements or examples about the client's view... Identify correct and incorrect statements or examples about the client's view of exceptions received from an enterprise bean invocation 

Programming Tutorials

Identify correct and incorrect statements or examples about the client view of an entity bean's local component interface (EJBLocalObject).
;   Identify correct and incorrect statements or examples about the client... correct and incorrect statements or examples about the client view... Identify correct and incorrect statements or examples about 

Programming Tutorials

Identify correct and incorrect statements or examples about the client view of a entity bean's remote component interface (EJBObject).
Identify correct and incorrect statements or examples about the client view of a entity bean's remote component interface (EJBObject). Prev Chapter 5. Client View of an Entity Next   

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 

Programming Tutorials

Identify correct and incorrect statements or examples about the client view of a session bean's local and remote component interfaces.
Identify correct and incorrect statements or examples about the client view of a session bean's local and remote component interfaces. Prev Chapter 2. Client View of a Session Bean Next   

Hibernate Questions

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

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  while generating the hibernate code i got the error like org.hibernate.MappingException 

Hibernate Questions

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

Swing AWT

I didn't gat an output for this code, plz send me a correct code
I didn't gat an output for this code, plz send me a correct code  Hi, Here is my code: import java.awt.event.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.*; import java.sql.*; public 

Java Beginners

what is the correct format of charAt() function?
)=='a'){ But the syntax of the charat()function is correct in the code.  Hi Friend, Try the following code: class prog{ int count=0; public void cal1...what is the correct format of charAt() function?   class prog 

Programming Tutorials

Identify correct and incorrect statements or examples about EJB programming restrictions.
Identify correct and incorrect statements or examples about EJB... Overview Next     Identify correct and incorrect statements... is allowed be a network socket client. The enterprise bean must 

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 

Hibernate Questions

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

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 Birendra Pradhan.I want... in the DAO.Can it be possibe. Please send some sample code.. thanks... to : http://www.roseindia.net/hibernate/index.shtml Thanks 

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 

Programming Tutorials

Chapter 2. Client View of a Session Bean
;Client View of a Session BeanIdentify correct and incorrect statements... interfaces, including the code used by a client to locate a session bean's... Chapter 2. Client View of a Session BeanPrev  

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 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... session.flush(); i am using hibernate 3.3.1 and I kept hibernate3.jar 

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 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 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 

Struts Questions

struts client side validation
struts client side validation  how can i code for client side validation 

Hibernate-Tutorials

Hibernate 4 AnnotationSessionFactoryBean
from Hibernate 3 to Hibernate 4. If you use the following code in your Hibernate 4...How to use AnnotationSessionFactoryBean in Hibernate 4? Can it be used... AnnotationSessionFactoryBean which is not available in Hibernate 4. As a part of migration process 

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 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 

JSP Servlet Questions

jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct...  my project has login in whic i should select the company name... value(i.e)company name should match.... pls provide code.... thanx    

JDBC Questions

jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct...  my project has login in which i should select the company name... value(i.e)company name should match.... pls provide code.... thanx   1 

JSP Servlet Questions

jsp login code ... when username , drop down box and password is correct
jsp login code ... when username , drop down box and password is correct  i need a jsp code for login.... when username password and dropdown box value is correct.... the drop down box values should be retrieved from database 

Java Beginners

Java FTP Client Example
Java FTP Client Example  How to write Java FTP Client Example code? Thanks   Hi, Here is the example code of simple FTP client in Java which downloads image from server FTP Download file example. Thanks 

Hibernate Questions

Hibernate application - Hibernate
Hibernate application  Hi, Could you please tell me how to implement hibernate application in eclipse3.3.0 Thanks, Kalaga.  Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate 

Web Services

Axis2 client - Axis2 Client example
; Apache Axis2 Client code In this section we will develop client code example... we will write the Web service client code and call the web service.  ... changes the wsdl2java.bat is available for generating the client code calling 

Hibernate Tutorial Example

Hibernate 4 create Session Factory: Example of creating Session Factory in Hibernate 4
the code for creating the SessionFactory instance in your application. Hibernate... to this version of Hibernate you will have to change the code. You should the latest... the following code to create the SessionFactory in Hibernate 4: Configuration 

Hibernate Questions

java(Hibernate) - Hibernate
java(Hibernate)  Hai Amardeep This is jagadhish.Iam giving full code... Client TestClient.java file import... will read hibernate.cfg.xml and prepare hibernate for use SessionFactory 

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 

Java Beginners

How to get the correct value by calculating double values....
How to get the correct value by calculating double values....  Hello Sir, I have a method in which i am getting getting wrong datavalues calculated from the function ...here is my code for this task.... try 

JSP Servlet Questions

XML response correct in broser but incorrect in Java
XML response correct in broser but incorrect in Java  Firs of all I... for this and many other helps. I read and printed the response (code below) but the result is not correct. In browser shows me (correct): <ENELIT> <GESI> 

Java Beginners

How to get the correct value by calculating double values....
How to get the correct value by calculating double values....  Hello Sir, I have a method in which i am getting getting wrong datavalues calculated from the function ...here is my code for this task.... try 

Web Development

Client Side Coding
Client Side Coding       Here, the client side coding refers to the code scripted for the end-client that reflects on the clients’ terminal. This type of coding is known 

Java Beginners

Failed Client-Socket Communication
connection with the client. I am at my wits end!Can someone run the code for me &...){ System.out.println(e); } } }[/code] CLIENT: [code] import...Failed Client-Socket Communication  I hve written a server program 

JDBC Questions

correct the sql error and retrive data....plez
correct the sql error and retrive data....plez  i am getting a SQL Error while retriving data from access to jframe called "datatype mismatch... your handling code here: if(jTextField1.getText().equals 

Java Beginners

Probblems with printing if my innput of text file is correct..
Probblems with printing if my innput of text file is correct..  I am trying to make sure this block of code does what I think it will do. Can someone show me with some code how I can print out what is is labled with <----print 

Eclipse Plugins

Eclipse Plugin-Rich Client Applications
Eclipse Plugin-Rich Client Applications.... Is is an example of a business oriented, rich client application which benefits from....    Matchmaker-Client Application  

Hibernate Questions

hibernate web project - Hibernate
links: http://www.roseindia.net/hibernate/index.shtml http://www.roseindia.net/hibernate/runninge-xample.shtml http://www.roseindia.net/struts/struts...hibernate web project  hi friends,very good morning,how to develop 

Hibernate Questions

org.hibernate.cfg.Environment - Hibernate
org.hibernate.cfg.Environment  HI FRIEND aS I M USING MY CODE WHICH IS FULLY CORRECT BUT THEN ALLSO IT IS SHOWING THAT THE log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN 

Java Beginners

http Client Authentication
http Client Authentication  hi friends, i am trying a java API... { System.out.println("\n Place Collection URL = "+ placeurl); HttpClient client = new... ); System.out.println("\n Response status code: " + statusCode); // Display response 

Hibernate Questions

hibernate...............
hibernate...............  goodevining. I am using hibernate... in connect descriptor The Connection descriptor used by the client... in connect descriptor The Connection descriptor used by the client was: localhost 

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 Questions

Problem in running first hibernate program.... - Hibernate
/FirstExample Exception in thread "main" " http://www.roseindia.net/hibernate/runninge...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 

Hibernate Questions

java - Hibernate
/hibernate/runninge-xample.shtml Thanks...java  HI guys can any one tell me,procedure for executing spring and hibernate in myeclipse ide,plz very urgent for me,thank's in advance.   

Hibernate Questions

Is buildSessionFactory() deprecated in hibernate 4?
Is buildSessionFactory() deprecated in hibernate 4?  Hi, I am trying to develop an application in Hibernate 4. I am using the Hibernate 4.3.0.final build. Following code is given is the Hibernate documentation: SessionFactory 

EJB Questions

new to EJBs exceptions while excuting Client code - EJB
new to EJBs exceptions while excuting Client code  Hi i am new... then it is compiling fine can any one help me please.. i am posting the client code and the EXCEPTIONS here... thanks 

Struts Questions

fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below pls correct my code  my Code Given below Pls... help me send correct code for me jsp file... <%@page contentType="text/html" pageEncoding 

Struts Questions

fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below pls correct my code  my Code Given below Pls... help me send correct code for me jsp file... <%@page contentType="text/html" pageEncoding 

Java Beginners

Hi i want java code that diaplays server scren at the client side
Hi i want java code that diaplays server scren at the client side  Hi I'm Shivaprasad i want java socket code that shows the server side screen when client gets connected with the server. Please help me   Please visit 

WebSevices Questions

Spring Restful webservice and client example
Spring Restful webservice and client example  Hi, I need the Spring Restful webservices generation using dao ,dto and controller format. Then tell me how can i generate the client for the above service. Please send the code 

Hibernate Questions

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

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 - Hibernate
Hibernate  I am trying to connect hibernate with ejb2.0 stateless session bean, my application sucessfully deploy in weblogic server but when i execute the client application i got an error message that class not found exception 

Hibernate Interview Questions

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

Hibernate Questions

Hibernate Criteria Transformer Example code
Hibernate Criteria Transformer Example code  Hello, I am trying to find the example of Hibernate Criteria Transformer. Tell me the good tutorial of Hibernate Criteria Transformer with source code. Thanks   Hi, Check 

Hibernate Questions

hibernate - Hibernate
Hibernate; import org.hibernate.Session; import org.hibernate.*; import...   Hi Radhika, i think, you hibernate configuration is not correct com.mysql.jdbc.Driver jdbc:mysql 

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

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=" 

Struts Questions

<s:radio> in struts 2 is not setting the correct value. - Struts
in struts 2 is not setting the correct value.  hello, i m using the following code in my jsp: where pa is HashMap object defined in action class with getter/setter as pa = new HashMap(); pa.put("1","Yes"); pa.put("2 

Programming Tutorials

Given a security-related deployment descriptor tag, identify correct and incorrect statements and code related to that tag.
correct and incorrect statements and code related to that tag. Prev ...; Given a security-related deployment descriptor tag, identify correct and incorrect statements and code related to that tag 

Java Beginners

code
the correct code for a program.The output of the program is listed below...: {Block 5} ADDRESS-3: {San Juan} POST CODE:{6745} ENTER CODE (XX TO stop) CODE:{FF1} QUANTITY:{2} CODE:{TR4} QUANTITY:{1} CODE:XX INVOICE FOR YOUR ORDER Harry 

Hibernate Questions

hibernet code - Hibernate
 

JavaScript Questions

Server side validation vs client side validation
Server side validation vs client side validation  Can any one tell me... of Server side validation vs client side validation.   The client side.... It actually check if the submitted data is correct or not. It is suggested 

Hibernate Questions

Hibernate - Hibernate
Hibernate  Hai this is jagadhish while running a Hibernate.../hibernate/ Please specify your requirements in detail. It would be good for me to provide you the solution if problem is clear. please post all code 

Hibernate Questions

hibernate Configuration with eclpse 3.1 - Hibernate
/hibernate/runninge-xample.shtml http://www.roseindia.net...hibernate Configuration with eclpse 3.1  Dear Sir, i m developing a program using hibernate with struts. but i am not able to configure 

Servlets

Client Auto Refresh in Servlets
Client Auto Refresh in Servlets       This section illustrates you how client gets auto refresh. We are providing... the servlet gets destroy. Here is the code of ClientAutoServlet.java 

Java Beginners

Create text file at client's directory from server.
Create text file at client's directory from server.  Need java code to create text file at client's directory from server..... Please Help 

Hibernate Questions

myJSF,Hibernate and Spring integration code is not working. - Hibernate
myJSF,Hibernate and Spring integration code is not working.  the code given in this url : http://www.roseindia.net/roseindiamembers/login.php i have tried but it does not work. when i write http://localhost 

JSP Servlet Questions

Produces XML file but format not correct for storing data using JSP and XML
Produces XML file but format not correct for storing data using JSP and XML  hii I have created a project using JSP and XML as database to store data...;1232</Email> </Student> </Stu> My JSP code for the given 

Java Code Examples

Multicast Client in Java
UDP Multicast Client in Java   ... to send and receive the IP packet or message by multicast client. Here, we provide...') and port number(5000). Those of any client sends and receives IP packet 

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 

WebSevices Questions

selenium rc java client driver - WebSevices
selenium rc java client driver  how to implement getcookies functions in selnium rc??? i m using getcookies function in selenium rc java client driver. but its given some error. pls tell me whether i have 2 write code 

Hibernate Questions

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

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-Tutorials

Hibernate SessionFactory
;/hibernate-configuration> Download Source Code...Hibernate SessionFactory In this tutorial we will learn about how... request from the client. Once the SessionFactory is created it can't 

Servlets

How to get client's address in a servlet
How to get client's address in a servlet  ... client's address in a servlet. In this example we have used method getremoteAddr() of the ServletRequest interface which returns IP address of the client 

Struts and Hibernate Integration Tutorial

Struts Hibernate Integration
and Hibernate Integration. You can download the source code from here... In this section we will write Hibernate Struts Plugin Java code... using Struts Hibernate Plugin In this section we will write web client 

Development process Questions

Save file on Client Machine - Development process
the code such that the D: of client machine is accessed and file is saved...Save file on Client Machine  Hi my application is running on main...://boserver:9090/AI where boserver is the name of server machine, now when a client 

Hibernate Questions

Hibernate Criteria Query Example with source code
good example of Hibernate Criteria Query Example with source code? Thanks   Here is good Example program of Hibernate Criteria Query with source code. The source code of the Hibernate Criteria Query will help you in grasping 

Java Beginners

How to fireup HTTP request from JavaFX Client
can fire HTTP post request from an JavaFX client. Sceneario: I've an JavaFX... i've working version of JSP Code to handle HTTP post request tested by posting... string data-types i.e., Username and Password from JavaFX client 

General

RMI Client And RMI Server Implementation
= _3232 Here is the code of RMI Client... RMI Client And RMI Server Implementation  ... comprises of the two separate programs, a server and a client. A typical server 

Advertisements Advertisements
 

 

 

DMCA.com