JSP file upload code
Hi ! here is my code for uploading csv file in Database.
This code works if i upload the file from my PC where Tomcat is also running.
but the same page gives me " File not found error" when run from other PC's.
Suggestions and help is appreciated..
<%@ page
import ="java.io.*"
import ="java.lang.*"
import ="java.sql.*"
import ="java.sql.Date"
import ="java.text.SimpleDateFormat"
import ="java.util.*" %>
<% String File_Name=request.getParameter("csv_file"); %>
<%! String line;
String LINE_1 ="";
String X;
String[] Data =new String[32];
int Count = 27;
Connection con;
PreparedStatement stmt;
ResultSet rs;
%>
<%try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
}catch (ClassNotFoundException err){ out.println("Class loading error" +err);}
try{
con = DriverManager.getConnection("jdbc:odbc:fault_db");
}catch (Exception e){ out.println("ODBC Error"+e);} %>
<% BufferedReader read =new BufferedReader(new InputStreamReader(request.getInputStream()));
while ((line = read.readLine())!=null){
StringTokenizer st =new StringTokenizer(line,",",true);
while (st.hasMoreTokens()){
for (int field = 1; field < Count; field++){
String token = st.nextToken();
if ( token.equals(",")){
X="xx";
}else{
if ( field == 26 ){
X=token;
}else{
X=token;
}
if (st.hasMoreTokens())
st.nextToken();
}
Data[field] = X;
}
stmt = con.prepareStatement("INSERT INTO FAULT_TABLE values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
for (int i=1;i < 27; i++){
stmt.setString(i,Data[i]);
}
try{
stmt.executeUpdate();
}catch(Exception e){ out.println("Insert Error"+e);} %>
<%}
}
con.close();
read.close();
%>
<I> recoreds updtaed </I>

