Professional Documents
Culture Documents
Logical database
Physical
Database
session
JDBC Program
Methods of Connection:
Boolean getAutoCommit()
Retrieves the current auto-commit mode for this Connection object.
Void setAutoCommit(Boolean autoCommit)
Sets this connection’s auto-commit mode to the given state.
Void commit()
Makes all changes made since the previous commit/rollback permanent and
releases any database locks currently held by this Connection object.
Void rollback()
Undoes all changes made in the current transaction and releases any database locks
currently held by this connection object.
Savepoint setSavepoint()
Creates an unnamed savepoint in the current transaction and returns the new
Savepoint object that represents it.
Savepoint setSavepoint(String name)
Creates a savepoint with the given name in the current transaction and returns the
new Savepoint object that represents it
Void rollback (Savepoint savepoint)
Undoes all changes made after the given Savepoint object was set
package com;
import java.sql.Connection;
import java.sql.DriverManager;
b = con.getAutoCommit();
System.out.println(b);
}
}
package com;
import java.sql.*;
RowSets:
A RowSet is an object that encapsulates a set of rows from either Java Database Connectivity (JDBC)
result sets or tabular data sources like a file or spreadsheet. RowSets support component-based
development models like JavaBeans, with a standard set of properties and an event notification
mechanism.
Connected: - A connected RowSet object connects to the database once and remains
connected until the application terminates.
Javax.sql.RowSet.package:
1. JdbcRowSet - connected rowset
2. CacheRowSet disconnected rowset
3. WebRowSet disconnected rowset
1. JdbcRowSet
A JdbcRowSet is a connected RowSet, that is, it continually maintains its connection to a
database using a JDBC technology-enabled driver, it also effectively makes the driver a
JavaBeans component.
JdbcRowSet is an interface, which is implemented by jdbc driver developer.
How to create JdbcRowSet object?
Eg:
package com;
import java.sql.*;
import javax.sql.rowset.*;
import oracle.jdbc.rowset.*;
System.out.println(j.getInt(1)+","+j.getString(2)+","+j.getFloat(3));
}
CachedRowSet:
A CachedRowSet object is a container for rows of data that caches its rows in memory,
which makes it possible to operate without always being connected to its data
source/database.
It is JavaBeans component and is scrollable, updatable, and serializable.