Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Error - ; expected

 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
when i try to execute the code given below, its throwing compile time error
; expected, please help me
__________________________________

<%@ page import="java.sql.*" %>


<html>
<Body bgcolor=silver>
<br>
<%



String s1=null,s2=null,s3=null,s4=null,s5=null,s6=null;
String sqltext;

s1=request.getParameter("txtName");
s2=request.getParameter("txtAdnno");
s3=request.getParameter("selClass");
s4=request.getParameter("selSec");
s5=request.getParameter("txtDate");
s6=request.getParameter("txtAdnfee");



if(s1 !=null)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc dbc:Adn","","");
Statement st=con.createStatement();

sqltext="insert into AllIn ("Name, Adnno, Class, Section, Date, Adnfee") values ('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"' )";

st.executeUpdate(sqltext);
out.println("Inserted Successfully!");

}
catch(Exception e)
{
System.out.println(e);
}
}
else
{
%>

your data could not be inserted
<A HREF=Admission.html> Click Here </A> to Try again !
<%
}
%>

</body>
</html>
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
line 31 should be
sqltext="insert into AllIn (Name, Adnno, Class, Section, Date, Adnfee) values ('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"' )";
 
Sri Gnana
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Lalita

Thanks,
I have tried it but its giving syntax error, help me please!...
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the SQL statement is the problem:

"insert into AllIn ("Name, Adnno, Class, Section, Date, Adnfee") values ('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"' ";

Try

"insert into AllIn (Name, Adnno, Class, Section, Date, Adnfee) values ('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"' ";

I removed the "" for the column list (not needed).
 
Sri Gnana
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried it , now also i'm getting the same problem
Please help me
 
Sri Gnana
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please ANy One Help Me!
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


sqltext="insert into AllIn (Name, Adnno, Class, Section, Date, Adnfee) values ('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"' )";



You say you get a syntax error when you do this - is that at compile time, or when you run it? - i.e. is it a sql sytnax error?

What url are you using to test it?
 
Sheriff
Posts: 67634
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, it's clear at this point that is not a JSP issue but a JDBC syntax one. So I'm moving this to that forum.

But before you leave just let me interject that not abstracting database access out of the JSP is a serious crime against nature in my opinion.
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic