This problem is really killing me.
can you please check out all the programs i have written and find the error.
Student.jsp
<html>
<body>
<center><h2>Student Insertion Form</h2></center>
<form action="StudentInsert">
<table>
<tr>
<td>
Student No:
</td>
<td>
<input type="text" name="sno">
</td>
</tr>
<tr>
<td>
Student Name:
</td>
<td>
<input type="text" name="sname">
</td>
</tr>
<tr>
<td>
Student Email:
</td>
<td>
<input type="text" name="email">
</td>
</tr>
<tr>
<td>
Student Mobile:
</td>
<td>
<input type="text" name="mobile">
</td>
</tr>
<tr>
<td>
<input type="submit" value="Insert">
</td>
</tr>
</table>
</form>
</body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>
InsertStudent</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>InsertServlet</servlet-name>
<servlet-class>InsertStudent</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>InsertServlet</servlet-name>
<url-pattern>/StudentInsert</url-pattern>
</servlet-mapping>
</web-app>
hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- postgresql configuration -->
<property name="connection.url">
jdbc dbc:kishdsn</property>
<property name="connection.username">scott</property>
<property name="connection.password">tiger</property>
<property name="connection.driver_class">sun.jdbc.odbc.JdbcOdbcDriver</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<mapping resource="stud/student.hbm.xml" />
</session-factory>
</hibernate-configuration>
student.hbm.xml
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="stud">
<class name="Student" table="student">
<id name="sno" column="sno" type="java.lang.Integer">
<generator class="assigned"/>
</id>
<property name="sname" column="sname" type="java.lang.String" />
<property name="email" column="email" type="java.lang.String" />
<property name="mobile" column="mobile" type="java.lang.Integer"/>
</class>
</hibernate-mapping>
student.java
import java.io.Serializable;
public class Student implements Serializable
{
private int sno,mobile;
private
String sname,email;
public Student()
{
}
public void setSno(int sno)
{
this.sno=sno;
}
public void setSname(String sname)
{
this.sname=sname;
}
public void setEmail(String email)
{
this.email=email;
}
public void setMobile(int mobile)
{
this.mobile=mobile;
}
public int getSno()
{
return this.sno;
}
public String getSname()
{
return this.sname;
}
public String getEmail()
{
return this.email;
}
public int getMobile()
{
return this.mobile;
}
}
InsertStudent.java
import org.hibernate.*;
import org.hibernate.cfg.*;
public class InsertStudent
{
public static void main(String args[]) throws Exception
{
Configuration c=new Configuration();
c.configure("hibernate.cfg.xml");
SessionFactory sf=c.buildSessionFactory();
Session s=sf.openSession();
Transaction tx=s.beginTransaction();
Student sb=new Student();
sb.setSno(Integer.parseInt(args[0]));
sb.setSname(args[1]);
sb.setEmail(args[2]);
sb.setMobile(Integer.parseInt(args[3]));
s.save(sb);
s.flush();
tx.commit();
System.out.println("Record inserted");
s.close();
}
}