-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Newbie :
PostPosted: Thu Nov 20, 2003 12:59 am 
Newbie

Joined: Thu Nov 20, 2003 12:43 am
Posts: 1
Location: India
Dear All,
i have been following the article "Hibernate and Tomcat" Quick Start but am getting some errors and have followed the following steps

1) Have added the JDBC Driver to the global class path ( am using an Oracle Database)

2) Have placed hibernate.jar and all other jar files mentioned in Table 1 in the context class
path

3)Have done changes to the server.xml file for configuring the connection pool

4) Have created a hibernate.cfg.xml file at the context class path

5) I have created a persistent class Hibernate_Bean
package com.examples;

public class Hibernate_Bean
{

private String userId;
private String firstName;
private String lastName;
private String emailId;
private String address;

public void setUserId(String userId)
{
this.userId=userId;
}

public String getUserId()
{
return userId;
}

public void setFirstName(String firstName)
{
this.firstName=firstName;
}

public String getFirstName()
{
return firstName;
}

public void setLastName(String lastName)
{
this.lastName=lastName;
}

public String getLastName()
{
return lastName;
}

public void setEmailId(String emailId)
{
this.emailId=emailId;
}

public String getEmailId()
{
return emailId;
}

public void setAddress(String address)
{
this.address=address;
}

public String getAddress()
{
return address;
}
}

6) i already have a table in oracle with the following

Column Name Null? Type
------------------------------ -------- ----
USER_ID NOT NULL VARCHAR2(20)

PASSWORD VARCHAR2(30)
FIRST_NAME VARCHAR2(20)
LAST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(1000)

7) and this is the hibernate_bean.hbm.xml which has been
placed in the context path
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping.dtd">
<hibernate-mapping>
<class name="com.examples.Hibernate_Bean" table="users"></class>
<id name="ID" column="USER_ID" TYPE="String">
<generated class="assigned"/>
</id>

<property name="firstName" column="FIRST_NAME" type="String"/>
<property name="lastName" column="LAST_NAME" type="String"/>
<property name="password" column="PASSWORD" type="String"/>
<property name="emailId" column="E_MAIL" type="String"/>
<property name="address" column="ADDRESS" type="String"/>
</hibernate-mapping>

Q) What i want to ask you here is, is this file ok, i already have defined
the table i oracle, also i have a primary key which is the users login id in
the sytem and is the employee number and every employee has a pre-
defined employee number, what i want to tell you here is that is need
not be generated automatically.

8) Finally i would have to write a jsp file to insert the values into the database,
and this is the code for the jsp file

<%@page import="net.sf.hibernate.*,com.examples.*,javax.naming.*,javax.sql.*"%>
<html>
<head><title>JSP Page</title></head>
<body>

<%
Datastore ds=Hibernate.createDatastore();
ds.storeClass(Hibernate_Bean);

SessionFactory sf=ds.buildSessionFactory();
Session hsession=sf.openSession();


Hibernate_Bean hb=Hiberbate_Bean();
hb.setUserId("131313131");
hb.setFirstName("Krantiveer");
hb.setLastName("Shah");
hb.setEmailId("k@k.com");
hb.setAddress("Reliance Industries Limited");
hsession.save(hb);

hsession.close();

%>

</body>
</html>
and the error i am getting is ,could some one tell me how to rectify the same.
--------------------------------------------------------------------------------------
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\quickstart\Sample_jsp.java:53: cannot resolve symbol
[javac] symbol : class Datastore
[javac] location: class org.apache.jsp.Sample_jsp
[javac] Datastore ds=Hibernate.createDatastore();
[javac] ^
[javac] D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\quickstart\Sample_jsp.java:53: cannot resolve symbol
[javac] symbol : method createDatastore ()
[javac] location: class net.sf.hibernate.Hibernate
[javac] Datastore ds=Hibernate.createDatastore();
[javac] ^
[javac] D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\quickstart\Sample_jsp.java:54: cannot resolve symbol
[javac] symbol : variable Hibernate_Bean
[javac] location: class org.apache.jsp.Sample_jsp
[javac] ds.storeClass(Hibernate_Bean);
[javac] ^
[javac] D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\quickstart\Sample_jsp.java:60: cannot resolve symbol
[javac] symbol : method Hiberbate_Bean ()
[javac] location: class org.apache.jsp.Sample_jsp
[javac] Hibernate_Bean hb=Hiberbate_Bean();
[javac] ^
[javac] 4 errors

_________________
Regards,
amit malhotra,
Sr. Programmer,
Reliance Industries Limited,
India.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 1:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Looks like you have a wrong download or something. There is no Datastore class in Hibernate2.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.