hai
i am nireekshan
i am using mySql database in this i am create employe table
Now i am davalep One .HTML Page in this i am write the employe table fieldes-----------And write Jsp page inThis i write MYSQL CONNection code And Insert Prapared Staments
Now i am run TOMCat 5.0 Server,open .HTML page INSERT EMploye Fied Values Submet ok
next Work is Down NOT store data in database
plse see my program tell me any ERROR plse ...............
HTML..............>jsp.................;
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%
String vemp_code=request.getParameter("emp_code");
String vemp_name=request.getParameter("emp_name");
Connection conn = null;
ResultSet rs=null;
String url = "jdbc:mysql://localhost:3306/";
String driverName = "com.mysql.jdbc.Driver";
String userName = "roor";
String password = "root";
try{
Class.forName(driverName).newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/niree",userName,password);
Statement stmt = conn.createStatement();
stmt.executeUpdate("use newuser;");
out.println(" connection is established");
//Statement stmt = conn.createStatement();
//int val = //stmt.executeUpdate("INSERT employe VALUES(?,?)");
PreparedStatement pst;
pst=conn.prepareStatement(" insert into employe values(?,?)");
pst.setString(1,vemp_code);
pst.setString(2,vemp_name);
}
catch(Exception e){
System.out.println("error occured");
e.printStackTrace();
}
%>