ResultSet: moveToInsertRow() : ResultSet : java.sql : Java by API examples (example source code) Organized by topic

Java by API
C++
PHP
Java by API Home »  java.sql   » [  ResultSet  ]   
 



ResultSet: moveToInsertRow()

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;

public class Main {

  public static void main(String[] argsthrows Exception {
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";

    Connection con;
    Statement stmt;
    ResultSet uprs;

    try {
      Class.forName(driver);
      con = DriverManager.getConnection("jdbc:odbc:RainForestDSN""student","student");
      stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
      uprs = stmt.executeQuery("SELECT * FROM Records");

      // Check the column count
      ResultSetMetaData md = uprs.getMetaData();
      System.out.println("Resultset has " + md.getColumnCount() " cols.");

      int rowNum = uprs.getRow();
      System.out.println("row1 " + rowNum);
      uprs.absolute(1);
      rowNum = uprs.getRow();
      System.out.println("row2 " + rowNum);
      uprs.next();
      uprs.moveToInsertRow();
      uprs.updateInt(1150);
      uprs.updateString(2"Madonna");
      uprs.updateString(3"Dummy");
      uprs.updateString(4"Jazz");
      uprs.updateString(5"Image");
      uprs.updateInt(65);
      uprs.updateDouble(75);
      uprs.updateInt(815);
      uprs.insertRow();
      uprs.close();
      stmt.close();
      con.close();
    catch (SQLException ex) {
      System.err.println("SQLException: " + ex.getMessage());
    }
  }
}

           
       
Related examples in the same category
1.  ResultSet.CONCUR_UPDATABLE
2.  ResultSet.TYPE_SCROLL_SENSITIVE
3.  ResultSet: absolute(int row)
4.  ResultSet: close()
5.  ResultSet: deleteRow()
6.  ResultSet.getAsciiStream(int columnIndex)
7.  ResultSet: getBlob(String colName)
8.  ResultSet: getConcurrency()
9.  ResultSet: getInt(String columnName)
10.  ResultSet: getRow()
11.  ResultSet: getString(int columnIndex)Has Download File
12.  ResultSet: getTimestamp(int columnIndex)
13.  ResultSet: getType()
14.  ResultSet: insertRow()
15.  ResultSet: isFirst()
16.  ResultSet: last()
17.  ResultSet: next()
18.  ResultSet: previous()
19.  ResultSet: relative(int rows)
20.  ResultSet: updateRow()
21.  ResultSet: updateDouble(int columnIndex, double x)
22.  ResultSet: updateString(String columnName, String x)
23.  ResultSet: wasNull()
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.