Home Hibernate Writing First Hibernate Code
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Writing First Hibernate Code

Advertisement
In this section I will show you how to create a simple program to insert record in MySQL database. You can run this program from Eclipse or from command prompt as well. I am assuming that you are familiar with MySQL and Eclipse environment.

Writing First Hibernate Code

     

In this section I will show you how to create a simple program to insert record in MySQL database. You can run this program from Eclipse or from command prompt as well. I am assuming that you are familiar with MySQL and Eclipse environment.

Configuring Hibernate
In this application Hibernate provided connection pooling and transaction management is used for simplicity. Hibernate uses the hibernate.cfg.xml to create the connection pool and setup required environment.

 

Here is the code:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
  <property name="hibernate.connection.driver_class">

com.mysql.jdbc.Driver</property>
  <property name="hibernate.connection.url">

jdbc:mysql://localhost/hibernatetutorial</property>
  <property name="hibernate.connection.username">root</property>
  <property name="hibernate.connection.password"></property>
  <property name="hibernate.connection.pool_size">10</property>
  <property name="show_sql">true</property>
  <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  <property name="hibernate.hbm2ddl.auto">update</property>
  <!-- Mapping files -->
  <mapping resource="contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>

In the above configuration file we specified to use the "hibernatetutorial" which is running on localhost and the user of the database is root with no password. The dialect property  is org.hibernate.dialect.MySQLDialect which tells the Hibernate that we are using MySQL Database. Hibernate supports many database. With the use of the Hibernate (Object/Relational Mapping and Transparent Object Persistence for Java and SQL Databases),  we can use the following databases dialect type property:

  • DB2 - org.hibernate.dialect.DB2Dialect
  • HypersonicSQL - org.hibernate.dialect.HSQLDialect
  • Informix - org.hibernate.dialect.InformixDialect
  • Ingres - org.hibernate.dialect.IngresDialect
  • Interbase - org.hibernate.dialect.InterbaseDialect
  • Pointbase - org.hibernate.dialect.PointbaseDialect
  • PostgreSQL - org.hibernate.dialect.PostgreSQLDialect
  • Mckoi SQL - org.hibernate.dialect.MckoiDialect
  • Microsoft SQL Server - org.hibernate.dialect.SQLServerDialect
  • MySQL - org.hibernate.dialect.MySQLDialect
  • Oracle (any version) - org.hibernate.dialect.OracleDialect
  • Oracle 9 - org.hibernate.dialect.Oracle9Dialect
  • Progress - org.hibernate.dialect.ProgressDialect
  • FrontBase - org.hibernate.dialect.FrontbaseDialect
  • SAP DB - org.hibernate.dialect.SAPDBDialect
  • Sybase - org.hibernate.dialect.SybaseDialect
  • Sybase Anywhere - org.hibernate.dialect.SybaseAnywhereDialect

The <mapping resource="contact.hbm.xml"/> property is the mapping for our contact table.

Writing First Persistence Class
Hibernate uses the Plain Old Java Objects (POJOs) classes to map to the database table. We can configure the variables to map to the database column. Here is the code for Contact.java:

package roseindia.tutorial.hibernate;

/**
 @author Deepak Kumar
 *
 * Java Class to map to the datbase Contact Table
 */
public class Contact {
  private String firstName;
  private String lastName;
  private String email;
  private long id;

  /**
 @return Email
 */
  public String getEmail() {
  return email;
  }

  /**
 @return First Name
 */
  public String getFirstName() {
  return firstName;
  }

  /** 
 @return Last name
 */
  public String getLastName() {
  return lastName;
  }

  /**
 @param string Sets the Email
 */
  public void setEmail(String string) {
  email = string;
  }

  /**
 @param string Sets the First Name
 */
  public void setFirstName(String string) {
  firstName = string;
  }

  /**
 @param string sets the Last Name
 */
  public void setLastName(String string) {
  lastName = string;
  }

  /**
 @return ID Returns ID
 */
  public long getId() {
  return id;
  }

  /**
 @param l Sets the ID
 */
  public void setId(long l) {
  id = l;
  }

}

Mapping the Contact Object to the Database Contact table
The file contact.hbm.xml is used to map Contact Object to the Contact table in the database. Here is the code for contact.hbm.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class name="roseindia.tutorial.hibernate.Contact" table="CONTACT">
   <id name="id" type="long" column="ID" >
   <generator class="assigned"/>
  </id>

  <property name="firstName">
   <column name="FIRSTNAME" />
  </property>
  <property name="lastName">
  <column name="LASTNAME"/>
  </property>
  <property name="email">
  <column name="EMAIL"/>
  </property>
 </class>
</hibernate-mapping>

Setting Up MySQL Database
In the configuration file(hibernate.cfg.xml) we have specified to use hibernatetutorial database running on localhost.  So, create the databse ("hibernatetutorial") on the MySQL server running on localhost.

Developing Code to Test Hibernate example
Now we are ready to write a program to insert the data into database. We should first understand about the Hibernate's Session. Hibernate Session is the main runtime interface between a Java application and Hibernate. First we are required to get the Hibernate Session.SessionFactory allows application to create the Hibernate Sesssion by reading the configuration from hibernate.cfg.xml file.  Then the save method on session object is used to save the contact information to the database:

session.save(contact)

Here is the code of FirstExample.java


package roseindia.tutorial.hibernate;

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


/**
 @author Deepak Kumar
 *
 * 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();
  //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(3);
  contact.setFirstName("Deepak");
  contact.setLastName("Kumar");
  contact.setEmail("deepak_38@yahoo.com");
  session.save(contact);
  System.out.println("Done");
  }catch(Exception e){
  System.out.println(e.getMessage());
  }finally{
  // Actual contact insertion will happen at this step
  session.flush();
  session.close();

  }
  
  }
}

In the next section I will show how to run and test the program.

 

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 8, 2008

Ask Questions?    Discuss: Writing First Hibernate Code   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
anonymous
April 9, 2011
values are not inserted into the table?

after running the firstexample program it runs successfully but doesn't insert the hardcoded values into the contact table. please explain me why values are not inserted into the contact table?
shrikant kamble
June 7, 2011
comment on ur example

this very good for beginer
sid
June 16, 2011
good!

good helpfull!
priya
July 10, 2011
Regarding xml files

Hello sir, Do we have to put all the xml files in the src folder only?
shabbir
July 1, 2011
hai

ya friends ur giving full information about how to write first hibernet program but how to run ? information is not there.
Ameet
September 13, 2011
session transaction?

I tried your tutorial. After a bit of a struggle figured that we need to wrap the session into a session.beginTransaction() and session.getTransaction().commit(). Please clarify.
prasad
September 21, 2011
Hibernate Basics

If we have Servlet-Jsp technologies then why we use hibernate instead of it
doesn't matter
October 12, 2011
session.flush not working!

I followed this tutorial and session.flush didnt work for me. I googled this issue and still couldnt find any promising results. The solution Ive discovered so far is transaction.commit. Any bright ideas?
Bilaal
December 6, 2011
Error

Hi I am learning how to use hibernate and I tried this example, but I have an error in this line: session.flush(); Can you please show please, how the project tree is organized.
Bhoj Raj bhatt
December 17, 2011
Problem with this example

When I run above example I have with session.flush(). Error message: exception java.lang.NullPointerException helloPackage.hello.doPost(hello.java:80) javax.servlet.http.HttpServlet.service(HttpServlet.java:641) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) . Here line 80 means: session.flush();. please reply why ???
Gaurav
January 3, 2012
No Insertion

I got the message Hibernate: insert into CONTACT (FIRSTNAME, LASTNAME, EMAIL, ID) values (?, ?, ?, ?) And the values are not inserting?? Please help..
Abhishek Chaudhary
February 2, 2012
Code Problem

I am new in hibernate, I am using your this example as reference. But your this example is not working, The program is not giving any output, can you tell me why is it so??
mani
February 14, 2012
hi

good site
chartahir
February 17, 2012
Required Jars & MySqlDriver

Hi, Can you also add here about which jars are required to make this code work and how/where to get the MySQL Driver.
jubinpatel
March 1, 2012
Error Solved

You face error in bean file,your data can not pass to database so use this bean file(Problem is in only bean file) <!-- file is here --> public class FirstExample extends Contact{ public static void main(String[] args) { Session session = null; Transaction transaction = null ; try{ SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session =sessionFactory.openSession(); transaction = session.beginTransaction(); transaction.begin(); //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(7); contact.setFirstName("Deepak"); contact.setLastName("Kumar"); contact.setEmail("deepak_38@yahoo.com"); session.save(contact); System.out.println("Done"); transaction.commit(); session.flush(); session.close(); } catch(Exception e){ System.out.println("error in first"+e.getMessage()); } } }
Darshil
March 30, 2012
Error : No Reflection in database

Hey friends use Transaction ta=session.beginTransaction; //after session.save(); ta.commit();
Pavan
April 25, 2012
Error while running this program

Hi, If i use <generator class="assigned"/> in the mapping file for MYSQL database its not saving data. Instead of that i have used <generator class="native"/> which is working fine after that.
Pavan
April 25, 2012
Error while running this program

If dont commit the session the values are not getting stored in the database.
SANJEEV RANJAN
May 4, 2012
hibernate

thank you, now i'm albe to write the hibernate file.
arun kumar
May 15, 2012
bug in Writing First Hibernate Code

In this program we are not using transaction objection to commit the data..
kumar rajput
May 29, 2012
all links to same page

why have you provided previous index and next links when they point to same web page !!
ZhongmingLiu
June 1, 2012
software enegineer

like it and do it
chaitya
June 9, 2012
error

you need transcation object to commit the data
eiso
June 15, 2012
outdated

model
harsha rao
July 14, 2012
hibernate

nice
Chitranshu
July 25, 2012
Incomplete code

This code is incomplete. To complete this code create an object of transaction class. And use commit() method. ie Transaction tr=session.beginTransaction(); tr.commit();
Rajesh Kumar
August 18, 2012
save transaction

Running FirstExample will not insert record since transaction is not saved. The code has to be like this SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session =sessionFactory.openSession(); Transaction tx = 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.setFirstName("Deepak"); contact.setLastName("Kumar"); contact.setEmail("deepak_38@yahoo.com"); session.beginTransaction(); session.save(contact); tx.commit();
maktoom
August 23, 2012
fail

hi, i copy/paste this codes on netbeans7.2 and after build and deploy i see this messages in run (DB is: mysql5.2): run: Aug 23, 2012 10:36:11 AM org.hibernate.cfg.Environment <clinit> INFO: Hibernate 3.2.5 Aug 23, 2012 10:36:11 AM org.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found Aug 23, 2012 10:36:11 AM org.hibernate.cfg.Environment buildBytecodeProvider INFO: Bytecode provider name : cglib Aug 23, 2012 10:36:11 AM org.hibernate.cfg.Environment <clinit> INFO: using JDK 1.4 java.sql.Timestamp handling Aug 23, 2012 10:36:11 AM org.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml Aug 23, 2012 10:36:11 AM org.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml Aug 23, 2012 10:36:11 AM org.hibernate.cfg.Configuration addResource INFO: Reading mappings from resource : contact.hbm.xml Aug 23, 2012 10:36:12 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues INFO: Mapping class: roseindia.tutorial.hibernate.Contact -> CONTACT Aug 23, 2012 10:36:12 AM org.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null Aug 23, 2012 10:36:12 AM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: Using Hibernate built-in connection pool (not for production use!) Aug 23, 2012 10:36:12 AM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: Hibernate connection pool size: 10 Aug 23, 2012 10:36:12 AM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: autocommit mode: false Aug 23, 2012 10:36:12 AM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/hibernatetutorial Aug 23, 2012 10:36:12 AM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: connection properties: {user=root, password=****} Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: RDBMS: MySQL, version: 5.5.20 Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.18 ( Revision: tonci.grgin@oracle.com-20110930151701-jfj14ddfq48ifkfq ) Aug 23, 2012 10:36:12 AM org.hibernate.dialect.Dialect <init> INFO: Using dialect: org.hibernate.dialect.MySQLDialect Aug 23, 2012 10:36:12 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory INFO: Using default transaction strategy (direct JDBC transactions) Aug 23, 2012 10:36:12 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic flush during beforeCompletion(): disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic session close at end of transaction: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC batch size: 15 Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC batch updates for versioned data: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Scrollable result sets: enabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC3 getGeneratedKeys(): enabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Connection release mode: auto Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Maximum outer join fetch depth: 2 Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Default batch fetch size: 1 Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Generate SQL with comments: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Order SQL updates by primary key: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Order SQL inserts for batching: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory Aug 23, 2012 10:36:12 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init> INFO: Using ASTQueryTranslatorFactory Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Query language substitutions: {} Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: JPA-QL strict compliance: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Second-level cache: enabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Query cache: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory createCacheProvider INFO: Cache provider: org.hibernate.cache.NoCacheProvider Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Optimize cache for minimal puts: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Structured second-level cache entries: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Echoing all SQL to stdout Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Statistics: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Deleted entity synthetic identifier rollback: disabled Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Default entity-mode: pojo Aug 23, 2012 10:36:12 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Named query checking : enabled Aug 23, 2012 10:36:12 AM org.hibernate.impl.SessionFactoryImpl <init> INFO: building session factory Aug 23, 2012 10:36:13 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance INFO: Not binding factory to JNDI, no JNDI name configured Aug 23, 2012 10:36:13 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute INFO: Running hbm2ddl schema update Aug 23, 2012 10:36:13 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute INFO: fetching database metadata Aug 23, 2012 10:36:13 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute INFO: updating schema Aug 23, 2012 10:36:13 AM org.hibernate.tool.hbm2ddl.TableMetadata <init> INFO: table found: hibernatetutorial.contact Aug 23, 2012 10:36:13 AM org.hibernate.tool.hbm2ddl.TableMetadata <init> INFO: columns: [id, email, lastname, firstname] Aug 23, 2012 10:36:13 AM org.hibernate.tool.hbm2ddl.TableMetadata <init> INFO: foreign keys: [] Aug 23, 2012 10:36:13 AM org.hibernate.tool.hbm2ddl.TableMetadata <init> INFO: indexes: [primary] Aug 23, 2012 10:36:13 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute INFO: schema update complete Inserting Record Done Hibernate: insert into CONTACT (FIRSTNAME, LASTNAME, EMAIL, ID) values (?, ?, ?, ?)
karunakar sarabu
September 5, 2012
query

please tell me how to test this application. i cant find it in the online tutorial.
no comment
October 3, 2012
no comment

no comment
amit
October 29, 2012
About Updation of code

Please put this lines in code. import org.hibernate.Transaction; . . . Transaction tx=session.beginTransaction(); // Add this soon after initializing session object tx.commit() // just before saving the session
Reem
November 17, 2012
error

when i run the code a java exception has occured any advice thanks
dibya jyoti das
November 19, 2012
The code is amaizing

This tutorial is very simple as well asa very effective.
sahad
November 28, 2012
Please answer

I cant get the output by using above code.I am getting the error Could not parse mapping document from resource contact.hbm.xml Exception in thread "main" java.lang.NullPointerException at roseindia.FirstExample.main(FirstExample.java:34)
Bhajan
January 4, 2013
Need to make small correction in the given example

Hi There, No doubt, your this tutorial (http://www.roseindia.net/hibernate/firstexample.shtml) is very good and informative. But when I tried to use above example as it is, It was not working. I would like to give you my updated code, You can review this and if find this relevant than please update this example. 1.) Need to create object of transaction class as below after session creation. org.hibernate.Transaction txn = session.beginTransaction(); txn.begin(); 2.) Need to commit transaction after save command as: session.save(<NAME_OF_OBJECT>); txn.commit();
vidushe
April 3, 2013
unable to run the code

i tried your program.its giving me the 'hibernate.cfg.xml' file not found error.while debugging, i noticed that the code after SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); is not being executed. pls help
joseph
April 13, 2013
small issue with sample code

Hey, Nice and simple article I tried your example.It works good but FirstExample.java fails to insert to database.I am using SqlServer 2005 <property name ="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property> <property name ="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property> From the logs I can see that the INSERT statement is getting created fine and no exceptions are present but still no entry in database,any ideas?
Dilip Voruganti
April 28, 2013
Data is not going to be inserted in this example

Total example is correct but data is not going to be inserted bcoz of, Not opening Transaction. i.e.., After session =sessionFactory.openSession(); INSERT Transaction t =session.beginTransaction(); and at last say t.commit(); Then ur data will be inserted into the database.
Saurabh
July 10, 2013
Missing code

In FirstExample class we need to begin the Transaction after opening the session i,e Transaction trx=session.beginTransaction(); statement after session =sessionFactory.openSession(); and commit the transaction after saving the session i,e trx.commit(); Correct code ---------------------------- package com.test; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; 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(); //Create new instance of Contact and set values in it by reading them from form object System.out.println("Inserting Record"); Transaction trx=session.beginTransaction(); Contact contact = new Contact(); contact.setId(3); contact.setFirstName("Deepak"); contact.setLastName("Kumar"); contact.setEmail("deepak_38@yahoo.com"); session.save(contact); trx.commit(); System.out.println("Done"); }catch(Exception e){ System.out.println(e.getMessage()); }finally{ // Actual contact insertion will happen at this step session.close(); } } }
rambharath
February 7, 2014
test mail

this too easy to understand for beginners.....tnks a lot.....
Meena Patel
September 2, 2013
Error

Could not parse mapping document from resource employee.hbm.xml Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource employee.hbm.xml Exception in thread "main" java.lang.NullPointerException at com.hibtutorial.mypackage.StoreData.main(StoreData.java:22)
DMCA.com