Statement.RETURN_GENERATED_KEYS concept

Posted by rits on Stack Overflow See other posts from Stack Overflow or by rits
Published on 2009-06-20T16:02:55Z Indexed on 2010/04/01 7:03 UTC
Read the original article Hit count: 214

Filed under:
import java.sql.* ;
import java.util.* ;
import java.io.* ;

class DataBaseFactory{

    public static Connection getConnection(){
         ... ...
         ... ...
    }

}

class Demo{
    public static void main(String []args) throws SQLException{
    	    Connection con = DataBaseFactory.getConnection() ;

            //This is throwing exception
            //PreparedStatement ps = con.prepareStatement("insert into user values(?,?)", Statement.RETURN_GENERATED_KEYS) ;

            //But this is working fine
            PreparedStatement ps = con.prepareStatement("insert into user values(?,?)") ;

    }
}

thnx in advance to all the java people here....

© Stack Overflow or respective owner

Related posts about jdbc