daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <%@page language="java" contentType="text/html; charset=ISO-8859-1"
  2.    pageEncoding="ISO-8859-1"%>
  3.   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  4.    "http://www.w3.org/TR/html4/loose.dtd">
  5.  
  6.    <html>
  7.      <head>
  8.       <meta http-equiv="Content-Type" content="text/html" >
  9.       <title>Insert title here</title>
  10.     </head>
  11.  
  12.     <body>
  13.       <form  id="myform" method="post" action="spkr">
  14.          <label>First Name</label>
  15.             <input type="text" name="fname" >
  16.          <label">Last Name</label>
  17.             <input type="text" name="lname" >
  18.          <label>DOB</label>
  19.             <input type="text" name="dob"/ >
  20.          <label >Gender</label>                    
  21.             <input type="radio" name="optionradio" id="optionsRadios1"
  22.              value="Male" checked="">Male
  23.            <input type="radio" name="optionradio" id="optionsRadios2"
  24.             value="Female">Female
  25.  
  26.          <label >Emailid</label>
  27.             <input type="text" name="mail" placeholder="">
  28.  
  29.          <label>Achivements</label>
  30.             <input type="text" name="ach" placeholder="organization">
  31.  
  32.          <label> Skills</label>
  33.              <input type="text" name="skill" placeholder="">
  34.  
  35.          <label>Pincode</label>
  36.              <input type="text" name="pcode"/>
  37.  
  38.          <label>Organization</label>    
  39.              <input type="text" name="organization"
  40.               placeholder="organization">
  41.  
  42.              <input type="submit">Submit</input>
  43.  
  44.        </form>
  45.    </body>
  46.  </html>
  47.    
  48. Spkr.java
  49.  
  50.  package com.spkr.DO;
  51.  import javax.persistence.Entity;
  52.  import javax.persistence.Id;
  53.  
  54.  @Entity
  55.  public class Spkr {
  56. @Id
  57. private String fname;
  58. private String lname;
  59. private String gen;
  60. private String mail;
  61. private String ach;
  62. private String skill;
  63. private String org;
  64.  
  65. public Spkr(){
  66.  
  67. }
  68.  
  69. public Spkr( String fname, String lname, String gen, String mail, String ach, String skill, String org) {
  70.     super();
  71.  
  72.     this.fname = fname;
  73.     this.lname = lname;
  74.     this.gen = gen;
  75.     this.mail = mail;
  76.     this.ach = ach;
  77.     this.skill = skill;
  78.     this.org = org;
  79. }
  80.  
  81.  
  82. public String getFname() {
  83.     return fname;
  84. }
  85. public void setFname(String fname) {
  86.     this.fname = fname;
  87. }
  88. public String getLname() {
  89.     return lname;
  90. }
  91. public void setLname(String lname) {
  92.     this.lname = lname;
  93. }
  94. public String getGen() {
  95.     return gen;
  96. }
  97. public void setGen(String gen) {
  98.     this.gen = gen;
  99. }
  100. public String getMail() {
  101.     return mail;
  102. }
  103. public void setMail(String mail) {
  104.     this.mail = mail;
  105. }
  106. public String getAch() {
  107.     return ach;
  108. }
  109. public void setAch(String ach) {
  110.     this.ach = ach;
  111. }
  112. public String getSkill() {
  113.     return skill;
  114. }
  115. public void setSkill(String skill) {
  116.     this.skill = skill;
  117. }
  118. public String getOrg() {
  119.     return org;
  120. }
  121. public void setOrg(String org) {
  122.     this.org = org;
  123. }
  124. }
  125.    
  126. package com.spkr.service;
  127.  import com.spkr.DO.Spkr;
  128.  public interface SpeakerAddService {
  129.  public void add(Spkr s);
  130.  }
  131.    
  132. package com.spkr.service;
  133. import org.springframework.beans.factory.annotation.Autowired;
  134. import com.spkr.DO.Spkr;
  135. import com.spkr.dao.SpeakerDao;
  136.  
  137. public class SpeakerAddServiceImpl implements SpeakerAddService{
  138.  
  139. @Autowired
  140. SpeakerDao sas;
  141.  
  142. public SpeakerAddServiceImpl() {
  143.     super();
  144.     // TODO Auto-generated constructor stub
  145. }
  146.  
  147.     public void add(Spkr s) {
  148.  
  149.  
  150.     //System.out.println(fname +" "+skill);
  151.     System.out.println("Hi service");
  152.     System.out.println(s.getMail()+" "+s.getLname()+" "+s.getGen()+"
  153.   "+s.getAch());
  154.     System.out.println(s.getFname()+" "+s.getSkill());
  155.     sas.addSpeaker(s);
  156. }}
  157.    
  158. package com.spkr.dao;
  159.  import com.spkr.DO.Spkr;
  160.  public interface SpeakerDao {
  161.  public void addSpeaker(Spkr s);
  162.   }
  163.    
  164. package com.spkr.dao;
  165.  
  166.   import org.hibernate.Session;
  167.   import org.hibernate.SessionFactory;
  168.   import org.hibernate.Transaction;
  169.   import org.hibernate.cfg.AnnotationConfiguration;
  170.   import org.springframework.beans.factory.annotation.Autowired;
  171.  
  172.   import com.spkr.DO.Spkr;
  173.  
  174.   public class SpeakerDaoImpl implements SpeakerDao{
  175.  
  176.    @Autowired()
  177.    public SpeakerDaoImpl(SessionFactory sessionFactory) {
  178.     this.sessionfactory = sessionFactory;
  179.     }
  180.   private SessionFactory sessionfactory;
  181.    public void addSpeaker(Spkr s) {
  182.     // TODO Auto-generated method stub
  183.     System.out.println("Hi database");
  184.     System.out.println(s.getAch()+" "+s.getFname()+" "+s.getGen()+"
  185.    "+s.getLname()+" "+s.getMail()+" "+s.getOrg()+" "+s.getSkill());
  186.     /*Session session = sessionfactory.getSessionFactory().openSession();
  187.     session.save(s);*/
  188.     @SuppressWarnings("deprecation")
  189.     Session session = sessionfactory.getSessionFactory().openSession();
  190.     session.beginTransaction();
  191.  
  192.     session.save(s);
  193.     session.getTransaction().commit();
  194.  
  195.     System.out.println("one record friend--");
  196. }
  197.  
  198.  }
  199.    
  200. <?xml version="1.0" encoding="UTF-8"?>
  201.  
  202.     <beans:beans xmlns:mvc="http://www.springframework.org/schema/mvc"
  203.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  204.     xmlns:beans="http://www.springframework.org/schema/beans"
  205.     xmlns:context="http://www.springframework.org/schema/context"
  206.     xsi:schemaLocation="http://www.springframework.org/schema/mvc
  207.     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
  208.     http://www.springframework.org/schema/beans  
  209.     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  210.     http://www.springframework.org/schema/context
  211.     http://www.springframework.org/schema/context/spring-context-3.0.xsd
  212.     http://www.springframework.org/schema/tx
  213.     http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
  214.  
  215.   <mvc:annotation-driven />
  216.   <context:annotation-config/>
  217.  
  218.   <context:component-scan base-package="com.spkr.controller">
  219.   </context:component-scan>
  220.  
  221.  <beans:bean
  222.  
  223.  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  224.    <beans:property name="prefix" value="/WEB-INF/jsp/"></beans:property>
  225.   <beans:property name="suffix" value=".jsp"></beans:property>
  226.   </beans:bean>
  227.  
  228.   <beans:bean id="speakerAddService"
  229.   class="com.spkr.service.SpeakerAddServiceImpl"/>    
  230.   <beans:bean id="s" class="com.spkr.dao.SpeakerDaoImpl"/>  
  231.  
  232.  <beans:bean id="sessionFactory"
  233. class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  234.  
  235. <beans:property name="dataSource" ref="dataSource" />
  236.  
  237.  
  238.  
  239.  
  240.  
  241.           <beans:property name="hibernateProperties">
  242.                  <beans:props>
  243.                        <beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</beans:prop>
  244.                        <beans:prop key="hibernate.current_session_context_class">thread</beans:prop>
  245.                        <beans:prop key="hibernate.show_sql">true</beans:prop>
  246.                  </beans:props>
  247.           </beans:property>
  248.  
  249.           <beans:property name="annotatedClasses">
  250.         <beans:list>
  251.               <beans:value>com.spkr.DO.Spkr</beans:value> <!-- Entity classes-->
  252.  
  253.         </beans:list>
  254.         </beans:property>
  255.    </beans:bean>
  256.  
  257.  <beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
  258.   destroy-method="close">
  259.           <beans:property name="driverClassName"
  260.   value="com.mysql.jdbc.Driver" />
  261.           <beans:property name="url"
  262.   value="jdbc:mysql://localhost:3306/student" />
  263.           <beans:property name="username" value="root" />
  264.           <beans:property name="password" value="root" />
  265. </beans:bean>
  266.  
  267. </beans:beans>
  268.    
  269. <!DOCTYPE web-app PUBLIC
  270. "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  271.  "http://java.sun.com/dtd/web-app_2_3.dtd" >
  272.  
  273.  <web-app>
  274.  
  275.  <display-name>Archetype Created Web Application</display-name>
  276.  
  277.  <servlet>
  278.  <servlet-name>spkr</servlet-name>
  279.  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-
  280.  class>
  281.  <init-param>
  282.     <param-name>contextConfigLocation</param-name>
  283.     <param-value>/WEB-INF/spkr-servlet.xml</param-value>
  284. </init-param>
  285.  <load-on-startup>1</load-on-startup>
  286.  </servlet>
  287.  
  288.  <servlet-mapping>
  289.    <servlet-name>spkr</servlet-name>
  290.    <url-pattern>/</url-pattern>
  291.  </servlet-mapping>
  292.  
  293.  </web-app>
  294.    
  295. nested exception is org.hibernate.exception.GenericJDBCException: Unable to
  296.  acquire JDBC Connection
  297.  
  298.  Root cause
  299.  org.apache.commons.dbcp.SQLNestedException: Cannot create
  300.  PoolableConnectionFactory (initializeConnection: connection closed)  
  301.  
  302.  Root cause
  303.  java.sql.SQLException: initializeConnection: connection closed
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top