Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Problem in inserting data into access database through jsp file

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi all,
I am a second year student and this is my semester project worth 55% and i dont have much knowledge about making connection b/w html form and access database so i tried it doing with the help of jsp but it is not working this is my html code:

<html>
<head>
<title>Student Co-op Willingness Form</title>
</head>
<body>
<form name="myform" action="example5.jsp" method=post>
<table border=0>
<tr>
<td>TRU-ID/G.C.No:</td>
<td><input type="text" name="tid" size=15 /></td>
</tr>

<tr>
<td>Enrollment No.:</td>
<td><input type="text" name="enroll" size=15 /></td>
</tr>

<tr>
<td>Name:</td>
<td><input type="text" name="name" size=15/></td>
</tr>

<tr>
<td>Course:</td>
<td><input type="text" name="course" size=15/></td>
</tr>

<tr>
<td>Semester:</td>
<td><input type="text" name="semester" size=15/></td>
</tr>

<tr>
<td>Company:</td>
<td><input type="text" name="company" size=15/></td>
</tr>

<tr>
<td>Skills:</td>
<td><input type="text" name="skills" size=20/></td>
</tr>

<tr>
<td>Email:</td>
<td><input type="text" name="email" size=20/></td>
</tr>

<tr>
<td>Contact No.:</td>
<td><input type="text" name="contact" size=20/></td>
</tr>

<tr>
<td>Work-Term:</td>
<td><input type="radio" name="radwt" value="1" size="5" >1 </td>
</tr>
<tr>
<td></td>
<td><input type="radio" name="radwt" value="2" size="5">2</td>
</tr>
<tr>
<td></td>
<td><input type="radio" name="radwt" value="3" size="5">3</td>
</tr>

<tr>
<td>Willing to opt for co-op:</td>
<td><input type="radio" name="radwc" value="yes"size="5" >Yes </td>
</tr>
<tr>
<td></td>
<td><input type="radio" name="radwc" value="no" size="5">No </td>
</tr>


<tr>
<td style="text-align:left">Co-op Arrangement:</td>
<td style="text-align:left">
<select name="arrange">
<option value="On Your Own">On Your Own</option>
<option value="By Institute">By Institute</option>
</select>
</td>
</tr>

<tr>
<td></td>
</tr>

<tr>
<td></td>
</tr>

<tr>
<td></td>
</tr>

<tr>
<td><input type="submit" value="Submit"/></td>
<td><input type="reset" /></td>
</tr>
</table>
</form>
</body>
</html>



this is my jsp file:

<%@ page import="java.sql.*" %>
<%
String url = "jdbc:odbc:final";
Connection conn = null;
String classPath = "sun.jdbc.odbc.JdbcOdbcDriver";
try{
Class.forName(classPath);
conn = DriverManager.getConnection(url);
}catch(Exception exc){
out.println(exc.toString());
}
Statement stm=null;
String id;
String enroll;
String name;
String course;
String semester;
String company;
String skills;
String email;
String contact;
String workterm;
String willing;
String arrange;

id = request.getParameter("tid");
enroll = request.getParameter("enroll");
name = request.getParameter("name");
course = request.getParameter("course");
semester = request.getParameter("semester");
company = request.getParameter("company");
skills = request.getParameter("skills");
email = request.getParameter("email");
contact = request.getParameter("contact");
workterm = request.getParameter("radwt");
willing = request.getParameter("radwc");
arrange = request.getParameter("arrange");
stm= conn.createStatement();
String query = "INSERT INTO Student VALUES ("+ id +", " + enroll +", "+
name + "," + course +", "+ semester + ", "+ company +", " + skills +", "+
email + "," + contact +", "+ workterm + "," + willing +", "+
arrange + ")";
try{
stm.executeUpdate(query);
out.println("The data was added to the table successfully!");
}catch(Exception exc){
out.println("Inserting data failed!");
}
stm.close();
conn.close();
%>
<br><br><a href="coop.html">Add more record</a>
Please help me out. I am getting an error inserting data failed..... please please i have to submit it within two days

thanks,
kanwal
[ December 06, 2008: Message edited by: kanwal mandair ]
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Report post to moderator
Duplicate Post
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!