0

This is my first question at this great site :D

I have an access database. In this database there is a table with 4 teams in a column. These teams have points and i want to sort out the first two teams with the most points. And finally insert these two teams in another table.

I can fetch these two teams without any problems. But if i try inserting them into another table, it shows a mistake: "java.sql.SQLException: Invalid Cursor Type: 1003"

public void Viertelfinale()
    {
        final String [] temp = new String[20];

        int i=0;

        try {
            st = con.createStatement();
            String sql = "SELECT * FROM tbl_Spielplan ORDER BY A_Punkte DESC";
            rs = st.executeQuery(sql);

            while (rs.next()){
                temp[i] = rs.getString("A_Teams");
                i++;
            }

            rs.close();
            st.close();
            int j=0;
            st = con.createStatement();
            String sql1 = "SELECT * FROM tbl_Viertelfinale";
            rs = st.executeQuery(sql1);

            rs.next();
            rs.moveToInsertRow();
            rs.updateString("A_Teams", temp[0]);
            rs.insertRow();

            rs.next();
            rs.moveToInsertRow();
            rs.updateString("A_Teams", temp[1]);
            rs.insertRow();


        } catch (SQLException e) {
            e.printStackTrace();
        }
    }  

Sorry for my English :/

Error:

java.sql.SQLException: Invalid Cursor Type: 1003
    at sun.jdbc.odbc.JdbcOdbcResultSet.moveToInsertRow(JdbcOdbcResultSet.java:4306)
    at Turnier.Schultunier.Viertelfinale(Schultunier.java:49)
    at Turnier.Viertelfinale.<init>(Viertelfinale.java:94)
    at Turnier.Viertelfinale$1.run(Viertelfinale.java:35)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
3
  • Try to test the later rs.next(); using an if statement. Commented Dec 12, 2013 at 20:07
  • what do you mean exactly ? Commented Dec 12, 2013 at 20:13
  • PLease add the whole stacktrace you are getting. Also point us to that line. Commented Dec 12, 2013 at 20:13

1 Answer 1

1

I'm pretty sure that Access doesn't support SELECT FOR UPDATE which seems to be what you're trying to use. Instead, just use a plain UPDATE statement (in addition to your SELECT query).

Sign up to request clarification or add additional context in comments.

1 Comment

how should this look like because i have to update the table with 'temp[0]' and i cant write it in the update statement ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.