java.sql.SQLException: ORA-00911: 无效字符

上午一直在调试..java.sql.SQLException: ORA-00911: 无效字符这个错误..
反复检查 数据库调试都没有问题.. 没办法最终拿出杀手锏.. GOOGLE.搜到
http://blog.csdn.net/zjx2388/archive/2008/03/10/2164755.aspx博友的帖子
一语点醒梦中人. 谢谢博友..
public static void creNewTable(String[] arr_talColumn,String tableName){ 
        DBConnection db = new DBConnection(); 
        con = db.getCon(); 
        StringBuffer sb = new StringBuffer(); 
        sb.append("create table "); 
        sb.append(tableName); 
        sb.append("("); 
        int length = 1000; 
        for(int index=0;index<arr_talColumn.length;index++){ 
            if(index==arr_talColumn.length-1){ 
                sb.append(arr_talColumn[index]+" varchar("+length+") null"); 
            }else{ 
                sb.append(arr_talColumn[index]+" varchar("+length+") null,"); 
            } 
        } 
        sb.append(");"); 
        System.out.println(sb); 
        try{ 
            ps = con.prepareStatement(sb.toString()); 
            boolean flag = ps.execute(); 
            System.out.println("success"); 
        }catch(SQLException e){ 
            e.printStackTrace(); 
        }finally{ 
            db.close(); 
        } 
    }

异常提示:
java.sql.SQLException: ORA-00911: 无效字符 

    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124) 
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:304) 
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:271) 
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:622) 
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:180) 
    at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:542) 
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1027) 
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2887) 
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:2978) 
    at com.company.fileuploaddemo.util.DBDao.creNewTable(DBDao.java:65) 
    at com.company.fileuploaddemo.servlet.FileToNewTableServlet.doGet(FileToNewTableServlet.java:55) 
    at com.company.fileuploaddemo.servlet.FileToNewTableServlet.doPost(FileToNewTableServlet.java:60) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) 
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868) 
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663) 
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) 
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) 
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) 
    at java.lang.Thread.run(Thread.java:595)

原来是
sb.append(");");

后面多写了一个分号..
感谢那位博友...
特此 分享一下经验
希望同志们不要犯以上错误..


你可能感兴趣的:(java,apache,oracle,sql,jdbc)