
I want stores data in to the databse table but it can't be stores it shows an error about sql exception.
blackberry.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>Blackberry & Datacard Asset</title>
<head>
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
<!--[if lte IE 7]>
<link rel="stylesheet" href="css/ie.css" type="text/css" charset="utf-8" />
<![endif]-->
</head>
<body>
<div id="header">
<a href="index.html" id="logo"><img src="images/EATON-Logo.gif" alt="LOGO" /></a>
<div id="navigation">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<li class="selected"><a href="Asset.html">Asset Allocation</a></li>
<li><a href="services.html">Contact</a></li>
<li><a href="solutions.html">About</a></li>
</ul>
</div>
<div id="search">
<form action="">
<input type="text" value="Search" class="txtfield" onblur="javascript:if(this.value==''){this.value=this.defaultValue;}"onfocus="javascript:if(this.value==this.defaultValue){this.value='';}" />
<input type="submit" value="" class="button" />
</form>
</div>
</div>
<!-- /#header -->
<div id="contents">
<div class="background">
<h3></h3>
<div id="contents">
<div class="background">
<h3></h3>
<p>
<a href="blackberry.html">BlackBerry & DataCards</a>.
</p>
<center>
<form name="form" action="bb.jsp" method="get">
<table cellpadding=12 cellspacing=6 border="1" bgcolor="#efefef" align="center">
<th bgcolor="#efefef" colspan=8>
<font size=5>BlackBerry & DataCards Asset</font> <br>
<font size=2 color="red"><sup>*</sup> Required Fields</font></th>
<tr bgcolor="#efefef">
<td valign=top>EID<b><sup>*</sup></b></td>
<td><input type="text" name="eid" value="" size=10
maxlength=10> <br>
</td>
</tr>
<tr bgcolor="#efefef">
<td valign=top>UserName<b><sup>*</sup></b></td>
<td><input type="text" name="usernm" value="" size=25
maxlength=10> <br>
</td>
</tr>
<tr bgcolor="#efefef">
<td valign=top>WS NUmber<b><sup>*</sup></b></td>
<td><input type="text" name="wsno" value="" size=25
maxlength=10> <br>
</td>
</tr>
<tr bgcolor="#efefef">
<td valign=top>Device<b><sup>*</sup></b></td>
<td><select name="device" id="course" style="width: 158px;">
<option value="Select">---- Select ----</option>
<option value = "Blackberry">BlackBerry</option>
<option value = "DataCards">DataCard</option>
</select> <br>
</td>
</tr>
<tr bgcolor="#efefef">
<td valign=top>Model<b><sup>*</sup></b></td>
<td><input type="text" name="model" value="" size=10
maxlength=10> <br>
</td>
</tr>
<tr bgcolor="#efefef">
<td valign=top>Service Provider<b><sup>*</sup></b></td>
<td><input type="text" name="service" value="" size=20
maxlength=10> <br>
</td>
</tr>
<tr bgcolor="#efefef">
<td valign=top>IMEI Number<b><sup>*</sup></b></td>
<td><input type="text" name="imei" value="" size=15
maxlength=10> <br>
</td>
</tr>
<tr bgcolor="#efefef">
<td valign=top>MEID Number<b><sup>*</sup></b></td>
<td><input type="text" name="meid" value="" size=10
maxlength=10> <br>
</td>
</tr>
<tr bgcolor="#efefef">
<td valign=top><br>
<input type="submit" name="add" value="AddNew" size=25></td>
<td valign=top><br>
<input type="reset" name="button" value="reset" size=25>
<br>
</td>
</tr>
</table>
</form>
</center>
<h3></h3>
<p>
<a href="laptop.html">Laptop & Desktop</a>
</p>
<h3></h3>
<p> <a href=""> HeadPhone</a> </p>
<p>
<b></b>
<a href="">Phone</a>.<br/><br/>
</p>
</div> </div>
</div>
</body>
</html>
**
bb.jsp
------
**
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@page import="java.sql.SQLException;"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
String eid = request.getParameter("eid");
String usernm = request.getParameter("usernm");
String wsno = request.getParameter("wsno");
String model = request.getParameter("model");
String service = request.getParameter("service");
String imei = request.getParameter("imei");
String meid = request.getParameter("meid");
Connection con = null;
PreparedStatement pstatement = null;
int updateQuery = 0;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:asset");
String Qry = "INSERT INTO blackberry&datacards(User_id,User_name,WS_no,Model,Service_Provider,IMEI,MEID) value(?,?,?,?,?,?,?))";
pstatement = con.prepareStatement(Qry);
pstatement.setString(1,eid);
pstatement.setString(2,usernm);
pstatement.setString(3,wsno);
pstatement.setString(5,model);
pstatement.setString(6,service);
pstatement.setString(7,imei);
pstatement.setString(8,meid);
updateQuery = pstatement.executeUpdate();
if(updateQuery != 0)
{%>
<br>
<TABLE style="background-color: #E3E4FA;"
WIDTH="30%" border="1">
<tr><th>Data is inserted successfully in database.</th></tr>
</table>
<%
}
}
catch(Exception e)
{
out.println("Failed to success");
}
pstatement.close();
con.close();
%>
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.