jsp - Use column names with periods -
i've been writing jsp insert values excel sheet , code below.
<%@page import="java.sql.*"%> <% connection con = null; statement stmnt = null; try { int updatequery=0; string a=request.getparameter("comments"); string b=request.getparameter("updatedl"); string c=request.getparameter("sid"); string d=request.getparameter("desc"); string e=request.getparameter("pubcode"); string f=request.getparameter("type"); string g=request.getparameter("status"); string h=request.getparameter("daterec"); string i=request.getparameter("startd"); string j=request.getparameter("assignedd"); string k=request.getparameter("senttoae"); string l=request.getparameter("respfrmae"); string m=request.getparameter("vwrcmp"); string n=request.getparameter("ps"); string o=request.getparameter("test"); string p=request.getparameter("units"); string q=request.getparameter("vwr"); string r=request.getparameter("ie"); string s=request.getparameter("revdate"); string t=request.getparameter("reviews"); class.forname( "sun.jdbc.odbc.jdbcodbcdriver" ); con = drivermanager.getconnection( "jdbc:odbc:driver={microsoft excel driver (*.xls)};dbq=c:/jus/excel1.xls;"); stmnt = con.createstatement(); //string query="select column_name 'feb$'"; string query = "insert [feb$] (comments,'no. of lines updated in psis','shipment id',"+ "'sap txt description', 'phoenix pub code', 'product type', 'status of job', 'date request received',"+ "'start date', 'date assigned', 'date file sent ae', 'date response ae',"+ "'date completed --vwr', 'assigned ps', 'time estimate', units, 'date file needs sent vendor (vwr)',"+ "'internal errors', 'review date', 'review sent (yes/no)') values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; preparedstatement ps=con.preparestatement(query); ps.setstring(1, a); ps.setstring(2, b); ps.setstring(3, c); ps.setstring(4, d); ps.setstring(5, e); ps.setstring(6, f); ps.setstring(7, g); ps.setstring(8, h); ps.setstring(9, i); ps.setstring(10, j); ps.setstring(11, k); ps.setstring(12, l); ps.setstring(13, m); ps.setstring(14, n); ps.setstring(15, o); ps.setstring(16, p); ps.setstring(17, q); ps.setstring(18, r); ps.setstring(19, s); ps.setstring(20, t); //out.print(query); resultset rs = ps.executequery(); if (updatequery != 0) { %> <br> <table style="background-color: #e3e4fa;" width="30%" border="1"> <tr><th>data inserted in database.</th></tr> </table> <% } } catch( exception e ) { out.println( e ); } { try { stmnt.close(); con.close(); } catch( exception e ) { out.println( e ); } } %>
when run i'm getting below exception.
java.sql.sqlexception: [microsoft][odbc excel driver] invalid bracketing of name ''no. of lines updated in psis''.
please let me know how can rid of exception without changing column name.
thanks
Comments
Post a Comment