当前位置: 首页 > 知识库问答 >
问题:

当我运行下面给出的代码时,我得到了java.sql.sqlsyntaxerRoreXception

归松
2023-03-14

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

我尝试了setClob()中的Clob对象和setClob()中的reader对象,但给出了相同的异常“java.sql.sqlsyntaxerrorexception”,并且我将OJDBC14.jar更新为OJDBC6.jar,就像以前给出的“java.lang.AbstractMethoderror:Method 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(); }

我想用字符串(>4000)更新CLOB列。

下面是完整的堆栈跟踪。

java.sql.sqlsyntaxerroreXception:ORA-01747:无效的user.table.column、table.column或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个答案

邢博文
2023-03-14

在哪里之前不应该是逗号

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

我以前很难学到这个。

 类似资料: