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

Recommended Answers

All 3 Replies

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

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.