gpt4 book ai didi

java - 当我运行下面给出的代码时,我收到 java.sql.SQLSyntaxErrorException

转载 作者:行者123 更新时间:2023-12-02 10:01:10 27 4
gpt4 key购买 nike

我试图将一个非常长的字符串(基本上是图像的 base64 编码字符串)插入到数据库中的 CLOB 类型列中。但是我收到了异常 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 或列规范

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)

最佳答案

WHERE 之前不应有逗号

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

我以前就已经通过艰苦的方式了解到这一点。

关于java - 当我运行下面给出的代码时,我收到 java.sql.SQLSyntaxErrorException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55621690/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com