problem in storing data through TOMCAT6.0

hi friends i using TOMCAT6.0 and sql sever iam trying to store data but iam getting a below error kindly please rectify me asap thank a lot

HTTP Status 500 -

--

type Exception report

message

description The server encountered an internal error () that prevented it from fulfillingthis request.

exception

org.apache.jasper.JasperException: Unable to compileclassfor JSP:

An error occurred at line: 23 in the jsp file: /rajkumar/try2.jsp

Syntax error on tokens, delete these tokens

20:stmt = conn.createStatement();

21:out.println("statement Executed");

22:result = stmt.executeQuery("SELECT * FROM pur");

23:stmt.executeUpdate("Insert into pur(name,pno,age) values("kumar","342","32")");

24:out.println("result");

25:

26:}

Stacktrace:

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)

org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)

org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)

javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.

--

Apache Tomcat/6.0.10

program

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

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

<html>

<head>

<title>Obtaining a Connection</title>

</head>

<body>

<%

Connection conn =null;

ResultSet result =null;

Statement stmt =null;

try{

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

out.println("statement executed");

conn = DriverManager.getConnection("jdbc:odbc:sample","sa","pwd");

out.println("Statement 2 Executed");

stmt = conn.createStatement();

out.println("statement Executed");

result = stmt.executeQuery("SELECT * FROM pur");

stmt.executeUpdate("Insert into pur(name,pno,age) values("kumar","342","32")");

out.println("result");

}

catch (SQLException e){

System.out.println(e.getMessage());

}

%>

</body>

</html>

[3782 byte] By [KevinRaja] at [2007-11-26 21:33:35]
# 1

Do you not see anything wrong with this?

stmt.executeUpdate("Insert into pur(name,pno,age) values("kumar","342","32")");

Use single quotes around the values. Or better yet, use a prepared statement.

dcmintera at 2007-7-10 3:14:30 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Thank you but the driver is not get connected with the databaseconn = DriverManager.getConnection("jdbc:odbc:sample","sa","pwd"); out.println("Statement 2 Executed");
KevinRaja at 2007-7-10 3:14:30 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
iam getting a problem to connect in database this statement is not executedconn = DriverManager.getConnection("jdbc:odbc:sample","sa","pwd"); out.println("Statement 2 Executed");
KevinRaja at 2007-7-10 3:14:31 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

The problem you posted was "Unable to compile class for JSP" which is nothing to do with establishing a connection.

If you now have a different problem, please post the whole error message.

Assuming this really is a new problem, have you checked to make sure that the DSN called "sample" really exists and that it can be used to connect to the database. You should also make sure that it's set up for the appropriate user account if Tomcat is running as a service.

dcmintera at 2007-7-10 3:14:31 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...