Found 4331 Articles for Java 8

Exception Handling in C++ vs Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

518 Views

There are key differences in Exception Handling in C++ vs JavaException handling in javaException handling in C++Only throwable objects can be thrown as objects.All types can be thrown as exceptionIn java, finally is a block that is executed after try catch block for cleaning up.In C++ there is no existence of finally blockA new keyword throws is used to list exceptions thrown by a function.Throw keyword is used to list exceptions thrown by a function.Both checked and unchecked exceptions are present.Only unchecked exceptions are present.

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

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

490 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

508 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

357 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

Default virtual behavior in C++ vs Java

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

127 Views

In C++ methods are non-virtual by default. They can be made virtual function by using a virtual keyword.Example Code#include using namespace std; class B {    public: void s() //non virtual by default. Use virtual before the function to print “In Derived” {       cout

IntStream summaryStatistics() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

412 Views

The summaryStatistics() method in the IntStream class is used to return summary data about the elements of this stream. The syntax is as follows:IntSummaryStatistics summaryStatistics()Create an IntStream and add some elements:IntStream intStream = IntStream.of(30, 60, 90);Now, get the summary data about the above elements:IntSummaryStatistics details = intStream.summaryStatistics();The following is an example to implement IntStream summaryStatistics() method in Java:Example Live Demoimport java.util.stream.IntStream; import java.util.IntSummaryStatistics; public class Demo {    public static void main(String[] args) {       IntStream intStream = IntStream.of(30, 60, 90);       IntSummaryStatistics details = intStream.summaryStatistics();       System.out.println("Details = "+details);    } }OutputDetails = IntSummaryStatistics{count=3, ... Read More

How to generate Infinite Stream of Integers in Java using IntStream.iterate()

Nancy Den
Updated on 30-Jul-2019 22:30:25

148 Views

To generate an infinite stream of integer, use the IntStream.iterate(). The method is used to iterator an IntStream.Import the following package for the IntStream class in Java:import java.util.stream.IntStream;The following is an example displaying how to generate Infinite Stream of Integers with IntStream.iterate() in Java:Exampleimport java.util.stream.IntStream; public class Main {    public static void main(String[] args) {       IntStream.iterate(0, k -> k + 2).forEach(System.out::println);    } }Here is the output that displays integers infinitely:0 2 4 6 8 10 12 . . .

The build() method in Java Stream.Builder

Nancy Den
Updated on 30-Jul-2019 22:30:25

4K+ Views

The build() method in Stream.Builder class is used to build the stream. It returns the built stream.The syntax is as follows:Streaml build()Import the following package for the Stream.Builder class in Java:import java.util.stream.Stream;Declare a Stream.Builder:Stream.Builder builder = Stream.builder();Add some elements in the stream:builder.add("One"); builder.add("Two"); builder.add("Three");Now, use the build() method:Stream str = builder.build();The following is an example displaying how to implement build() method of Stream.Builder in Java:Example Live Demoimport java.util.stream.Stream; public class Demo {    public static void main(String[] args) {       Stream.Builder builder = Stream.builder();       builder.add("One");       builder.add("Two");       builder.add("Three");       ... Read More

Advertisements