2016-02-10 97 views
-1
<%@page import="javax.servlet.*"%> 
<%@page import="java.sql.*"%> 
<%@page import="java.util.*"%> 
<%@page import="java.lang.Object.*"%> 
<%@page import="java.text.*"%> 
<% 
String empid=request.getParameter("Emp.Id"); 
String sname=request.getParameter("sname"); 
String designation=request.getParameter("designation"); 
String category=request.getParameter("category"); 
String dept=request.getParameter("dept"); 
java.util.Date d=new SimpleDateFormat("yyyy-MM- dd").parse(request.getParameter("dob")); 
java.sql.Date dob=new java.sql.Date(d.getTime()); 
String age=request.getParameter("age"); 
java.util.Date dj=new SimpleDateFormat("yyyy-MM-dd").parse(request.getParameter("doj")); 
java.sql.Date doj=new java.sql.Date(dj.getTime()); 
String gender=request.getParameter("gender"); 
String community=request.getParameter("community"); 
String education=request.getParameter("education"); 
String yoe=request.getParameter("yoe"); 
String pdoor=request.getParameter("pdoor"); 
String padd1=request.getParameter("padd1"); 
String padd2=request.getParameter("padd2"); 
String pcity=request.getParameter("pcity"); 
String ptaluk=request.getParameter("ptaluk"); 
String pdistrict=request.getParameter("pdistrict"); 
String ppcode=request.getParameter("ppcode"); 
String pstate=request.getParameter("pstate"); 
String cdoor=request.getParameter("cdoor"); 
String cadd1=request.getParameter("cadd1"); 
String cadd2=request.getParameter("cadd2"); 
String ccity=request.getParameter("ccity"); 
String ctaluk=request.getParameter("ctaluk"); 
String cdistrict=request.getParameter("cdistrict"); 
String cpcode=request.getParameter("cpcode"); 
String cstate=request.getParameter("cstate"); 
String email=request.getParameter("email"); 
String ms=request.getParameter("ms"); 
String noc=request.getParameter("noc"); 
String fsname=request.getParameter("fsname"); 
String fsocc=request.getParameter("fsocc"); 
String fsadd=request.getParameter("fsadd"); 
String fsmob=request.getParameter("fsmob"); 
Class.forName("com.mysql.jdbc.Driver"); 
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", 
     "root", "mysql23"); 
Statement st = con.createStatement(); 
int i=st.executeUpdate("insert into staffdetail(empid,sname,designation,category,dept,dob,age,doj,gender,community,education,yoe,pdoor,padd1,padd2,pcity,ptaluk,pdistrict,ppcode,pstate,cdoor,cadd1,cadd2,ccity,ctaluk,cdistrict,cpcode,cstate,emailid,mstatus,nchild,fsname,fsocc,fsaddress,fsmobile) values("+empid+",'"+sname+"','"+designation+"','"+category+"','"+dept+"','"+dob+"','"+age+"','"+doj+"','"+gender+"','"+community+"','"+education+"','"+yoe+"','"+pdoor+"','"+padd1+"','"+padd2+",'"+pcity+"','"+ptaluk+"','"+pdistrict+"','"+ppcode+"','"+pstate+"','"+cdoor+"','"+cadd1+"','"+cadd2+"','"+ccity+"','"+ctaluk+"','"+cdistrict+"','"+cpcode+"','"+cstate+"','"+email+"','"+ms+"','"+noc+"','"+fsname+"','"+fsocc+"','"+fsadd+"','"+fsmob+"')"); 
if(i>0) 
{ 
response.sendRedirect("over.jsp"); 
    } 
else 
{ 
response.sendRedirect("over1.jsp"); 
    } 

%> 

的錯誤是商店形式的信息使用JSP

javax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:你在你的SQL有 錯誤句法;檢查對應於您的手冊 MySQL服務器版本

+1

mysql類似乎並沒有被導入。請提供您的代碼。 –

回答

0

MySQL JDBC驅動程序不在你的運行時類路徑中。你首先需要從這裏下載JAR:

https://dev.mysql.com/downloads/connector/j/

然後,您需要將其複製到共享庫文件夾您的服務器/容器上(而不是與你的應用程序捆綁它 - Why must the JDBC driver be put in TOMCAT_HOME/lib folder?)。

確切位置在哪裏,這是取決於你的服務器上:

對於Tomcat 8副本的JAR到TOMCAT_HOME/lib目錄

對於碼頭9副本JAR到JETTY_HOME/lib/ext目錄。

+0

我已添加連接器jar file.few數據存儲時,我使手機號碼是commends.but當我嘗試存儲的所有值我越來越錯誤..例外是javax .servlet.ServletException:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL語法中有錯誤;檢查對應於您的MySQL服務器版本的手冊,以便在附近的街道,kurichi(po),'Bhavani(tk),erode(dt)','kurichi','bhavani','erode ','6383'在第1行....這裏這些地址是我在網頁中給出的 – VINU

0

mysql-jdbc-connector.jar應該被添加到您的項目中。 所以你的jsp將與MySql數據庫進行通信

+0

但現在我越來越像mysql syntex錯誤檢查適當的mannual爲您的mysql version.javax.servlet.ServletException:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您在您的SQL語法錯誤;檢查對應於您的MySQL服務器版本的手冊 – VINU