Inserting a Row into a Database Table Using an Updatable Result Set : ResultSet Updatable « Database SQL JDBC « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java » Database SQL JDBC » ResultSet UpdatableScreenshots 
Inserting a Row into a Database Table Using an Updatable Result Set
  

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

public class Main {
  public static void main(String[] argvthrows Exception {
    String driverName = "com.jnetdirect.jsql.JSQLDriver";
    Class.forName(driverName);

    String serverName = "127.0.0.1";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String url = "jdbc:JSQLConnect://" + mydatabase;
    String username = "username";
    String password = "password";

    Connection connection = DriverManager.getConnection(url, username, password);
    Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
        ResultSet.CONCUR_UPDATABLE);
    ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table");

    // Move cursor to the "insert row"
    resultSet.moveToInsertRow();

    // Set values for the new row.
    resultSet.updateString("col_string""new data");

    // Insert the row
    resultSet.insertRow();

  }
}

   
    
  
Related examples in the same category
1.If database support updatable result sets
2.Using UpdatableResultSet to insert a new row
3.Delete Row from Updatable ResultSet for MySQL
4.Insert Row to Updatable ResultSet from MySQL
5.Make updates in Updatable ResultSet
6.Demo Updatable ResultSet
7.Updatable resultset with Oracle Driver
8.Determining If a Database Supports Updatable Result Sets: An updatable result set allows modification to data in a table through the result set.
9.Creating an Updatable Result Set
10.Determining If a Result Set Is Updatable
11.Updating a Row in a Database Table Using an Updatable Result Set
12.Cancelling Updates to an Updatable Result Set
13.Deleting a Row from a Database Table Using an Updatable Result Set
14.Refreshing a Row in an Updatable Result Set
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.