0

我正在使用 oracle xpress 版本。我在 Tender_reference 列的 TenderDetails 表上创建了一个序列。但是当我尝试从 netbeans java 将数据输入数据库时​​显示错误。这是我的代码

CREATE SEQUENCE test_sequence
START WITH 1
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER test_trigger
BEFORE INSERT
ON TENDERDETAILS
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT test_sequence.nextval INTO :NEW.TENDER_REFERENCE FROM dual;
END;

现在,当我尝试使用 jdbc 从 netbeans 输入数据时,它显示以下错误 java.sql.SQLException: Invalid column index

if(evt.getSource()==jButton1)
    {
        ResultSet rs;
        Connection con = null;
        Statement st = null;
        String bc,ef,fg,gh,hi,ij,jk,mn,lm,no;

        try
        {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","hr");}
        catch(      ClassNotFoundException | SQLException e)
        {

            System.out.println(e);
        }
        try{
            st = con.createStatement();

            //ab=jTextField1.getText();
            bc=jTextField2.getText();

            ef=jTextField5.getText();
            mn=jTextField13.getText();
            int cd=Integer.parseInt(jTextField3.getText());
            int de=Integer.parseInt(jTextField4.getText());
            no=jTextField14.getText();
            fg=jTextField6.getText();
            gh=jTextField7.getText();
            hi=jTextField8.getText();
            ij=jTextField9.getText();
            jk=jTextField10.getText();
            lm=jTextField11.getText();
            int kl=Integer.parseInt(jTextField12.getText());

            PreparedStatement ps= con.prepareStatement("Insert into TENDERDETAILS1          (TENDER_NAME,PRODUCT_CATEGORY,FUNDING_TYPE,EMD,DOCUMENT_COST,LOCATION_WORK,STATE_WORK,NIT,LASTDATE_DOC,LASTDATE_SUB,TENDEROPEN_DATE,CONTACT_DETAILS,NO_DOC)values('?','?','?','?','?','?','?','?','?','?','?','?','?')");
            //String new_custid1 = Integer.toString(TENDER_REFERENCE);
            //jTextField1.setText(new_custid1);


        ps.setString(1,bc);
                    ps.setString(2,ef);
                    ps.setString(3,mn);
        ps.setInt(4,cd);
        ps.setInt(5,de);
        ps.setString(6,no);
        ps.setString(7,fg);
        ps.setString(8,gh);
                    ps.setString(9,hi);
        ps.setString(10,ij);
        ps.setString(11,jk);

        ps.setString(12,lm);
                    ps.setInt(13,kl);



            int a=ps.executeUpdate();

    if(a>0){ 
            JOptionPane.showMessageDialog(null, "New Tender created","Tender", 1);
            con.close();}
        }
        catch(SQLException | HeadlessException e)
        {

            System.out.println(e);
        }
4

0 回答 0