aspose file tools*
The moose likes JDBC and the fly likes Error - ; expected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error - ; expected" Watch "Error - ; expected" New topic
Author

Error - ; expected

Sri Gnana
Ranch Hand

Joined: Apr 29, 2004
Posts: 166
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>


Thanks & Regards
Sri Gnana
Everythings Programmed!...
Lalita Sattavat
Greenhorn

Joined: May 31, 2004
Posts: 10
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

Joined: Apr 29, 2004
Posts: 166
Hi
Lalita

Thanks,
I have tried it but its giving syntax error, help me please!...
Catalin Merfu
Ranch Hand

Joined: May 26, 2004
Posts: 42
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).


Catalin Merfu<br /><a href="http://www.accendia.com" target="_blank" rel="nofollow">High Performance Java Networking</a>
Sri Gnana
Ranch Hand

Joined: Apr 29, 2004
Posts: 166
I have tried it , now also i'm getting the same problem
Please help me
Sri Gnana
Ranch Hand

Joined: Apr 29, 2004
Posts: 166
Please ANy One Help Me!
Ivor Lithan
Greenhorn

Joined: May 30, 2004
Posts: 10

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

Joined: Jan 10, 2002
Posts: 61661
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error - ; expected