使用具有句点的列名称

时间:2014-03-25 18:54:05

标签: jsp jdbc

我一直在编写JSP以将值插入Excel工作表,代码如下所示。

<%@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 from 'Feb$'";
String query = "insert into [Feb$] (Comments,'No. of lines updated in PSIS','Shipment ID',"+
"'SAP TXT Description', 'Phoenix Pub Code', 'Product Type', 'Status of the job', 'Date Request received',"+
"'Start Date', 'Date assigned', 'Date file sent to AE', 'Date response from AE',"+
"'Date completed --VWR', 'Assigned to PS', 'Time Estimate', Units, 'Date file needs to be sent to 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 is inserted successfully 
 in database.</th></tr>
</table>
<%
}

}
catch( Exception e )
{
out.println( e );
}
finally
{
try
{
stmnt.close();
con.close();
}
catch( Exception e )
{
out.println( e );
}
}

        %>

当我执行此操作时,我得到以下异常。

java.sql.SQLException: [Microsoft][ODBC Excel Driver] Invalid bracketing of name ''No. of lines updated in PSIS''. 

请告诉我如何在不更改我的专栏名称的情况下摆脱此异常。

由于

0 个答案:

没有答案