Daniol Thomas has Published 211 Articles

The set() method of AbstractList class in Java

Daniol Thomas

Daniol Thomas

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

54 Views

The set() method of the AbstractList class is used to replace the element at the specified position in this list with the specified element. It returns the element that gets replaced.The syntax is as follows:public E set(int index, E ele)Here, the parameter index is the index of the element to ... Read More

The hashCode() method of AbstractList class in Java

Daniol Thomas

Daniol Thomas

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

63 Views

The hashCode() method of AbstractList class returns the hash code value for this list.The syntax is as follows:public int hashCode()To work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to implement hashCode() method of the AbstractlList class in Java:Example Live Demoimport java.util.ArrayList; import java.util.AbstractList; public class ... Read More

What is JDBC Blob data type? how to store and read data from it?

Daniol Thomas

Daniol Thomas

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

10K+ Views

A BLOB is binary large object that can hold a variable amount of data with a maximum length of 65535 characters.These are used to store large amounts of binary data, such as images or other types of files. Fields defined as TEXT also hold large amounts of data. The difference ... Read More

MongoDB query condition to compare two fields?

Daniol Thomas

Daniol Thomas

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

4K+ Views

You can use $where operator along with find() method to compare two fields in MongoDB. The syntax is as follows:db.yourCollectionName.find({$where:”yourCondition”}).pretty();To understand the above syntax, let us create a collection with some documents. The query to create a collection with documents is as follows:>db.compareTwoFields.insert({"Id":1, "FullName":{"FirstName":"John", "LastName":"Smith"}, "BranchName":"ComputerScience"}); WriteResult({ "nInserted" : 1 ... Read More

The clear() method of Java AbstractCollection class

Daniol Thomas

Daniol Thomas

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

121 Views

The clear() method of the AbstractCollection class is used to remove all the elements from this collection. This makes the collection empty.The syntax is as follows:public void clear()To work with AbstractCollection class in Java, import the following package:import java.util.AbstractCollection;First, create AbstractCollection and add some elements using the add() method:AbstractCollection absCollection ... Read More

What is JDBC Clob data type? how to store and read data from it?

Daniol Thomas

Daniol Thomas

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

9K+ Views

CLOB stands for Character Large Object in general, an SQL Clob is a built-in datatype and is used to store large amount of textual data. Using this datatype, you can store data up to 2, 147, 483, 647 characters.The java.sql.Clob interface of the JDBC API represents the CLOB datatype. Since ... Read More

Get Random record from MongoDB?

Daniol Thomas

Daniol Thomas

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

1K+ Views

To get a random record from MongoDB, you can use aggregate function. The syntax is as follows:db.yourCollectionName.aggregate([{$sample:{size:1}}]);To understand the above syntax, let us create a collection with some documents. The query to create collection is as follows:>db.employeeInformation.insert({"EmployeeId":1, "EmployeeName":"Maxwell", "EmployeeAge":26}); WriteResult({ "nInserted" : 1 }) >db.employeeInformation.insert({"EmployeeId":2, "EmployeeName":"David", "EmployeeAge":25}); WriteResult({ "nInserted" : ... Read More

The contains() method of Java AbstractCollection class

Daniol Thomas

Daniol Thomas

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

73 Views

The contains() method of the AbstractCollection class checks whether an element is in the AbstractCollection or not. It returns a Boolean i.e. TRUE if the element is in the collection, else FALSE is returned.The syntax is as follows:public boolean contains(Object ele)Here, ele is the element to be checked for existence.To ... Read More

Write an JDBC example for inserting value for Clob data type into a table?

Daniol Thomas

Daniol Thomas

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

2K+ Views

Assume we already have a table named MyData in the database with the following description.+---------+--------------+------+-----+---------+-------+ | Field   | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+---------+-------+ | Name | varchar(255) | YES | ... Read More

Write an JDBC example to retrieve Clob value from a table using the getCharacterStream() method?

Daniol Thomas

Daniol Thomas

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

450 Views

The ResultSet interface provides the method named getClob() to retrieve clob datatype from a table in a database. In addition to this it also provides a method named getCharacterStream()Like getClob() this method also accepts an integer representing the index of the column (or, a String value representing the name of ... Read More

Advertisements