Advertisement
Guest User

Untitled

a guest
May 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1.     public static void insertSprint(String name, Date start, Date end,long duration, int proj_ID){
  2.         Connection con=null;
  3.        
  4.         try{
  5.             proj_ID=1;
  6.             Class.forName("com.mysql.jdbc.Driver");
  7.             con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root","");
  8.             Statement st = con.createStatement();
  9.             st.executeUpdate("insert into sprints (Title,Start_Date,End_Date,Duration,Proj_ID) values ('"+name+"',"+"'"+start+"',"+"'"+end+"',"+duration+","+proj_ID+")");
  10.         }
  11.        
  12.         catch(Exception e){
  13.             e.printStackTrace();
  14.         }
  15.        
  16.         finally{
  17.             try{
  18.                 if(con != null)
  19.                     con.close();
  20.             }
  21.             catch(Exception e){
  22.         }
  23.     }
  24.  
  25. }
  26.  
  27.  
  28.  
  29.             protected void onSubmit()
  30.             {
  31.                 String s_Name=(String)sprint.getObject();
  32.                 Date s_Date=(Date)start_Date.getObject();
  33.                 Date e_Date=(Date)end_Date.getObject();
  34.                 long diff = e_Date.getTime()-s_Date.getTime();
  35.                 long days = diff/(1000 * 60 * 60 * 24);
  36.  
  37.                 if(s_Name!=null && s_Date!=null && e_Date!=null)
  38.                 {
  39.                     MySQL.insertSprint(s_Name, s_Date, e_Date, days, 1);
  40.                     SprintResult sprintResult = new SprintResult(s_Name,days);
  41.                     setResponsePage(sprintResult);
  42.                    
  43.                 }
  44.                 else if(s_Date.getTime()>e_Date.getTime())
  45.                 {
  46.                     error("You can't end the sprint before it starts");
  47.                 }
  48.                 else
  49.                 {
  50.                     error("Please fill the required fields");
  51.                 }
  52.                
  53.                
  54.             }
  55.  
  56.  
  57. Error: com.mysql.jdbc.MysqlDataTrunction: Data trunction: Incorrect datetime value 'Thu May 13 00:00:00 EEST 2010 ' for column 'Start_Date' at row1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement