cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

java.sql.SQLException: Invalid column index

Former Member
4,917

Hello Experts,

I am developing one application on web dynpro java, here the users will enter data and the data will be stored in Oracle database, while saving the form i am having this exception:

java.sql.SQLException: Invalid column index

please help me out with this error

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Shilpi,

>> java.sql.SQLException: Invalid column index

Check the SQL statement and parameters that you are supplied in the code. This error mostly caused by providing wrong parameters on the code.

Remove set parameters first then execute the code. Then add the removed parameters one by one and find the root cause.

Best regards,

Orkun Gedik

Answers (3)

Answers (3)

Former Member
0 Likes

Hi Orkun,

I have checke the sql statement, its ok in the values, when I am deploying the application, i am getting this error. I am not getting problem is where; is it in my database or in code:

java.sql.SQLException: Invalid column index

Former Member
0 Likes

Hi Shilpi

Can you execute the code directly in your database .. from SQLPLUS ? If it works , the the issue is in the calling code..

Please check this - Oracle/PLSQL: ORA-00913 Error

Thanks

Rishi

Former Member
0 Likes

the application have two tables. i will show them and while saving the form i am encountering one more error:

java.sql.SQLException: ORA-00913: too many values

the tables are:

insert into hsemonthly_report1(bgroup,bvertical,pvertical,site,months,years,key1,key2,key3,key4,key5,manhour1, manhour2,mh_total,ip_emp1,ip_emp2,ip_emp3,ip_emp4,ip_con1,ip_con2,ip_con3,ip_con4,ip_cases,ip_injured,ip_totalman,ip_totalcost,ht_topic,ht_train_mth,ht_manhrs_mth,ht_toolbox_mth,ht_hours_mth,ht_inducted_mth,ht_manhrs_ca,ht_toolbox_ca,ht_hours_ca,ht_inducted_ca,lc_govt_mo,lc_penalties_mo,lc_cause_mo,lc_other_mo,lc_govt_co,lc_penalties_co,lc_cause_co,lc_other_co,PK_VALUE,euser, incidence_performance1, incidence_performance2, lti_contractor, lti_total, ip_fy1, mdl_contractor, mdl_total, ip_fy2, fr_1, fr1_emp, fr2con, fr_emp, fr_con, fr, sr1_emp, sr2_con, sr_1, sr_emp, sr_con, sr, capa_closed, comment1  )" +
       " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    PreparedStatement pstat=null;
    pstat=conn.prepareStatement(queryinsert);
    pstat.setString(1,(ele.getBusiness_group()));
    pstat.setString(2,(ele.getProjectname()));
    pstat.setString(3,(ele.getProjectvertical()));
    pstat.setString(4,(ele.getSite()));
    pstat.setString(5,(ele.getMonth()));
    pstat.setString(6,(ele.getYear()));
    pstat.setString(7,(key.getK1()));
    pstat.setString(8,(key.getK2()));
    pstat.setString(9,(key.getK3()));
    pstat.setString(10,(key.getK4()));
    pstat.setString(11,(key.getK5()));
    pstat.setFloat(12,(ele.getManhour1()));
    pstat.setFloat(13,(ele.getManhour2()));
    pstat.setFloat(14,(ele.getMH_Total()));
    pstat.setInt(15,(inc.getEmp_m1()));
    pstat.setInt(16,(inc.getEmp_m2()));
    pstat.setInt(17,(inc.getEmp_m3()));
    pstat.setInt(18,(inc.getEmp_m4()));
    pstat.setInt(19,(inc.getCon_m1()));
    pstat.setInt(20,(inc.getCon_m2()));
    pstat.setInt(21,(inc.getCon_m3()));
    pstat.setInt(22,(inc.getCon_m4()));
    pstat.setInt(23,(inc.getM1()));
    pstat.setInt(24,(inc.getM2()));
    pstat.setInt(25,(inc.getM3()));
    pstat.setInt(26,(inc.getM4()));
    pstat.setString(27,(tra.getTopic()));
    pstat.setInt(28,(tra.getM1()));
    pstat.setInt(29,(tra.getM2()));
    pstat.setInt(30,(tra.getM3()));
    pstat.setInt(31,(tra.getM4()));
    pstat.setInt(32,(tra.getM5()));
    pstat.setString(33,(tra.getC1()));
    pstat.setString(34,(tra.getC2()));
    pstat.setString(35,(tra.getC3()));
    pstat.setString(36,(tra.getC4()));
    pstat.setInt(37,(leg.getM1()));
    pstat.setInt(38,(leg.getM2()));
    pstat.setInt(39,(leg.getM3()));
    pstat.setInt(40,(leg.getM4()));
    pstat.setString(41,(leg.getC1()));
    pstat.setString(42,(leg.getC2()));
    pstat.setString(43,(leg.getC3()));
    pstat.setString(44,(leg.getC4()));
    pstat.setString(45,pk);
    pstat.setString(46,euser);
    pstat.setFloat(47,(ele.getIncident_performance1()));
    pstat.setFloat(48,(ele.getIncident_performance2()));
    pstat.setFloat(49,(ele.getLti_contractor()));
    pstat.setFloat(50,(ele.getLti_total()));
    pstat.setFloat(51,(ele.getIp_fy1()));
    pstat.setFloat(52,(ele.getIp_fy2()));
    pstat.setFloat(53,(ele.getMdl_contractor()));
    pstat.setFloat(54,(ele.getMdl_total()));
    pstat.setFloat(55,(ele.getFr_1()));
    pstat.setFloat(56,(ele.getFr1_emp()));
    pstat.setFloat(57,(ele.getFr2con()));
    pstat.setFloat(58,(ele.getFr_emp()));
    pstat.setFloat(59,(ele.getFr_con()));
    pstat.setFloat(60,(ele.getFr()));
    pstat.setFloat(61,(ele.getSr1_emp()));
    pstat.setFloat(62,(ele.getSr2_con()));
    pstat.setFloat(63,(ele.getSr_1()));
    pstat.setFloat(64,(ele.getSr_emp()));
    pstat.setFloat(65,(ele.getSr_con()));
    pstat.setFloat(66,(ele.getSr()));
    pstat.setFloat(67,(ele.getCapa_closed()));
    pstat.setString(68,(inc.getComment1()));
   
    a=pstat.executeUpdate();


"insert into hsemonthly_report2(bgroup,bvertical,pvertical,site,months,years,ia_inspections_mo, ia_audits_mo, ia_layer1, ia_stake_mo, ia_other_mo, ia_extagencies, ia_obs_closed_mo, ia_obs_open_mo, ia_HSEsteering,ia_inspections_co, ia_audits_co, ia_layer_co, ia_stake_co, ia_other_co, ia_extagencies_co, ia_obs_co,  ia_HSEsteering_co, oh_examination, oh_health, oh_other, plan_m, erp_hydrant, eme_year1, eme_year2, env_energy, env_fuels, env_consumed, env_nonhazadous, env_hazardous, env_release, env_spillage, env_programmes, env_other, Con_m, Per_m, Con_y, Per_y)" +
        
        " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
              PreparedStatement pstat1=null;
              pstat1=conn.prepareStatement(queryinsert1);
              pstat1.setString(1,(ele.getBusiness_group()));
              pstat1.setString(2,(ele.getProjectname()));
              pstat1.setString(3,(ele.getProjectvertical()));
              pstat1.setString(4,(ele.getSite()));
              pstat1.setString(5,(ele.getMonth()));
              pstat1.setString(6,(ele.getYear()));

              pstat1.setInt(7,(ins.getM1()));
              pstat1.setInt(8,(ins.getM2()));
              pstat1.setFloat(9,(ins.getM3()));
              pstat1.setInt(10,(ins.getM4()));
              pstat1.setInt(11,(ins.getM5()));
              pstat1.setFloat(12,(ins.getM6()));
              pstat1.setInt(13,(ins.getM3c1()));
              pstat1.setInt(14,(ins.getM3o1()));
              pstat1.setFloat(15,(ins.getM7()));
              pstat1.setString(16,(ins.getC1()));
              pstat1.setString(17,(ins.getC2()));
              pstat1.setString(18,(ins.getC3()));
              pstat1.setString(19,(ins.getC4()));
              pstat1.setString(20,(ins.getC5()));
              pstat1.setString(21,(ins.getC6()));
              pstat1.setString(22,(ins.getC7()));
              pstat1.setString(23,(ins.getC8()));

              pstat1.setInt(24,(occ.getM1()));
              pstat1.setInt(25,(occ.getM2()));
              pstat1.setString(26,(occ.getM3()));
     
              pstat1.setString(27,(eme.getM1()));
              pstat1.setInt(28,(eme.getM2()));
              pstat1.setString(29,(eme.getYear1()));
              pstat1.setString(30,(eme.getYear2()));
              pstat1.setInt(31,(eme.getM3()));
              pstat1.setInt(32,(eme.getM4()));
              pstat1.setInt(33,(eme.getM5()));
              pstat1.setInt(34,(eme.getM6()));
              pstat1.setString(35,(eme.getM7()));
     
              pstat1.setInt(36,(env.getM1()));
              pstat1.setInt(37,(env.getM2()));
              pstat1.setInt(38,(env.getM3()));
              pstat1.setInt(39,(env.getM4()));
              pstat1.setInt(40,(env.getM5()));
              pstat1.setInt(41,(env.getM6()));
              pstat1.setInt(42,(env.getM7()));
              pstat1.setString(43,(env.getM8()));
              pstat1.setString(44,(env.getM9()));
     
              pstat1.setString(45,(ele.getCon_m()));
              pstat1.setString(46,(ele.getCon_y()));
              pstat1.setString(47,(ele.getPer_m()));
              pstat1.setString(48,(ele.getPer_y()));
              pstat1.setString(49,(ele.getAnyother()));
              pstat1.setString(50,pk);
      
             b=pstat1.executeUpdate();

please help me out

Former Member
0 Likes

Please see the following links

ORA-00913: too many values tips

Oracle/PLSQL: ORA-00913 Error

Thanks

Rishi

Former Member
0 Likes

Check the "," value has inside of your data provided into the sql statement

Former Member
0 Likes

Hi Shilpi


From the description of the problem - looks like this is related to Java application code when trying to access and perform some action on the Oracle DB.

Can you please check the alertSID.log file for the Oracle DB and check if any error was captured there ..

Also maybe below links might be helpful

How to fix java.sql.SQLException: Invalid column index

java - What does the following Oracle error mean: invalid column index - Stack Overflow

Thanks

Rishi