Home > database >  Invalid url <- the pattern> [KaochaCorrectServlet] in the servlet mapping
Invalid url <- the pattern> [KaochaCorrectServlet] in the servlet mapping

Time:09-20

The debug is correct, the SQL statement is correct, I can insert, after a can't insert,
Public void submit (Kaocha Kaocha, String [] Kaochaxingming) {


Try {
DBconnect. The init ();
} the catch (Exception e) {
e.printStackTrace();
}
KaochaDaoImplement kaocha1=new KaochaDaoImplement ();
String SQL="insert into ins_travel_arrange (leader, judger, drawers, iarrange inumber, state, accomplishman, sdate, edate) values (" + kaocha. GetLnumber () +", "+ kaocha. GetJudger_number () +", "+ kaocha. GetJudger_number () +", "" + kaocha. GetIarrange () +" ", "+ kaocha. GetKaocha_id () +", "" + kaocha. GetState () +" ', '" + kaocha. GetAccomplishman () + "', '" + kaocha. GetSdate1 () + "', '" + kaocha. GetEdate1 () + "")";
DBconnect. AddUpdateDelete (SQL);
DBconnect. CloseConn ();
For (int a=0; a{
Try {
DBconnect. The init ();
} the catch (Exception e) {
e.printStackTrace();
}

Int kaochaxingming=kaocha1. Search_by_name (kaochaxingming [0]).
String sql1="insert into serch_peple_table (inumber penumber) values (" + kaocha. GetKaocha_id () +", "+ kaochaxingming +") ";
DBconnect. AddUpdateDelete (sql1);
DBconnect. CloseConn ();
}


DBconnect. CloseConn ();
}



DBconnect
Package com. Util;

import java.sql.*;

Public class DBconnect
{
The static String url="JDBC: mysql://localhost: 3306/lingdao10001? UseUnicode=true& CharacterEncoding=utf-8 ";
The static String user="root";
The static String pw="";
The static Connection conn=null;
The static PreparedStatement ps=null;
The static ResultSet rs=null;
The static Statement st=null;

Public static void init () throws SQLException, ClassNotFoundException {//SQl program initialization
Try {
Class.forname (". Com. Mysql. JDBC Driver ");//registration drive
Conn=DriverManager. GetConnection (url, user, pw);//connect
} the catch (Exception e) {
System. The out. Println (" SQL program initialization failed ");
e.printStackTrace();
}
}

Public static int addUpdateDelete (String SQL) {
int i=0;
Try {
Ps=conn. PrepareStatement (SQL);
A Boolean flag=ps. The execute ();
//if the first result is the result set object, it returns true; If the first result is updated count or not as a result, it returns false
If (flag==false) {
i++;
}
} the catch (Exception e) {
System. The out. Println (increasing the deletion anomalies "database");
e.printStackTrace();
}
return i;
}

Public static ResultSet selectSql (String SQL) {
Try {
Ps=conn. PrepareStatement (SQL);
Rs=ps. ExecuteQuery ();

} the catch (Exception e) {
System. The out. Println (" database query exception ");
e.printStackTrace();
}
return rs;
}

Public static void closeConn () {
Try {
Conn. Close ();
} the catch (Exception e) {
Abnormal shutdown System. Out. Println (" ");
e.printStackTrace();
}
}
}
  • Related