Krantik Chavan has Published 308 Articles

What is Type_FORWARD_ONLY ResultSet in JDBC?

Krantik Chavan

Krantik Chavan

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

2K+ Views

A ResultSet interface in JDBC represents the tabular data generated by SQL queries. It has a cursor which points to the current row. Initially, this cursor is positioned before the first row.You can retrieve the column value at the current row using the getter methods getInt(), getString(), getDate() etc…To move ... Read More

Java Program to get Sub Set from TreeSet

Krantik Chavan

Krantik Chavan

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

61 Views

Let us first create a TreeSet and add elements:TreeSet treeSet = new TreeSet(); treeSet.add(10); treeSet.add(20); treeSet.add(30); treeSet.add(40); treeSet.add(50); treeSet.add(60); treeSet.add(70); treeSet.add(80); treeSet.add(90); treeSet.add(100);Now, let’s say you need to set sub set from 50 to 70, then use the subset() for it:SortedSet sub = treeSet.subSet(50, 70); System.out.println("Sub Set = " + ... Read More

Java Program to get Tail Set from TreeSet

Krantik Chavan

Krantik Chavan

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

43 Views

Let us first create a TreeSet and add elements to it:TreeSet treeSet = new TreeSet(); treeSet.add(20); treeSet.add(50); treeSet.add(100); treeSet.add(120); treeSet.add(150); treeSet.add(200); treeSet.add(250); treeSet.add(300); treeSet.add(350); treeSet.add(400);Now, let us get Tail Set from the TreeSet. In the below case, we will get elements above 200:SortedSet set = treeSet.tailSet(200);Exampleimport java.util.SortedSet; import java.util.TreeSet; public ... Read More

What is TYPE_SCROLL_INSENSITIVE ResultSet in JDBC?

Krantik Chavan

Krantik Chavan

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

2K+ Views

This represents a scrollable ResultSet i.e. the cursor moves in forward or backward directions. This type of ResultSet is insensitive to the changes that are made in the database i.e. the modifications done in the database are not reflected in the ResultSet.Which means if we have established a connection with ... Read More

Java Program to convert LocalDateTime to LocalDate and LocalTime

Krantik Chavan

Krantik Chavan

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

3K+ Views

At first set a LocalDateTime:LocalDate date = LocalDate.now(); LocalTime time = LocalTime.now(); LocalDateTime dateTime = LocalDateTime.of(date, time);Now, convert the LocalDateTime to LocalDate and LocalTime:LocalDate localDate = LocalDateTime.now().toLocalDate(); LocalTime localTime = LocalDateTime.now().toLocalTime();Exampleimport java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; public class Demo {    public static void main(String[] args) {       ... Read More

Java Program to convert millisecond to readable string

Krantik Chavan

Krantik Chavan

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

405 Views

Let’s say the following is the declaration for milliseconds:long millis = 5000000;Now get the hours, minutes and seconds from the milliseconds:long hours = TimeUnit.MILLISECONDS.toHours(millis); long minutes = TimeUnit.MILLISECONDS.toMinutes(millis) - (hours * 60); long seconds = TimeUnit.MILLISECONDS.toSeconds(millis) - ((hours * 60 * 60) + (minutes * 60));Use String.format() to convert the ... Read More

What is TYPE_SCROLL_SENSITIVE ResultSet in JDBC?

Krantik Chavan

Krantik Chavan

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

3K+ Views

This represents is a scrollable ResultSet i.e. the cursor moves in forward or backward directions. This type of ResultSet is sensitive to the changes that are made in the database i.e. the modifications done in the database are reflected in the ResultSet.Which means if we have established a connection with ... Read More

How to format and display date in Java as '201904'

Krantik Chavan

Krantik Chavan

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

76 Views

To format and display date like this i.e. YearMonth, you need to set the pattern:uuuuMMAt first, set a LocalDate:LocalDate localDate = LocalDate.now();Now format and display date as ‘201904’:localDate.format(DateTimeFormatter.ofPattern("uuuuMM"))Exampleimport java.time.LocalDate; import java.time.format.DateTimeFormatter; public class Demo {    public static void main(String[] args) {       LocalDate localDate = LocalDate.now();   ... Read More

How can I display Java date as '12/04/2019'

Krantik Chavan

Krantik Chavan

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

57 Views

To format and display date like this i.e. Day/Month/Year, you need to set the pattern:dd/MM/yyyyAt first, set a LocalDate:LocalDate localDate = LocalDate.now();Now format and display date as '12/04/2019':localDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))Exampleimport java.time.LocalDate; import java.time.format.DateTimeFormatter; public class Demo {    public static void main(String[] args) {       LocalDate date = LocalDate.now();   ... Read More

Network Control Protocol (NCP)

Krantik Chavan

Krantik Chavan

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

2K+ Views

Network Control Protocol (NCP) is a set of protocols forming a part of Point − to − Point Protocol (PPP). PPP is a data link layer protocol that is used to transmit multiprotocol data between two directly connected (point-to-point) computers. PPP is composed of link control protocol (LCP), authentication protocol ... Read More

Advertisements