//:CreateCoffee.java
//an example using to create and update .
import java.sql.*;
public class CreateCoffee {
    public static void main(String args[]) {
        String url = "jdbc:odbc:coffees2";
        
        String createString;
        String myLogin="yuan";
        String myPassword="132440";
        Connection con;
        Statement stmt;
        int[] a={1,102,130,4,16};
        createString = "create table COFFEES " +
                            "(COF_NAME VARCHAR(32), " +
                            "SUP_ID INTEGER, " +
                            "PRICE FLOAT, " +
                            "SALES INTEGER, " +
                            "TOTAL INTEGER)";
        //using to load driver:
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch(java.lang.ClassNotFoundException e) {
            System.err.print("ClassNotFoundException: ");
            System.err.println(e.getMessage());
        }
        //using to create:
      try {
            con = DriverManager.getConnection(url, myLogin, myPassword);
            stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
              ResultSet.CONCUR_UPDATABLE);
            stmt.executeUpdate(createString);
            stmt.close();
            con.close();
        }catch(SQLException ex) {
            System.err.println("SQLException: " + ex.getMessage());
        }
        //using to update:    
        try{
             con = DriverManager.getConnection(url, myLogin, myPassword);
             stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
              ResultSet.CONCUR_UPDATABLE);
            // 允许自动更新
            con.setAutoCommit(true);            ResultSet re = stmt.executeQuery("select * from coffees2");
            re.absolute(2);
            re.updateInt(1,a[0]);
            re.updateInt(2,a[1]);
            re.updateInt(3,a[2]);
            re.updateInt(4,a[3]);
            re.updateInt(5,a[4]);System.out.println("love");
            re.updateRow();
            while(re.next()){System.out.println("love");
              System.out.println(re.getString(1)+","+                                                             re.getString(2)+","+re.getString(3)+","+re.getString(4));
                
            }
/*          String updateString = "UPDATE COFFEES " +
"SET SALES = 90 " ;

            stmt.executeUpdate(updateString);System.out.println("love");*/
            re.close();
            stmt.close();
            con.close();
        } catch(SQLException ex) {
            System.err.println("SQLException: " + ex.getMessage());
        }
/*     try{
          Thread.currentThread().sleep(5*1000);
        }catch(InterruptedException e){}*/
    }
}///:~
这是我的程序
但老是有错误:
[Microsoft][.... 驱动程序管理器]:非法的游标状态..
我真是急四了,有答复
必重谢!!!