jdbc connectivity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaleeswaran
    New Member
    • Mar 2007
    • 132

    #1

    jdbc connectivity

    hi!
    i am started to connect jdbc driver with my java program..
    i am using proper systax in my java program for connecting jdbc driver but i face the problem like this:
    [Microsoft][ODBC Driver Manager] Invalid cursor stat..
    this my java code:
    try {
    Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
    Connection conn = DriverManager.g etConnection"jd bc:odbc:sample" ,"kaleeswaran", "kalees");
    Statement stat = conn.createStat ement();
    ResultSet res = stat.executeQue ry("Select * from customers");
    ResultSetMetaDa ta d=res.getMetaDa ta();
    int co=d.getColumnC ount();
    while(res.next( ));
    {
    for(int i=1;i<=co;i++)
    {
    System.out.prin tln(res.getObje ct(i)+" ");
    System.out.prin tln();
    }
    conn.close();
    }

    i hope i am getting immediate reply,
    thank you,
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    do one thing .....

    insert System.out.prin tln(message) before and after the line .....
    ResultSetMetaDa ta d=res.getMetaDa ta();

    then tell me what prints and what not.......

    and do one more thing ... check out the table whether it contains data or not.

    best of luck
    kind regards.

    Comment

    • kaleeswaran
      New Member
      • Mar 2007
      • 132

      #3
      Thank you for replay me!..
      i found my mistake...
      i was put a semicolon in my while statement that's the problem..
      thank you,

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        that means exausted resultset causes this error.

        Comment

        Working...