Krantik Chavan has Published 278 Articles

How to get the greatest of two columns values in MySQL?

Krantik Chavan

Krantik Chavan

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

302 Views

In order to get the greatest of two columns values in MySQL, you need to use GREATEST() function. Following is the syntax:select greatest(yourColumnName1, yourColumnName2) AS anyAliasName from yourTableName; Let us first create a table:mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Number1 int,    Number2 ... Read More

Is it mandatory to close JDBC connections?

Krantik Chavan

Krantik Chavan

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

3K+ Views

At the end of your JDBC program, it is required explicitly to close all the connections to the database to end each database session. However, if you forget, Java's garbage collector will close the connection when it cleans up stale objects.Relying on the garbage collection, especially in database programming, is ... Read More

What is the IntStream.Builder accept() method in Java

Krantik Chavan

Krantik Chavan

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

143 Views

Insert an element into IntStream using the IntStream.Builder accept() method. It adds element to the stream being built.The syntax is as follows:void accept(int t)Here, parameter t is the input argument.The elements are inserted as shown below in the stream:builder.accept(10); builder.accept(15); builder.accept(25); builder.accept(39); builder.accept(45);The following is an example to implement IntStream.Builder ... Read More

Why are Prepared Statements in JDBC faster than Statements? Explain?

Krantik Chavan

Krantik Chavan

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

596 Views

While executing statements using Statement object, especially insert statements, each time a query is executed the whole statement is compiled and executed again and again where, the only difference among these statements is the values of the statements.Whereas, prepared statement is a precompiled statement i.e. the query is compiled and ... Read More

IntStream.Builder add() method in Java

Krantik Chavan

Krantik Chavan

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

146 Views

To insert element into the stream, you need to use the add() method of the IntStream.Builder.The syntax is as follows:default IntStream.Builder add(int t)Here, parameter t is the element to be inserted.Declare IntStream.Builder:IntStream.Builder builder = IntStream.builder();Add some elements to the Builder using add() method:builder.add(10); builder.add(25); builder.add(33); builder.add(42);The following is an example ... Read More

What are the advantages and limitations of JDBC PreparedStatement?

Krantik Chavan

Krantik Chavan

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

2K+ Views

Following are the advantages of the prepared statement:By avoiding multiple compilation and execution of statements, prepared statements perform faster.Using prepared statements, we can insert values to advanced datatypes such as BLOB, CLOB, OBJECT easily with the help of the setter methods provided by the PreparedStatement interface.By providing setter method to ... Read More

StringJoiner merge() method in Java 8

Krantik Chavan

Krantik Chavan

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

315 Views

The merge() method of the StringJoiner class in Java 8 is used to merge the contents of the StringJoiner str, which is passed as a parameter. The content gets added as the next element.The syntax is as follows:public StringJoiner merge(StringJoiner str)Here, str is the StringJoiner content to be merged.To work ... Read More

The remove() method of Java AbstractCollection class

Krantik Chavan

Krantik Chavan

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

472 Views

If you want to remove an element from the AbstractCollection classs, use the remove() method. It returns TRUE if the elements requested to be removed is successfully removed from the collection.The syntax is as follows:public boolean remove(Object ob)Here, ob is the element to be removed the from this Collection. Whereas, ... Read More

What is Octet class in JavaTuples?

Krantik Chavan

Krantik Chavan

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

150 Views

An Octetclass is a Tuple of 8 element. It is in the JavaTuples library. The following is the declaration of the Octet class:public final class Octet extends Tuple implements IValue0, IValue1, IValue2, IValue3, IValue4, IValue5, IValue6, IValue7Let us first see what we need to work with JavaTuples. To work with ... Read More

DoubleStream toArray() method in Java

Krantik Chavan

Krantik Chavan

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

125 Views

The toArray() method returns an array containing the elements of this stream.The syntax is as follows:double[] toArray()To use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;Create DoubleStream and add some elements:DoubleStream doubleStream = DoubleStream.of(20.7, 30.5, 45.9, 60.2, 75.9, 88.3, 95.2);Now, use the toArray() method to return an array ... Read More

Advertisements