Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Hibernate fIRST APPLICATION
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


SAMAR
fIRST APPLICATION
2 Answer(s)      6 years and 9 months ago
Posted in : Hibernate


Dear Sir, with due respect,it is here to tell you i am beginner in hibernate.AS I M TRYING TO RUN YOUR FIRST APPLICATION OF HIBERNATE. BUT IT IS SHOWING exception Exception in thread "main


Advertisement
View Answers

April 22, 2008 at 7:43 PM


Hi friend,

package roseindia;

import org.hibernate.*;
import org.hibernate.criterion.*;
import org.hibernate.cfg.*;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import java.util.*;

public class pojoexample {
public static void main(String arg[]){
Session session = null;
try{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
org.hibernate.Transaction tx = session.beginTransaction();
System.out.println("Insert data into database");
HibernatePojoExample pojo = new HibernatePojoExample();

pojo.setUsername("amardeep");
pojo.setLastname("Patel");
pojo.setAddress("rohini,delhi-85");
pojo.setQualification("MCA");
pojo.setState("delhi");
session.save(pojo);
tx.commit();
session.flush();
session.close();
}catch(Exception e){
System.out.println(e.getMessage());
}
finally{
}
}
}

------------------------


April 22, 2008 at 7:45 PM


package roseindia;

public class HibernatePojoExample {

private String username;
private String lastname;
private String address;
private String qualification;
private String state;
private int id;

public String getUsername(){
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}

public String getQualification(){
return qualification;
}
public void setQualification(String qualification){
this.qualification = qualification;
}
public String getState(){
return state;
}
public void setState(String state){
this.state = state;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}


----------------------------

<class name="roseindia.HibernatePojoExample" table="pojoinformation">
<id name="id" type="int" column="id" >
<generator class="assigned"/>
</id>

<property name="username">
<column name="username" />
</property>
<property name="lastname">
<column name="lastname"/>
</property>
<property name="address">
<column name="address"/>
</property>
<property name="qualification">
<column name="qualification"/>
</property>

<property name="state">
<column name="state"/>
</property>

</class>

-------------------------------------

try again,

read for information,

http://www.roseindia.net/hibernate/


Related Tutorials/Questions & Answers:
First JSF Application - WebSevices
First JSF Application  First JSF application and JSF application folder structure, please help me in writing my first application using JSF. thanx :-)  Hi,Please check http://www.roseindia.net/jsf/jsf1.2
First Struts Application - Struts
First Struts Application  Hello, Hello, I have created a struts simple application by using struts 1.2.9 and Jboss 4.0.4. I am getting below exception when I start JBoss server. INFO [[/project1]] Marking servlet
Advertisements
fIRST APPLICATION - Hibernate
fIRST APPLICATION  Dear Sir, with due respect,it is here to tell you i am beginner in hibernate.AS I M TRYING TO RUN YOUR FIRST APPLICATION OF HIBERNATE. BUT IT IS SHOWING exception Exception in thread "main   Hi friend
Writing your First WAP Application.
different cards. Let's create our first application... WML application first three line is must and it contains...; Writing your First
First Hibernate Application
First Hibernate Application In this tutorial you will learn about how to create an application of Hibernate 4. Here I am giving an example which will demonstrate you how can you make your application using Hibernate 4. To create
Writing First Hello World application in JSP
to create first web page on tomcat server. JSP simply application that work...;. This one the simply exercise for your first application JSP. Just modify file... html pages. Then the application load the new file, with the "Hello.jsp"
First Ajax Example
Ajax First Example - Print Date and Time   ... Ajax Application for displaying the current date and time. Date and time.... This is the first example in Ajax that will give you quick start in the Ajax
First Step towards JDBC!
First Step towards JDBC      ... and shows you how to create a database application to access the databases. For the shake of simplicity, in very first example Access database
struts first example - Struts
struts first example  I got errors in struts first example like can... # -- welcome -- welcome.title=Struts Blank Application welcome.heading=Welcome... ERROR: Application resources not loaded
First Step towards JDBC!
is Java application programming interface that allows the Java programmers... and simple.    JDBC Versions From First To Latest  ...; JDBC is essentially an Application Programming Interface (API
Writing first JPA 2.1 example
/tools are need for developing the first JPA 2.1 example application: Java... the application easily. Let's start developing our first JPA 2.1 example. Step 1... for storing the data for this application. The MySQL database is very easy to use
struts first - Struts
struts first  struts first program example
the focus to the first form field
the focus to the first form field   How do I set the focus to the first form field
focus to the first form field
focus to the first form field  How do I set the focus to the first form field
focus to the first form field
focus to the first form field  How do I set the focus to the first form field
Struts first example - Struts
Struts first example  when i am doing struts first example , it is raising 404 error sometimes it is raised 500 error. what is the problem, and how to do the first program in struts. please give reply with regad's
find the first character is vowel or not
find the first character is vowel or not  hi friend, can u plz send me javascript code for find the wether the first character is a vowel or not. 2) check wether the last character is same as the first character or not 3) check
Sum of first n numbers
Sum of first n numbers  i want a simple java program which will show the sum of first n numbers....   import java.util.*; public class SumOfNumbers { public static void main(String[]args){ Scanner input=new
resign first responder keyboard
resign first responder keyboard  Hi, How I can hide keyboard on click on of done button in keyboard. Give me example of resign first responder keyboard example code. Thanks   Hi, Make your controller delegate to text
Struts First Example - Framework
Struts First Example  HI i am new to Struts and developing a single loginForm project. But it gives me the following exception javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean
My first Java Program
My first Java Program  I have been caught with a practical exam to do the following: Write a program that takes input from a user through the command line. The user must be prompt to enter a sentence (anything). The sentence
SQL Aggregate Functions First
SQL Aggregate Functions First       SQL Aggregate Function First, that performs calculation... illustrate an example from SQL Aggregate Functions First. The Example create a table
Struts first example - Struts
Struts first example  Hi! I have field price. I want to check require and input data type is int. can you give me an example code of validation.xml file to resolve it? thanks you so much!  Hi friend, Plz specify
spring first example - Spring
spring first example  I am trying my first example of spring from the link http://www.maestric.com/doc/java/spring/setup But I am not getting the simple "Hi" message ,I have created simple one jsp page and /WEB_INF/web.xml
JDBC ResultSet first() Example
JDBC ResultSet first() Example: The ResultSet first() are use to moves the cursor to the first row in the ResultSet object. It return true if the cursor pointed first row in the ResultSet and return false if the ResultSet object does
First Program
Now, lets move ahead for printing the first and most simple & common example of programming “Hello World”. <html> <body> <?php print (“Hello World”); ?> </body> </html>
Creating Web application on tomcat server
Create your first Tomcat Web application       In this section we will show you how to create first web application using Servlet on the tomcat server.  We first make a class
Spark Application Container in Flex4
Spark Application Container in flex4: Spark container is define in the spark.components package. The application container is the first container... application. The tag for the spark application container is <s:Application
How to write first example in Ajax?
How to write first example in Ajax?  Hi, I am beginner in Ajax and want learn it. How can I write first example in Ajax? Thanks   Hi, Please check the tutorial First Ajax Example. Thank
How to create first program in Java?
How to create first program in Java?  Hi, I am new in Java programming. Tell me How to create first program in Java? Thanks   Hi, Read more at First Java Program. Thanks
My first struts 2 program
My first struts 2 program  Hi, Please help me for my first struts 2... from one page to another. Details: I am trying my first Struts 2 example program. I want to pass values from first loginpage.jsp to displaypage.jsp. I
Advertisements
 

 

 

DMCA.com