Note that there are some explanatory texts on larger screens.

plurals
  1. POArray list update to database
    text
    copied!<p>I am trying to update my database using values in array list . Following is the code i am trying.</p> <pre><code>String query = "insert into login values(? , ?)"; Connection conn = null; PreparedStatement statement = null; ResultSet resultSet = null; try { conn = getConnection(); for(int i = 0;i &lt; rowlength; i++) { System.out.println(rowList.get(i)); statement = conn.prepareStatement(query); statement.setInt(1, rowList.get(i)); statement.setString(2, rowsList.get(i+2)); resultSet = statement.executeQuery(); } } catch (SQLException e) { try { throw new ServletException("DB interaction failed", e); } catch (ServletException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } finally { if (resultSet != null) try { resultSet.close(); } catch (SQLException ignore) {} if (statement != null) try { statement.close(); } catch (SQLException ignore) {} if (conn != null) try { conn.close(); } catch (SQLException ignore) {} } </code></pre> <p>Its fetching following error in console for all values of loop.</p> <pre><code>java.lang.ClassNotFoundException: org.postgresql.Driver at org.apache.catalina.loader.WebappClassLoader.loadClass (WebappClassLoader.java:1358) at org.apache.catalina.loader.WebappClassLoader.loadClass (WebappClassLoader.java:1204) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at com.aipl.struts.action.ExcelDbAction.getConnection(ExcelDbAction.java:60) at com.aipl.struts.action.ExcelDbAction.execute(ExcelDbAction.java:126) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619) </code></pre> <p>Can anybody direct me in what i am doing wrong or their is another way of updating table in database.</p> <p>Thank you////</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload