Found 317 Articles for JDBC

How to update the column of a row in a CachedRowSet object in JDBC?

Samual Sam
Updated on 30-Jul-2019 22:30:25

482 Views

The CachedRowSet is the base implementation of disconnected row sets. It connects to the data source, reads data from it, disconnects with the data source and the processes the retrieved data, reconnects to the data source and writes the modifications.You can create a Cached RowSet object using the createCachedRowSet() method of the RowSetFactory.You can create a RowSetFactory object using the newfactory() method of the RowSetProvider method.Updating a Particular column of a rowThe updateXXX() methods of the CachedRowSet interface allows you to update column values of a particular row in a RowSet object.Get the required row and update the desired column ... Read More

How to insert data into a CachedRowSet in JDBC? Explain?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

497 Views

The CachedRowSet is the base implementation of disconnected row sets. It connects to the data source, reads data from it, disconnects with the data source and the processes the retrieved data, reconnects to the data source and writes the modifications.Creating a CachedRowSetYou can create a Cached RowSet object using the createCachedRowSet() method of the RowSetFactory.You can create a RowSetFactory object using the newfactory() method of the RowSetProvider method.Create a CachedRowSet object using the above mentioned methods as shown below −//Creating the RowSet object RowSetFactory factory = RowSetProvider.newFactory(); CachedRowSet rowSet = factory.createCachedRowSet();Connecting to the data sourceAfter creating a RowSet object you ... Read More

What is a CachedRowSet in JDBC? Explain?

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

The CachedRowSet is the base implementation of disconnected row sets. It connects to the data source, reads data from it, disconnects with the data source and the processes the retrieved data, reconnects to the data source and writes the modifications.Creating a CachedRowSetYou can create a Cached RowSet object using the createCachedRowSet() method of the RowSetFactory.You can create a RowSetFactory object using the newfactory() method of the RowSetProvider method.Create a CachedRowSet object using the above-mentioned methods as shown below −//Creating the RowSet object RowSetFactory factory = RowSetProvider.newFactory(); CachedRowSet rowSet = factory.createCachedRowSet();Connecting to the data sourceAfter creating a RowSet object you need ... Read More

Is RowSet Scrollable? Explain with an example?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

354 Views

A RowSet object is similar to ResultSet, it also stores tabular data, in addition to the features of a ResultSet. A RowSet follows the JavaBeans component model.If you Retrieve a ResultSet object by default the cursor of it moves only in forward direction. i.e. you can retrieve the contents of it from first to last.But, in a scrollable result set, the cursor can scroll forward and backward and you can retrieve data backward too.To make ResultSet object scrollable, you need to create one as shown below −Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);Whereas, a RowSet object is Scrollable by default. Therefore, whenever ... Read More

What is RowSet? How to retrieve contents of a table using RowSet? Explain?

Samual Sam
Updated on 30-Jul-2019 22:30:25

1K+ Views

A RowSet object is similar to ResultSet, it also stores tabular data, in addition to the features of a ResultSet a RowSet follows JavaBeans component model. This can be used as a JavaBeans component in a visual Bean development environment, i.e. in environments like IDE’s you can visually manipulate these properties.Connecting RowSet with databaseThe RowSet interface provides methods to set Java bean properties to connect it to the required database −void setURL(String url):void setUserName(String user_name):void setPassword(String password):PropertiesA RowSet object contains properties and each property have Setter and getter methods. Using these you can set and get values from a command ... Read More

How to retrieve multiple ResultSets from a stored procedure using a JDBC program?

Nitya Raut
Updated on 30-Jul-2019 22:30:25

5K+ Views

Stored procedures are sub routines, segment of SQL statements which are stored in SQL catalog. All the applications that can access Relational databases (Java, Python, PHP etc.), can access stored procedures.Stored procedures contain IN and OUT parameters or both. They may return result sets in case you use SELECT statements. Stored procedures can return multiple result sets.Retrieving Results from a procedure:You can call an existing stored procedure using the CallableStatement. The prepareCall() method of the Connection interface accepts the procedure call in string format and returns a callable statement object.CallableStatement cstmt = con.prepareCall("{call sampleProcedure()}");Execute the above created callable statement using ... Read More

How to connect to a MongoDB database using a JDBC program?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

1K+ Views

MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document.Before you start connecting MongoDB in you need to make sure that you have MongoDB JDBC driver. If not, download the jar from the path Download mongo.jar and, add it to your classpath.ExampleFollowing JDBC program establishes connection with the MongoDB database and creates a collection in it.import com.mongodb.client.MongoDatabase; import com.mongodb.MongoClient; import com.mongodb.MongoCredential; public class CreatingCollection {    public static void main( String args[] ) {       // Creating a Mongo client       MongoClient ... Read More

How to connect to PostgreSQL database using a JDBC program?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

758 Views

PostgreSQL is an open source relational database management system (DBMS) developed by a worldwide team of volunteers. PostgreSQL is not controlled by any corporation or other private entity and the source code is available free of charge.PostgreSQL runs on all major operating systems, including Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, Mac OS X, Solaris, Tru64), and Windows. It supports text, images, sounds, and video, and includes programming interfaces for C / C++, Java, Perl, Python, Ruby, Tcl and Open Database Connectivity (ODBC).Download the latest version of postgresql- from postgresql-jdbc repository.Add downloaded jar file postgresql-(VERSION).jdbc.jar in your class path.ExampleFollowing JDBC program ... Read More

How to connect to HSQLDB database using a JDBC program?

Nitya Raut
Updated on 30-Jul-2019 22:30:25

650 Views

HSQLDB is a relational database management system implemented in pure Java. You can easily embed this database to your application using JDBC. Or you can use the operations separately.Installing HSQLDB:Download the latest version of HSQLDB database.Install HSQLDB following the steps given in HSQLDB Tutorial.Make sure that the HSQLDB database is up and running. The URL to connect to this database is jdbc:hsqldb:hsql://host_name/database_name and the driver class name is org.hsqldb.jdbc.JDBCDriver. Download the driver and set classpath to it.ExampleFollowing JDBC program establishes a connection with HSQL database.import java.sql.Connection; import java.sql.DriverManager; public class ConnectDatabase {    public static void main(String[] args) {   ... Read More

How to get the current value of a particular row from a database using JDBC?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

1K+ Views

The refreshRow() method of the ResultSet interface refreshes the current row with the most recent value in the database.rs.refreshRow()Assume we have a table named cricketers_data with 7 records as shown below:+----+------------+------------+---------------+----------------+-------------+ | ID | First_Name | Last_Name  | Year_Of_Birth | Place_Of_Birth | Country     | +----+------------+------------+---------------+----------------+-------------+ | 1  | Shikhar    | Dhawan     | 1981-12-05    | Delhi          | India       | | 2  | Jonathan   | Trott      | 1981-04-22    | CapeTown       | SouthAfrica | | 3  | Lumara     | Sangakkara | ... Read More

Advertisements