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