我正在使用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:列索引无效
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);
}