Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error in SQL java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Conn

807589Jul 27 2008 — edited Jul 28 2008
this is a package part of a project
but iam getting a error

*Error in SQL java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt*

this is made in java netbeans v6.1
plz help !!

package account;
import java.sql.*;
import bankpr.useredit;

/**
 *
 * @author Bharat Raj Verma
 */
public class edit {
    
          String fn="";
    String mn="";
    String ln="";
   // String sex;
    String ad1="";
          String  ad2="";
           String ad3="";
           String city="";
           String pin="";
           String states="";
           String country="";
            String contact="";
            String email="";
            String sex="";
            String ac="";
            String userid="";
    int age;
    int chk=-99;
    int count=-99;
    public void change(String a,String b,String c,int d,String e,String f,String g,String h,String i,String j,String k,String l,String m,String n,String o) throws SQLException
   {//return();
    fn = a;
    mn = b;
    ln = c;
    age = d;
    ad1 = e;
    ad2 = f;
    ad3 = g;
    city = h;
    pin = i;
    states = j;
    country = k;
    contact=l;
    email=m;
    sex=n;
    userid=o;
    
    
    
    
    String url = "jdbc:odbc:bharat";
    Connection con11 = null,con10=null;
    
  
   String query = "UPDATE dbo.userd SET fn - ?, mn = ?, ln = ?, age = ?, sex = ?, ad1= ?, ad2 = ?, ad3 = ?, city = ?, pin = ?, state = ?, country = ?, contact= ?, email = ? WHERE idnum =?";
   
    try {
        //load the driver
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  
        //get the connection
      con11 = DriverManager.getConnection(url,"","");
      con10 = DriverManager.getConnection(url,"","");
      
      System.out.println("connection Established");
      
      Statement stmt = con11.createStatement();
      System.out.println(a+b+c+d);
         //get userid for USER
      
      ResultSet rs;
       
      rs=stmt.executeQuery("select * from dbo.userd");
      while(rs.next())
      {
            String com="";
     com=rs.getString("idnum");
          System.out.println("userid for match : "+userid);
          
    
      com.trim();
      System.out.println("userid found     : "+com);
      if(com.equalsIgnoreCase(userid))
      {
          System.out.println("condition true ");
      PreparedStatement ps = con11.prepareStatement(query);
      //ps.setString(1,userid);
      ps.setString(1,fn);
      ps.setString(2,mn);
      ps.setString(3,ln);
      ps.setInt(4,age);
      ps.setString(5,sex);
      ps.setString(6,ad1);
      ps.setString(7,ad2);
      ps.setString(8,ad3);
      ps.setString(9,city);
      ps.setString(10,pin);
      ps.setString(11,states);
      ps.setString(12,country);
      ps.setString(13,contact);
      ps.setString(14,email);     
      ps.setString(15,userid);
      ps.executeUpdate();
      count=1;
      break;
      
      }
      
        
      }
      con10.close();
      con11.close();
      rs.close();
      stmt.close();
      
       
      if(count==-99)
      {
        System.out.println("Error");  
      }
      else 
      {
        System.out.println("Resutset reached : no of rowws affected "+count); 
        useredit u= new useredit();
        u.chk(1);
      }
     
    }
    catch(Exception e1)
    {
      System.err.println("Error in SQL "+e1);
      count=-99;
    }
finally
{
    con11.close();
    con10.close();
    
}

}
public int result()
{
    return(count);
}
/*public String accnum1()
{
    return(accnum);
    
}*/

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 25 2008
Added on Jul 27 2008
6 comments
928 views