I feel this is simple but.....I cant Run my Application

[nobr]Hi

I have written a simple jsp application. which is used to user interaction.

It will the data from browser and insert into data base.

The actual problem is i cant insert the data . I did't get the logical problem. But i not insert the data.

here the full code

userform.

<%@ page language="java" %>

<html>

<head>

<title>

Gazetteer Database Access Test - JSP/MySQL

</title>

</head>

<body>

<h1>

Gazetteer Database Access Test - JSP/MySQL

</h1>

<form action="accessdata.jsp" method=get>

A simple example to find information about a place in

the United Kingdom. <br>

<br>

<br>

Enter name :

<input type=text name=name><br>

<br>

Enter The code :

<input type=text name=code><br>

<br>

Enter The City :

<input type=text name=city><br>

<br>

<br>

Enter the Qualification :

<select name="qus" VALUE="ss">

<option selected>MCA</option>

<option>MCOM</option>

<option>MA</option>

<option >Msc</option>

</select>

<input type=submit value="Search database">

</form>

</body>

</html>

Here is

accessdata.jsp

<html>

<head>

<%@ page

import ="java.io.*"

import ="java.lang.*"

import ="java.sql.*"

%>

<title>

JSP Example 2

</title>

</head>

<body>

<h1>JSP Example 3</h1>

<%

Stringplace;

Connection dbconn;

ResultSet results;

PreparedStatement sql;

ResultSet rs=null;

Statement stmt=null;

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

dbconn = DriverManager.getConnection("jdbc:odbc:webtogo","system","manager");

try

{

String code="";

String name="";

String city="";

String qualification="";

String query="";

booleandoneheading =false;

//dbconn = DriverManager.getConnection("jdbc:mysql://clun.scit.wlv.ac.uk/mydatabase","demo","");

name = request.getParameter("name");

code=request.getParameter("code");

city=request.getParameter("city");

qualification=request.getParameter("qus");

System.out.println("after getting values ");System.out.println("after getting values "+code);

System.out.println("after getting values "+city);

query="insert into temp (name,code,city,qualifcation) values('"+name+"',"+code+",'"+city+"','"+qualification+"')";

stmt=dbconn.createStatement();

stmt.executeUpdate(query);

/*stmt.setString(1,name);

stmt.setInt(2,Integer.parseInt(code));

stmt.setString(3,city);

stmt.setString(4,qualification);*/

System.out.println(query);

System.out.println("NAME OF THE EMPLOYEE"+name);

System.out.println("CODE NO"+code);

System.out.println("CITY"+city);

System.out.println("QUALIFICATION"+qualification);

dbconn.commit();

if(dbconn!=null)

{

dbconn.close();

}

out.println("SUCCESS FULLY ADDED ONE RECORD");

}

catch(Exception ee)

{

System.out.println("SQL ERROR in inner TRY BLOCK");

ee.printStackTrace();

out.println("SQL error" +ee.toString());

}

}

catch (Exception e)

{

out.println("Class loading error"+e.toString());

}

%>

</body>

</html>

Please clear my confusions that what is Error on the above code

Thankx

MerlinRoshina[/nobr]

[5579 byte] By [MerlinRosinaa] at [2007-10-2 10:56:32]
# 1
I think there is some quote problem in your query near code variable.If you think its ok the use stmt.execute(query);
Innovaa at 2007-7-13 3:21:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...