wood burning stoves 2.0*
The moose likes Servlets and the fly likes how to solve class not found exception and data not insert in database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to solve class not found exception and data not insert in database" Watch "how to solve class not found exception and data not insert in database" New topic
Author

how to solve class not found exception and data not insert in database

tillu Sharma
Greenhorn

Joined: Dec 07, 2010
Posts: 8
dear friends,
i don't have remove class not find error......and servlet not inserted data in database............what kind of this problem ..friend solve this problem and give me suggestion...please

datatype in database is varchar2


Database class:

package work;
import java.sql.*;
public class Jdbc_Connection
{
public java.sql.Connection con=null;

public Connection getconnection()
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con = java.sql.DriverManager.getConnection("jdbcracle:thin:@localhost:1521:XE","system","password");
}
catch(Exception ex)
{
ex.printStackTrace();
return (null);
}
return con;
}



}





User_Servlet class:

package work;

import java.io.IOException;
import java.sql.*;
import java.sql.PreparedStatement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class User_Servlet
*/
public class User_Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public User_Servlet() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
try
{
int i;
Jdbc_Connection JConnection =new Jdbc_Connection();
System.out.println("Hello");
//Statement stmt=null;
String firstName = request.getParameter("Firstname");
String lastName = request.getParameter("Lastname");
String email = request.getParameter("Email");
String confirmEmail = request.getParameter("Confirm_Email");
String password = request.getParameter("Password");
Connection con = JConnection.getconnection();
PreparedStatement ps=con.prepareStatement("insert into USER_INFO values(?,?,?,?)");
ps.setString(3, email);
ps.setString(1, firstName);
ps.setString(2, lastName);
ps.setString(4,password);
i = ps.executeUpdate();
System.out.print(i);
// System.out.println("This is the SErvlet"+firstName);
//response.sendRedirect("/pages/signin.html");
javax.servlet.RequestDispatcher rd = null;
rd = request.getRequestDispatcher("/pages/signin.html");
rd.forward(request, response);
// con.close();
}
catch(Exception e)
{
System.out.println("i m in servlet exception......");

}
}

}
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

I don't follow. Are you saying you see an exception running this code or not?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
tillu Sharma
Greenhorn

Joined: Dec 07, 2010
Posts: 8
yes, exception is occur in this program..........
Sunny Bhandari
Ranch Hand

Joined: Dec 06, 2010
Posts: 448

I am asking you provide the stacktrace of the exception...


Java Experience
tillu Sharma
Greenhorn

Joined: Dec 07, 2010
Posts: 8
yes
 
jQuery in Action, 2nd edition
 
subject: how to solve class not found exception and data not insert in database