Daniol Thomas has Published 242 Answers

What is a RowSet object explain using a JDBC program?

Daniol Thomas

Daniol Thomas

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

A RowSet is a wrapper around a ResultSet Object. It can be connected, disconnected from the database and can be serialized. It maintains a JavaBean component by setting the properties. You can pass a RowSet object over the network. By default, RowSet object is scrollable and updatable and it is ... Read More

How to update the contents of a ResultSet using a JDBC program?

Daniol Thomas

Daniol Thomas

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

To update the contents of the ResultSet you need to create a statement by passing the ResultSet type updatable, as://Creating a Statement object Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);Just like getXXX() and setXXX() methods ResultSet interface also provides methods to update the contents of a row in a result set updateXXX().These ... Read More

Java Program to check for the supported attribute via java.nio.file.FileStore

Daniol Thomas

Daniol Thomas

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

Following is our file:Path p = Paths.get("E:/input.txt"); FileStore file = Files.getFileStore(p);Now, check for the supported attributes one by one:FileAttributeView = file.supportsFileAttributeView(FileAttributeView.class) PosixFileAttributeView = file.supportsFileAttributeView(PosixFileAttributeView.class) BasicFileAttributeView = file.supportsFileAttributeView(BasicFileAttributeView.class)Exampleimport java.nio.file.FileStore; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.FileAttributeView; import java.nio.file.attribute.FileOwnerAttributeView; import java.nio.file.attribute.PosixFileAttributeView; public class Demo {    public static void ... Read More

Java Program to format date as Apr 19, 2019, 1:27 PM

Daniol Thomas

Daniol Thomas

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

To format and display datetime, you need to use DateTimeFormatter. The format style is MEDIUM and SHORT:DateTimeFormatter formatter = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT);Display the formatted date:formatter.format(LocalDateTime.now()Exampleimport java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; public class Demo {    public static void main(String[] args) {       DateTimeFormatter formatter = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT); ... Read More

Java Program to format date as Apr 14 2019 01:35 PM IST

Daniol Thomas

Daniol Thomas

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

To format and display datetime, you need to use DateTimeFormatter and use the pattern as:DateTimeFormatter dtFormat = DateTimeFormatter.ofPattern("MMM dd yyyy hh:mm a z");Above, the z is the timezone:MMM dd yyyy hh:mm a zNow, use the following for zone:ZonedDateTime dateTime = ZonedDateTime.now();Exampleimport java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; public class Demo {    public ... Read More

How to format Java LocalDateTime as ISO_DATE_TIME format

Daniol Thomas

Daniol Thomas

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

At first, set the date:LocalDateTime dateTime = LocalDateTime.of(2019, Month.JULY, 9, 10, 20);Now, format the datetime as ISO_DATE_TIME format:String str = dateTime.format(DateTimeFormatter.ISO_DATE_TIME);Exampleimport java.time.LocalDateTime; import java.time.Month; import java.time.format.DateTimeFormatter; public class Demo {    public static void main(String[] args) {       LocalDateTime dateTime = LocalDateTime.of(2019, Month.JULY, 9, 10, 20);     ... Read More

Java Program to format LocalDateTime as ISO_WEEK_DATE format

Daniol Thomas

Daniol Thomas

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

At first, set the date:LocalDateTime dateTime = LocalDateTime.of(2019, Month.SEPTEMBER, 9, 10, 20);Now, format the datetime as ISO_WEEK_DATE format:String str = dateTime.format(DateTimeFormatter.ISO_WEEK_DATE);Exampleimport java.time.LocalDateTime; import java.time.Month; import java.time.format.DateTimeFormatter; public class Demo {    public static void main(String[] args) {       LocalDateTime dateTime = LocalDateTime.of(2019, Month.SEPTEMBER, 9, 10, 20);     ... Read More

IntStream mapToObj() method in Java

Daniol Thomas

Daniol Thomas

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

The mapToObj() method in the IntStream class returns an object-valued Stream consisting of the results of applying the given function to the elements of this stream.The syntax is as follows.<U> Stream<U>mapToObj(IntFunction<? extends U> mapper)Here, the parameter mapper is a stateless function to apply to each element.Create an IntStream with the ... Read More

IntStream mapToLong() method in Java

Daniol Thomas

Daniol Thomas

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

The mapToLong() function in IntStream class returns a LongStream consisting of the results of applying the given function to the elements of this stream.The syntax is as follows.LongStream mapToLong(IntToLongFunction mapper)Here, the parameter mapper is a stateless function to apply to each element.Create an IntStream with some elements in the Stream.IntStream ... Read More

Collectors collectingAndThen() method in Java 8

Daniol Thomas

Daniol Thomas

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

The collectingAndThen() method in Java Collectors class acclimates a Collector to perform an additional finishing transformation. It returns collector which performs the action of the downstream collector, followed by an additional ending step.The syntax is as follows.static <T, A, R, RR> Collector<T, A, RR> collectingAndThen(Collector<T, A, R> downstream, Function<R, RR> ... Read More

Advertisements