java.sql.SQLException: ORA-01006: bind variable does not exist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lunas
    New Member
    • Aug 2007
    • 4

    #1

    java.sql.SQLException: ORA-01006: bind variable does not exist

    hi
    i am trying to update a table selecting a value from another table and ve written the following codes for it..

    import java.sql.*;
    import java.io.*;
    import java.util.*;

    public class AF_updateAllele Tmp
    {
    Connection m_alleleCon;

    public void con() throws SQLException, java.lang.Class NotFoundExcepti on
    {
    Class.forName(" oracle.jdbc.dri ver.OracleDrive r"); // oracle driver
    m_alleleCon = (Connection)Dri verManager.getC onnection("jdbc :oracle:thin:@1 92.168.2.222:15 21:SNPDB","g2p" ,"g2p");

    }

    public void updateAlleleTem p() throws Exception
    {
    Statement my_updateStmt=m _alleleCon.crea teStatement(); //:1<int>,:2<char[32]>,:3<double>,:4 <char[128]>)
    PreparedStateme nt my_SelMTStmt=m_ alleleCon.prepa reStatement("se lect distinct(AutoMa rkerID) from marker_temp where marker_temp.dbS NPrsID=?");
    System.out.prin tln("after 1");
    PreparedStateme nt my_updateATPStm t=m_alleleCon.p repareStatement ("update allele_temp set allele_temp.Aut oMarkerID =? where dbsnprsid=? and automarkerid is null");
    System.out.prin tln("after 2");
    ResultSet AT_amid=my_upda teStmt.executeQ uery("select * from missingautomark erid");
    System.out.prin tln("after 3");
    while (AT_amid.next() )
    {

    System.out.prin tln("inside while");
    String dbsnpStr=AT_ami d.getString("db snprsid");
    System.out.prin tln("got dbsnprsid\t"+db snpStr);

    my_SelMTStmt.se tString(1,dbsnp Str);
    System.out.prin tln("sel stmt");
    //ResultSet rs=my_SelMTStmt .executeQuery() ;

    System.out.prin tln("result set...");
    while (rs.next())
    {
    System.out.prin tln("inside 2 while");
    int MT_amid=rs.getI nt("automarkeri d");
    System.out.prin tln("got automarkerid");
    my_updateATPStm t.setInt(1,MT_a mid);
    System.out.prin tln("set 1 done");
    my_updateATPStm t.setString(2,d bsnpStr);
    System.out.prin tln("set 2 done");
    my_updateATPStm t.executeQuery( );
    System.out.prin tln("update done");
    }
    System.out.prin tln("one update done !!!!");
    my_updateATPStm t.executeQuery( "commit");

    }

    my_updateATPStm t.executeQuery( "commit");
    my_updateStmt.c lose();
    System.out.prin tln("Update Allele temp done");
    }
    public static void main(String[] args)
    {
    try
    {
    AF_updateAllele Tmp up =new AF_updateAllele Tmp();
    up.con();
    up.updateAllele Temp();
    System.out.prin tln("Hello World!");
    }
    catch (Exception e)
    {
    e.printStackTra ce();
    }
    }
    }


    after one update the i get the following error
    java.sql.SQLExc eption: ORA-01006: bind variable does not exist

    can anyone plitz suggest something...
    thanx
  • madhoriya22
    Contributor
    • Jul 2007
    • 251

    #2
    Originally posted by lunas
    hi
    i am trying to update a table selecting a value from another table and ve written the following codes for it..

    import java.sql.*;
    import java.io.*;
    import java.util.*;

    public class AF_updateAllele Tmp
    {
    Connection m_alleleCon;

    public void con() throws SQLException, java.lang.Class NotFoundExcepti on
    {
    Class.forName(" oracle.jdbc.dri ver.OracleDrive r"); // oracle driver
    m_alleleCon = (Connection)Dri verManager.getC onnection("jdbc :oracle:thin:@1 92.168.2.222:15 21:SNPDB","g2p" ,"g2p");

    }

    public void updateAlleleTem p() throws Exception
    {
    Statement my_updateStmt=m _alleleCon.crea teStatement(); //:1<int>,:2<char[32]>,:3<double>,:4 <char[128]>)
    PreparedStateme nt my_SelMTStmt=m_ alleleCon.prepa reStatement("se lect distinct(AutoMa rkerID) from marker_temp where marker_temp.dbS NPrsID=?");
    System.out.prin tln("after 1");
    PreparedStateme nt my_updateATPStm t=m_alleleCon.p repareStatement ("update allele_temp set allele_temp.Aut oMarkerID =? where dbsnprsid=? and automarkerid is null");
    System.out.prin tln("after 2");
    ResultSet AT_amid=my_upda teStmt.executeQ uery("select * from missingautomark erid");
    System.out.prin tln("after 3");
    while (AT_amid.next() )
    {

    System.out.prin tln("inside while");
    String dbsnpStr=AT_ami d.getString("db snprsid");
    System.out.prin tln("got dbsnprsid\t"+db snpStr);

    my_SelMTStmt.se tString(1,dbsnp Str);
    System.out.prin tln("sel stmt");
    //ResultSet rs=my_SelMTStmt .executeQuery() ;

    System.out.prin tln("result set...");
    while (rs.next())
    {
    System.out.prin tln("inside 2 while");
    int MT_amid=rs.getI nt("automarkeri d");
    System.out.prin tln("got automarkerid");
    my_updateATPStm t.setInt(1,MT_a mid);
    System.out.prin tln("set 1 done");
    my_updateATPStm t.setString(2,d bsnpStr);
    System.out.prin tln("set 2 done");
    my_updateATPStm t.executeQuery( );
    System.out.prin tln("update done");
    }
    System.out.prin tln("one update done !!!!");
    my_updateATPStm t.executeQuery( "commit");

    }

    my_updateATPStm t.executeQuery( "commit");
    my_updateStmt.c lose();
    System.out.prin tln("Update Allele temp done");
    }
    public static void main(String[] args)
    {
    try
    {
    AF_updateAllele Tmp up =new AF_updateAllele Tmp();
    up.con();
    up.updateAllele Temp();
    System.out.prin tln("Hello World!");
    }
    catch (Exception e)
    {
    e.printStackTra ce();
    }
    }
    }


    after one update the i get the following error
    java.sql.SQLExc eption: ORA-01006: bind variable does not exist

    can anyone plitz suggest something...
    thanx
    Hi,
    For updating a table u should use pStatement.exec uteUpdate();

    thanks and regards,
    madhoriya22.

    Comment

    • praveen2gupta
      New Member
      • May 2007
      • 200

      #3
      Hi
      1. In the second while loop you are using rs , ResultSet from which you are not getting any value. Use AT_amid.next() in place of rs.next().

      2. In place of my_updateATPStm t.executeQuery( ); use my_updateATPStm t.executeUpdate ();

      try and post your results and Explain your program working more clearly.

      Comment

      Working...