<%
MultipartRequest m=new MultipartRequest(request,"D:\\Adv.java\\SessionTrackingProcess\\Farmer Scheme Informer\\WebContent\\news",1024*1024*1024);
String file=m.getFilesystemName("file");
String des=m.getParameter("description");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dbfarm","root","root");
String query="insert into news (name,pname) values (?,?)";
PreparedStatement ps=con.prepareStatement(query);
ps.setString(1,"news/"+file);
ps.setString(2,des);
int done=ps.executeUpdate();
int cnt=1;
if(done>0)
{
out.print("News is added Successfully");
response.sendRedirect("news.jsp");
cnt++;
}
else
{
out.print("News is not added into database");
response.sendRedirect("news.jsp");
}
%