使用Java插入数据库时出现Postgresql PSQL异常

使用Java插入数据库时出现Postgresql PSQL异常,java,spring,postgresql,Java,Spring,Postgresql,我的代码有错误 java.lang.RuntimeException: org.postgresql.util.PSQLException: The column index is out of range: 12, number of columns: 11 我花了一些时间研究不同的解决方案,但没有用 这是我的代码,我有我的sql字符串 public void insertToDB(Active active) { String sql = "INSERT INTO act

我的代码有错误

java.lang.RuntimeException: org.postgresql.util.PSQLException: The column index is out of range: 12, number of columns: 11
我花了一些时间研究不同的解决方案,但没有用

这是我的代码,我有我的sql字符串

public void insertToDB(Active active) {

        String sql = "INSERT INTO active (branchname, branchcode, sidnew, sidold, accountno, openingbalance, "
                + "paymentreceived, currentcharges, monthlyrecrate, invoiceno, category)"
                + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

        Connection conn = null;

        try {

            conn = dataSource.getConnection();
            PreparedStatement ps = conn.prepareStatement(sql);

            ps.setString(3, active.getBranchname());
            ps.setString(4, active.getBranchcode());
            ps.setString(5, active.getSidnew());
            ps.setString(6, active.getSidold());
            ps.setString(7, active.getAccountno());
            ps.setString(8, active.getOpeningbalance());
            ps.setString(9, active.getPaymentreceived());
            ps.setString(10, active.getCurrentcharges());
            ps.setString(11, active.getMonthlyrecrate());
            ps.setString(12, active.getInvoiceno());
            ps.setString(13, active.getCategory());

            ps.executeUpdate();
            ps.close();

        } catch (SQLException e) {
            throw new RuntimeException(e);

        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {}
            }
        }

    }
这是我的eclipse控制台中的日志

java.lang.RuntimeException:org.postgresql.util.PSQLException:列索引超出范围:12,列数:11。 位于com.joven.dao.ActiveDAOImpl.insertToDB(ActiveDAOImpl.java:74) 在com.joven.core.ActiveAccountsReadExcel.getExcelInfo(ActiveAccountsReadExcel.java:138) 在com.joven.core.ActiveAccountsReadExcel.ValidateExcelFormat(ActiveAccountsReadExcel.java:56) 在com.joven.core.ActiveAccountsReadExcel.buttonChooseFile(ActiveAccountsReadExcel.java:41) 位于com.joven.ui.MainView$3.handle(MainView.java:110) 位于com.joven.ui.MainView$3.handle(MainView.java:1) 在com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)上 位于com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) 位于com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) 在com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)上 在com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) 位于com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) 在com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) 位于com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) 在com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) 位于com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) 位于com.sun.javafx.event.EventUtil.fireventimpl(EventUtil.java:74) 位于com.sun.javafx.event.EventUtil.firevent(EventUtil.java:49) 位于javafx.event.event.fireEvent(event.java:198) 位于javafx.scene.Node.firevent(Node.java:8413) 位于javafx.scene.control.Button.fire(Button.java:185) 在com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased上(ButtonBehavior.java:182) 位于com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96) 位于com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89) 位于com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218) 位于com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80) 位于com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) 位于com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) 在com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)上 在com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) 位于com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) 在com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) 位于com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) 在com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) 位于com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) 位于com.sun.javafx.event.EventUtil.fireventimpl(EventUtil.java:74) 位于com.sun.javafx.event.EventUtil.firevent(EventUtil.java:54) 位于javafx.event.event.fireEvent(event.java:198) 位于javafx.scene.scene$MouseHandler.process(scene.java:3757) 在javafx.scene.scene$MouseHandler.access$1500(scene.java:3485) 位于javafx.scene.scene.impl_processMouseEvent(scene.java:1762) 位于javafx.scene.scene$ScenePeerListener.mouseEvent(scene.java:2494) 位于com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394) 位于com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295) 位于java.security.AccessController.doPrivileged(本机方法) 位于com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:432) 位于com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389) 位于com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431) 位于com.sun.glass.ui.View.handleMouseEvent(View.java:555) 位于com.sun.glass.ui.View.notifyMouse(View.java:937) 原因:org.postgresql.util.PSQLException:列索引超出范围:12,列数:11。 位于org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:56) 位于org.postgresql.core.v3.SimpleParameterList.setStringParameter(SimpleParameterList.java:118) 位于org.postgresql.jdbc2.AbstractJdbc2Statement.bindString(AbstractJdbc2Statement.java:2310) 位于org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1398) 位于org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1384) 位于org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:135) 位于org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:135) 位于com.joven.dao.ActiveDAOImpl.insertToDB(ActiveDAOImpl.java:67) ... 49多

感谢您的帮助。