Win a copy of Rust Web Development this week in the Other Languages forum!

umesh rawat

Ranch Hand
+ Follow
since Mar 03, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by umesh rawat

A Java developer from Cowes,
A java developer moments of Wows,
A Java developer is not in the nerdy Race
ready to make the world a better Place .
put the soul to learn all the Hows,



7 years ago
We have 3 databases , Db2 , oracle nad ms sql .
Our web application is connected with anyone of these at a time.
When Server is running (Web server- apache tomcat) and applicaiton is pointing to any DB .
The user can generate some report which basically hits the database.
for some report i need to change my system time.
i want to khow why we need to chnage the time.

12 years ago
JSP
my web application works fine with us and canada time but not with indian time.
what could be reason ?

12 years ago
JSP
these are 100 questions

[b]
and 100 % free
[/b]
http://100javaquestions.blogspot.com/

12 years ago
100 questions in java
see here

http://100javaquestions.blogspot.com

please give your comment
12 years ago


Hi all
if someone has some inheritance and polymorphim related hibernate examples .
please send me at -umeshrawat30@gmail.com

thanks



it is giging same fatal exception
while i have chaged hibernate2.jar


other programs are working propely ,
only diff is that i did not create a utill class for sessionFactory.
This is code of workign program



// this is working properly




package roseindia.tutorial.hibernate;

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

public class FirstExample {
public static void main(String[] args) {
Session session = null;

Transaction tx = 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(5);
contact.setFirstName("umesh5");
contact.setLastName("rawat5");
contact.setEmail("5umeshrawat30@gmail.com");
tx= session.beginTransaction();

session.save(contact);
//session.
System.out.println("Done");
contact.setFirstName("umesh5Changed");
session.update(contact);
tx.commit();
//session.commit();
}catch(Exception e){

System.out.println(e.getMessage());
}finally{
// Actual contact insertion will happen at this step
//session.flush();
//session.close();

}

}
}

================
contact.hbm

<?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" mutable="false" >
<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>
=========











hibernate.cfg.xml

<?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/test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.pool_size">1</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"/>
<mapping resource="insurance.hbm.xml"/>
<mapping resource="book.hbm.xml"/>

</session-factory>
</hibernate-configuration>
==================






Contact .java




package roseindia.tutorial.hibernate;

/**
* @author Deepak Kumar
*
* http://www.roseindia.net
* 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 email) {
this.email = email;
}

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

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

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

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

}
==




This is the console report
-------------------------------------------








log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
java.lang.ExceptionInInitializerError
at GroupTest.main(GroupTest.java:16)
Caused by: java.lang.RuntimeException: SessionFactory Error - Dialect class not found: net.sf.hibernate.dialect.MySQLDialect
at HibernateSession.<clinit>(HibernateSession.java:13)
... 1 more
Caused by: org.hibernate.HibernateException: Dialect class not found: net.sf.hibernate.dialect.MySQLDialect
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:81)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:409)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:119)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2006)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1289)
at HibernateSession.<clinit>(HibernateSession.java:11)
... 1 more
Exception in thread "main"

Note- this example is from professional hibernate wrox publication chapter 10

whenever i am doing a program with two tables having a relationship .
Eclipse is showing fatal exception .


when i am running this program
it is giving fatal excepiton .
follwoing are the files





group.java


import java.util.*;

public class Group {
private int id;
private String name;
private List stories;

public Group(){
}

public Group(String name) {
this.name = name;
}

public void setId(int i) {
id = i;
}

public int getId() {
return id;
}

public void setName(String n) {
name = n;
}

public String getName() {
return name;
}

public void setStories(List l) {
stories = l;
}

public List getStories() {
return stories;
}
}
===================================
story.java

import java.util.*;

public class Story {
private int id;
private String info;

public Story(){
}

public Story(String info) {
this.info = info;
}

public void setId(int i) {
id = i;
}

public int getId() {
return id;
}

public void setInfo(String n) {
info = n;
}

public String getInfo() {
return info;
}
}
====================================
HibernateSession.java


import org.hibernate.*;
import org.hibernate.cfg.*;


public class HibernateSession {
private static final SessionFactory sessionFactory;

static {
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (HibernateException e) {
throw new RuntimeException("SessionFactory Error - " + e.getMessage(), e);
}
}

public static final ThreadLocal session = new ThreadLocal();

public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();

if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}

return s;
}

public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session. set(null);
if (s != null)
s.close();
}
}
============================
hibernet.cfg.xml


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

<hibernate-configuration>

<session-factory>
<property name="connection.driver">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/test</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<mapping resource="Group.hbm.xml"/>

</session-factory>

</hibernate-configuration>============================
GroupTest.java

import java.io.*;
import java.util.*;


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


public class GroupTest {

public static void main(String [] args) {

try {
Session session = HibernateSession.currentSession();

Group sp = new Group("accouting");

ArrayList list = new ArrayList();
list.add(new Story("A Story"));
list.add(new Story("And yet another story"));
sp.setStories(list);

Transaction transaction = null;

try {
transaction = session.beginTransaction();

session.save(sp);

transaction.rollback();
} catch (Exception e) {
if (transaction != null) {
transaction.rollback();
throw e;
}
} finally {
session.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

=======================================



group.xml

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

<hibernate-mapping>

<class name="Group"
table="grouptable">
<id name="id" unsaved-value="0">
<generator class="native"/>
</id>

<list name="stories" cascade="all">
<key column="parent_id"/>
<index column="idx"/>
<one-to-many class="Story"/>
</list>
<property name="name" type="string"/>
</class>
<class name="Story"
table="story">
<id name="id" unsaved-value="0">
<generator class="native"/>
</id>
<property name="info"/>
</class>


</hibernate-mapping>
=======================================
< put here >
< put here > com.example.my Listener </ put here >
< put here >


from this list


class , listerner-resource ,

listener ,,, sevlet -listener ,
context-listener, listerner-class ,
class -name , resource- class


1 jspInit is called
2 jsp page implementation class is loaded
3 jsp page is complied
4 jspdestroy is called
5 jsp page implementation is instantiate
6 jsp page is translated
7 _jspService is called

----------------------------
Hi all
i want to know that what is diffidence between these papers.
i have one book ( for 310-081 by david bridewater )
is it sufficient for this certification,
at the end of this month i will go for this paper .

please give the answer asap.
thanks in advance .

umesh
There are many simulation program in the market ,
like whizlab , enthuware etc
i want to know which one is the best for this paper.

which mock exam paper is the best
where can i get whole information of this paper
1 - diff between0310- 82, and 83
i have 0310-82 book (author -david bridgewater dreamtake publish ion )
is it sufficient ?