当我运行下面给出的代码时,我正在获取java.sql.SQLSyntaxErrorException

时间:2019-04-10 21:40:25

标签: java oracle jdbc

我试图在数据库中的CLOB类型列中插入一个很长的String,它基本上是image的base64编码的字符串。但是我遇到了java.sql.SQLSyntaxErrorException异常。正确的方法是什么?

我已经尝试了setClob()中的Clob对象和setClob()中的reader对象,但是给出了相同的异常“ java.sql.SQLSyntaxErrorException”,而且我像以前一样将ojdbc14.jar更新为ojdbc6.jar它给出了“ java.lang.AbstractMethodError:方法oracle / jdbc / driver / T4CPreparedStatement.setClob(ILjava / io / Reader;)”。

       String uid = (String)session.getAttribute("uid");
        String userPhoto = request.getParameter("userPhoto");
        String AadhaarImageURI = request.getParameter("AadhaarImageURI");
        System.out.println(uid+"\n"+userPhoto+"\n"+AadhaarImageURI);
        //StringReader reader1 = new StringReader(userPhoto);
        //StringReader reader2 = new StringReader(AadhaarImageURI);

 try {

          Connection con = Connect_db.getCon();
          PreparedStatement ps= con.prepareStatement("update aadhardb set userimg=?, aadharimg=?, where u_id=?");


       Clob myclob = con.createClob();
       myclob.setString(1, userPhoto);
       Clob myclob2 = con.createClob();
       myclob2.setString(1,AadhaarImageURI);

           ps.setClob(1,myclob);
           ps.setClob(2,myclob2);
           ps.setString(3,uid);

       ps.execute();

           con.close();


}

         catch(Exception e){
                e.printStackTrace(); }

我想用Strings(> 4000)更新CLOB列。

这是完整的堆栈跟踪。

java.sql.SQLSyntaxErrorException:ORA-01747:无效的user.table.column,table.column或列规范

at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:953)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1222)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3488)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
at org.apache.jsp.userAadhaarEntry_jsp._jspService(userAadhaarEntry_jsp.java:141)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

1 个答案:

答案 0 :(得分:1)

在WHERE之前不要成为逗号

      PreparedStatement ps= con.prepareStatement("update aadhardb set userimg=?, aadharimg=? where u_id=?");

我以前很难学到这一点。