0

Hi all,

I am getting this error:java.lang.ClassNotFoundException: sun:jdbc:odbc:JdbcOdbcDriver .

when i run my jsp code

<html>
<head><title>registration page</title></head>
<body>
<%@ page import="javax.sql.*,java.sql.*,javax.servlet.*,javax.servlet.http.*"%>
<%! String firstname1;String lastname1;String email1;String address1; String state1; String password1; int phno1;String cpassword1;%>
<% String firstname1 = request.getParameter("fname"); %>
<% String lastname1 = request.getParameter("lname"); %>
<% String email1 = request.getParameter("email"); %>
<% String phno1 = request.getParameter("phno"); %>
<% String address1 = request.getParameter("address"); %>
<% String state1 = request.getParameter("state"); %>
<% String password1 = request.getParameter("password"); %>
<% String cpassword1 = request.getParameter("cpassword"); %>

<%
   try
   {
	   Class.forName("sun:jdbc:odbc:JdbcOdbcDriver");
	   Connection con=DriverManager.getConnection("jdbc:odbc:Ldsn","","");
	   PreparedStatement ps;
	   	 Statement stmt = con.createStatement(); // to create a statement
		 ResultSet rs = stmt.executeQuery("select * from registration_tabl " ); // to execute a query 
                                        
	   String stm = "insert into registration_table values(?,?,?,?,?,?,?,?)";
	   ps = con.prepareStatement(stm);
	   ps.setString(1,"firstname1");
	   ps.setString(2,"lastname1");
	   ps.setString(3,"email1");
	   ps.setString(4,"phno1");
	   ps.setString(5,"address1");
	   ps.setString(6,"state1");
	   ps.setString(7,"password1");
	   ps.setString(8,"cpassword1");
	   int x=ps.executeUpdate();

	  		rs.close();
			con.close();
			stmt.close();

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

  		<h1 align="center" style="color:blue">successfully  registered</h1>
                		<br><a href="index.html"><h3 align="center" >click here to login</h3></a><br>
                			
 
</body>
</html>

i am using ms access as my database ....so how to debug this error...i dint set any classpath for this.


thanks

3
Contributors
3
Replies
7
Views
7 Years
Discussion Span
Last Post by ishlux
0

Did you downloaded that driver and included in your project?

PS: Try to avoid using excessive of scriplets and DB connection should be managed through servlet called class

0

Take a look - package1.package2.package3.ClassName,

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

Hi all,
I have that jsp syntax in my code.... but some one said to load the driver , means what should i do........and to set class path for jar file..............i dint understand how to proceed, please tel me..
i am still getting this error.

Thanks
ishlux

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.