Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp error

 
Naresh Babu
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,
When i'm trying to insert a record into a table through JSP, while doing i'm getting this error
Error: Type Connection was not found.
Error: "DriverManager" is either a misplaced package name or a non-existent entity.
Error: Type Statement was not found
The code i am using is below
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc dbc:teexcel","","");
Statement st = con.createStatement();
st.executeUpdate("insert into Main values('xx','xx','xx','xx','xx','xx','xx','xx','xx','xx','xx','xx','xx','xx')");
}
catch (Exception e)
{
out.println("problems inserting");
}
%>

However when i use the same code above in a java file, its inserting the record. When i use JSP it is giving error.
Thank You and I appreciate your help in advance
Naresh Babu
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naresh,
Your import statements in .jsp file should be covered within <%@ page import... %> directives as below. Give it a try!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic