Krantik Chavan has Published 278 Articles

How to sort an array with customized Comparator in Java?

Krantik Chavan

Krantik Chavan

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

2K+ Views

Let’s say the following is our string array and we need to sort it:String[] str = { "Tom", "Jack", "Harry", "Zen", "Tim", "David" };Within the sort() method, create a customized comparator to sort the above string. Here, two strings are compared with each other and the process goes on:Arrays.sort(str, new ... Read More

Java Program to create Stream from a String/Byte Array

Krantik Chavan

Krantik Chavan

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

588 Views

Create an input stream and set the string:DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream("pqrs tu v wxy z".getBytes()));The getBytes() method is used to convert a string into sequence of bytes and returns an array of bytes.Now return one single input byte:(char) inputStream.readByte()Exampleimport java.io.ByteArrayInputStream; import java.io.DataInputStream; public class Demo { public static ... Read More

What are the important components of JDBC?

Krantik Chavan

Krantik Chavan

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

2K+ Views

To communicate with the Database using JDBC you need the following components.JDBC DriverManager: The DriverManager class of the java.sql package manages different types of JDBC drivers. This class loads the driver classes. In addition to this, whenever a new connection establishes it chooses and loads the suitable driver from the ... Read More

What are the main features of JDBC?

Krantik Chavan

Krantik Chavan

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

3K+ Views

Following are the new features of JDBC:Makes JDBC calls: While using JDBC Java applications can make JDBC calls these calls submit SQL statements to the driver which in turn accesses the data from the database.Portability: JDBC provides wide level portability.Using JDBC you can request any type of queries from the ... Read More

Explain the architecture of JDBC?

Krantik Chavan

Krantik Chavan

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

4K+ Views

If you want to develop a Java application that communicates with a database, you should use JDBC API. A driver is the implementation of the said API; various vendors provide various drivers, you need to use a suitable driver with respect to the database you need to communicate with. The ... Read More

Create LabelValue Tuple from another collection in Java

Krantik Chavan

Krantik Chavan

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

90 Views

To create LabelValue tuple from another collection, use the fromCollection() method or the fromArray() method. Here, we will be creating LabelValue from List, therefore use the fromCollection() method.Let us first see what we need to work with JavaTuples. To work with LabelValue class in JavaTuples, you need to import the ... Read More

Create KeyValue Tuple from another collection in Java

Krantik Chavan

Krantik Chavan

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

84 Views

To create KeyValue tuple from another collection, use the fromCollection() method. We will be creating the tuple from List collection. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package.import org.javatuples.KeyValue;Note: Download JavaTuples Jar library ... Read More

How many types of JDBC Drivers are there?

Krantik Chavan

Krantik Chavan

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

1K+ Views

There are 4 types of JDBC drivers namely, Type-1, Type-2, Type-3 and, Type-4.Type1 It is the ODBC − JDBC bridge driver, it acts as a bridge between JDBC and, ODBC database connectivity mechanism. Using this you can access the databases which support only ODBC. Initially, it is used extensively, since most ... Read More

What is type1 driver of JDBC what are the advantages and disadvantages of it?

Krantik Chavan

Krantik Chavan

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

1K+ Views

It is the ODBC – JDBC bridge driver, it acts as a bridge between JDBC and, ODBC database connectivity mechanism. Using this you can access the databases which support only ODBC. Initially, it is used extensively, since most of the databases supported only ODBC.Whenever Java application sends a request to ... Read More

Order randomly in MySQL with a random value column?

Krantik Chavan

Krantik Chavan

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

249 Views

Let us first create a table. After that we will create a new random value column and order the record randomly:mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(20) ); Query OK, 0 rows affected (0.57 sec)Following is the query to insert some ... Read More

Advertisements