
this is a jsp file . look at the line with code-> Statement st=con.createStatement(); in the below example. the error is "cannot convert from java.sql.Statement to com.mysql.jdbc.Statement please help me with it. thanks
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
Connection con = null;
Statement st=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = (Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/commondb", "root", "root123");
st=con.createStatement();
int i=st.executeUpdate("insert into contactinfo(title,name,cname,pos,req,emailId,phone1,phone2) values('"+t+"','"+n+"','"+cn+"','"+pos+"','"+req+"','"+eid+"',"+ph1+","+ph2+")");
out.println("Data is successfully inserted!");
//System.out.println("rows affected by insert "+st.executeUpdate(i));
}
catch(Exception e){
e.printStackTrace();
}
%>

1)form.jsp:
<html> <form method="post" action="insertdata.jsp"> <table> <tr><td>Username:</td><td><input type="text" name="uname"></td></tr> <tr><td>First Name:</td><td><input type="text" name="fname"></td></tr> <tr><td>Last Name:</td><td><input type="text" name="lname"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass"></td></tr> <tr><td>Address:</td><td><input type="text" name="address"></td></tr> <tr><td>Contact No:</td><td><input type="text" name="contact"></td></tr> <tr><td>Email:</td><td><input type="text" name="email"></td></tr> <tr><td></td><td><input type="submit" value="Submit"></td></tr> </table> </form> </html>
2)insertdata.jsp:
<%@page import="java.sql.*,java.util.*"%>
<%
String uname=request.getParameter("uname");
String fname=request.getParameter("fname");
String lname=request.getParameter("lname");
String pass=request.getParameter("pass");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st=con.createStatement();
int i=st.executeUpdate("insert into login(username,password,firstname,lastname,address,contactNo,email) values('"+uname+"','"+pass+"','"+fname+"','"+lname+"','"+address+"',"+contact+",'"+email+"')");
out.println("Data is successfully inserted into database.");
con.close();
}
catch(Exception e){
System.out.println(e);
}
%>

still the problem persists

Please specify your problem....

solved it . some problem with import..
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.