Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-02-2008, 12:03 PM
Member
 
Join Date: Jan 2008
Posts: 4
rhlpnt is on a distinguished road
how to call data from MySQL
hi,my teacher asked me to make a Response Form.It contains 20 question. It has multiple choices. choice will vary from 3 to 6.I have to make it with help of jsp.Question will be filled by other person i have to make database in mysql.i m facing problem in how to retrieve data from table.I donot know how to call i all question. Can u help me to out...i using hibernate too...which is al follow...
this is JSP page.
<%
Long id=Long.valueOf(request.getParameter("id"));
Question q=(Question) com.ats.survey.utils.HibernateUtils.currentSession ().get(Question.class, id);

if (q==null){
String page_forward="serial.jsp";
String message= " you have not entered wrong serial Number";
}
%>

<html>
<head>
<title> ATS EMPLOYEE SURVEY </title>
</head>
<body>
<h1 align="center"> RESPONSE FORM </h1>
<form action="thanks.jsp" method="POST" name="responseform">
<table>
<tr>
<td>S.No.<%=q.getSerialNumber()%></td>
<td>Question:<%=q.getQuestions()%></td>
<td>Resonse Caption 1:</td>
<td>Response 1:<input type="radio" name="group1"></td>
<td>Resonse Caption 2:</td>
<td>Response 2:<input type="radio" name="group1"></td>
<td>Resonse Caption 3:</td>
<td>Response 3:<input type="radio" name="group1"></td>
<td>Resonse Caption 4:</td>
<td>Response 4:<input type="radio" name="group1"></td>
<td>Resonse Caption 5:</td>
<td>Response 5:<input type="radio" name="group1"></td>
<td>Resonse Caption 6:</td>
<td>Response 6:<input type="radio"name="group1"></td>
</tr>
</table>

<br><input type="submit" value="SUBMIT" />
</form>
</body>
</html>

my java class
ublic class Question {

// This id for hibernate mapping
long id;
//DEFINE DATA TYPE
String questions;
long serialNumber;
//resp for response cap for caption
String resp1Caption;
String resp2Caption;
String resp3Caption;
String resp4Caption;
String resp5Caption;
String resp6Caption;
char resp1;
char resp2;
char resp3;
char resp4;
char resp5;
char resp6;

// HERE GETTER AND SETTER FUNCTION FOR ALL DATA TYPE

public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}

public String getQuestions() {
return questions;
}
public void setQuestions(String questions) {
this.questions = questions;
}
public long getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(long serialNumber) {
this.serialNumber = serialNumber;
}
public String getResp1Caption() {
return resp1Caption;
}
public void setResp1Caption(String resp1Caption) {
this.resp1Caption = resp1Caption;
}
public String getResp2Caption() {
return resp2Caption;
}
public void setResp2Caption(String resp2Caption) {
this.resp2Caption = resp2Caption;
}
public String getResp3Caption() {
return resp3Caption;
}
public void setResp3Caption(String resp3Caption) {
this.resp3Caption = resp3Caption;
}
public String getResp4Caption() {
return resp4Caption;
}
public void setResp4Caption(String resp4Caption) {
this.resp4Caption = resp4Caption;
}
public String getResp5Caption() {
return resp5Caption;
}
public void setResp5Caption(String resp5Caption) {
this.resp5Caption = resp5Caption;
}
public String getResp6Caption() {
return resp6Caption;
}
public void setResp6Caption(String resp6Caption) {
this.resp6Caption = resp6Caption;
}
public char getResp1() {
return resp1;
}
public void setResp1(char resp1) {
this.resp1 = resp1;
}
public char getResp2() {
return resp2;
}
public void setResp2(char resp2) {
this.resp2 = resp2;
}
public char getResp3() {
return resp3;
}
public void setResp3(char resp3) {
this.resp3 = resp3;
}
public char getResp4() {
return resp4;
}
public void setResp4(char resp4) {
this.resp4 = resp4;
}
public char getResp5() {
return resp5;
}
public void setResp5(char resp5) {
this.resp5 = resp5;
}
public char getResp6() {
return resp6;
}
public void setResp6(char resp6) {
this.resp6 = resp6;
}

}

configration file..
<?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>
<class name="com.ats.custFlight.pojo.CustomerDetail" table="CUSTOMERTABLE" lazy="false">
<id name="id" column="ID">
<generator class="increment" />
</id>
<property column="S_NO" name="serialNumber"/>
<property column="QUESTION_DETAILS" name="questions"/>
<property column="RESPONSE1" name="resp1"/>
<property column="RESPONSE1_CAPTION" name="resp1Caption"/>
<property column="RESPONSE2" name="resp2"/>
<property column="RESPONSE2_CAPTION" name="resp2Caption"/>
<property column="RESPONSE3" name="resp3"/>
<property column="RESPONSE3_CAPTION" name="resp3Caption"/>
<property column="RESPONSE4" name="resp4"/>
<property column="RESPONSE4_CAPTION" name="resp4Caption"/>
<property column="RESPONSE5" name="resp5"/>
<property column="RESPONSE5_CAPTION" name="resp5Caption"/>
<property column="RESPONSE6" name="resp6"/>
<property column="RESPONSE6_CAPTION" name="resp6Caption"/>

</class>
</hibernate-mapping>

thnk you
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem inserting values to MySQL tables from the Data Source Explorer tip Eclipse 0 12-24-2007 10:47 AM
how to call a dll from java katie Advanced Java 3 12-10-2007 11:34 AM
MySQL 5.0 data backup from java sanjay_sharma77 Database 1 11-06-2007 01:19 PM
I need to call and run another program coco Advanced Java 1 07-31-2007 06:47 AM
How To Call EJB From Eclipse IDE JavaForums Eclipse 0 04-26-2007 11:15 AM


All times are GMT +3. The time now is 01:03 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org