Karthikeya Boyini has Published 2193 Articles

MongoDB query to find property of first element of array?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

You can use $slice operator for this. Let us first create a collection with documents −> db.firstElementOfArray.insertOne( ...    { ...       _id: 100, ...       "Details": [ ...          { ...             "CustomerName": "John", ...     ... Read More

How can you upload a file using JSP?

karthikeya Boyini

karthikeya Boyini

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

538 Views

A JSP can be used with an HTML form tag to allow users to upload files to the server. An uploaded file can be a text file or a binary or an image file or just any document.Creating a File Upload FormLet us now understand how to create a file ... Read More

Java Tuples addAtX() method for Pair class

karthikeya Boyini

karthikeya Boyini

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

91 Views

The addAtX() method is used to add value at a particular position represented by X here.Let us first see what we need to work with JavaTuples. To work with Pair class in JavaTuples, you need to import the following package −import org.javatuples.Pair;Here we have also used the Triplet class, therefore ... Read More

Is RowSet Scrollable? Explain with an example?

karthikeya Boyini

karthikeya Boyini

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

490 Views

A RowSet object is similar to ResultSet, it also stores tabular data, in addition to the features of a ResultSet. A RowSet follows the JavaBeans component model.If you Retrieve a ResultSet object by default the cursor of it moves only in forward direction. i.e. you can retrieve the contents of ... Read More

Java 8 Clock fixed() method

karthikeya Boyini

karthikeya Boyini

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

432 Views

The fixed instant on the clock can be obtained using the method fixed() in the Clock Class in Java. This method requires two parameters i.e. the fixed instant and the time zone. Also, it returns the fixed instant on the clock. The fixed() method is normally used for testing purposes.A ... Read More

How to print current date and time in a JSP page?

karthikeya Boyini

karthikeya Boyini

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

14K+ Views

With JSP program, it is very easy to get the current date and the time. You can use a simple Date object with the toString() method to print the current date and the time as follows −Example Live Demo           Display Current Date & Time   ... Read More

Java Program to create custom DateTime formatter

karthikeya Boyini

karthikeya Boyini

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

212 Views

To create custom DateTime formatter, use DateTimeFormatter. Let us first see for Time −DateTimeFormatter dtFormat = new DateTimeFormatterBuilder() .appendValue(ChronoField.HOUR_OF_DAY) .appendLiteral(":") .appendValue(ChronoField.MINUTE_OF_HOUR) .appendLiteral(":") .appendValue(ChronoField.SECOND_OF_MINUTE) .toFormatter();For Date −dtFormat = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR) .appendLiteral("/") .appendValue(ChronoField.MONTH_OF_YEAR) .appendLiteral("/") .appendValue(ChronoField.DAY_OF_MONTH) .toFormatter();Exampleimport java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.ChronoField; public class Demo {    public static void ... Read More

Finding matching records with LIKE in MongoDB?

karthikeya Boyini

karthikeya Boyini

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

129 Views

Let us first create a collection with documents −> db.likeDemo.insertOne({"Name":"John", Age:32}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb84984623186894665ae41") } > db.likeDemo.insertOne({"Name":"Chris", Age:25}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb84991623186894665ae42") } > db.likeDemo.insertOne({"Name":"Carol", Age:22}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb849a1623186894665ae43") } > db.likeDemo.insertOne({"Name":"Johnny", Age:22}); ... Read More

MySQL command to order timestamp values in ascending order?

karthikeya Boyini

karthikeya Boyini

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

4K+ Views

You can use ORDER BY ASC to order timestamp values in ascending order with TIMESTAMP() method.The following is the syntax using TIMESTAMP() −SELECT timestamp( yourTimestampColumnName ) as anyAliasName From yourTableName order by 1 ASCTo understand the above syntax, let us create a table. The query to create a table is ... Read More

Create Quintet Tuple from another collection in Java

karthikeya Boyini

karthikeya Boyini

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

108 Views

To create a tuple from another collection, you need to use fromCollection() method.Let us first see what we need to work with JavaTuples. To work with Quintet class in JavaTuples, you need to import the following package −import org.javatuples.Quintet;Note − Steps to download and run JavaTuples program If you are ... Read More

Advertisements