File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error - ; expected

 
Sri Gnana
Ranch Hand
Posts: 166
  • 0
  • Mark post as helpful
  • send pies
  • 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>
 
Lalita Sattavat
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Lalita

Thanks,
I have tried it but its giving syntax error, help me please!...
 
Catalin Merfu
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please ANy One Help Me!
 
Ivor Lithan
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic