Samual Sam has Published 2492 Articles

Extracting filenames from a path in MySQL?

Samual Sam

Samual Sam

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

500 Views

To extract filenames from a path MySQL, you can use SUBSTRING_INDEX(). The syntax is as follows −SELECT SUBSTRING_INDEX(ypurColumnName, '\', -1) as anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table ExtractFileNameDemo -> ... Read More

ShortBuffer duplicate() method in Java

Samual Sam

Samual Sam

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

61 Views

A duplicate buffer of a buffer can be created using the method duplicate() in the class java.nio.ShortBuffer. This duplicate buffer is identical to the original buffer. The method duplicate() returns the duplicate buffer that was created.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public ... Read More

The contains() method of Java Unit Tuple

Samual Sam

Samual Sam

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

139 Views

To search a value in Unit class in JavaTuples, use the contains() method.Let us first see what we need to work with JavaTuples. To work with the Unit class in JavaTuples, you need to import the following package −import org.javatuples.Unit;Note − Steps to download and run JavaTuples program If you ... Read More

Java Program to get timezone id strings

Samual Sam

Samual Sam

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

144 Views

Let us get the timezone id strings for timezone America. For this, use the get.AvailableZoneIds() method −ZoneId.getAvailableZoneIds().stream().filter(s ->s.startsWith("America")) .forEach(System.out::println);With that, we have used the forEach to display all the timezones in America −America/Cuiaba America/Marigot America/El_Salvador America/Guatemala America/Belize America/Panama America/Managua America/Indiana/Petersburg America/Chicago America/Tegucigalpa America/Eirunepe America/Miquelon . . .Exampleimport java.time.ZoneId; public class ... Read More

ShortBuffer compareTo() method in Java

Samual Sam

Samual Sam

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

57 Views

A buffer can be compared with another buffer using the method compareTo() in the class java.nio.ShortBuffer. This method returns a negative integer if the buffer is less than the given buffer, zero if the buffer is equal to the given buffer and a positive integer if the buffer is greater ... Read More

What is a Pair class in Java Tuples?

Samual Sam

Samual Sam

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

139 Views

A Pair class in JavaTuples can only have 2 elements. The JavaTuples library includes the Pair class.The following is the declaration −public final class Pair extends Tuple implements IValue0, IValue1Let us first see what we need to work with JavaTuples. To work with Pair class in JavaTuples, you need to ... Read More

Java Program to get the seconds since the beginning of the Java epoch

Samual Sam

Samual Sam

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

402 Views

To get the seconds since the beginning of epochs, you need to use Instant. The method here used is ofEpochSecond() method. The epoch is the number of seconds that have elapsed since 00::00:00 Thursday, 1 January 1970.Get the seconds with ChronoUnit.SECONDS −long seconds = Instant.ofEpochSecond(0L).until(Instant.now(), ChronoUnit.SECONDS);Exampleimport java.time.Instant; import java.time.temporal.ChronoUnit; public ... Read More

Perform search/replace for only the first occurrence of a character in MySQL table records?

Samual Sam

Samual Sam

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

2K+ Views

You can achieve this with the help of CONCAT() along with REPLACE() function. To find the first occurrences you need to use INSTR() function.The syntax is as follows −UPDATE yourTableName SET UserPost = CONCAT(REPLACE(LEFT(yourColumnName, INSTR(yourColumnName, 'k')), 'k', 'i'), SUBSTRING(yourColumnName, INSTR(yourColumnName, 'k') + 1));To understand the above syntax, let us create ... Read More

Return a specific field in MongoDB?

Samual Sam

Samual Sam

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

306 Views

Too return a specific field, use the find() method in MongoDB. Let us first create a collection with documents −> db.specificFieldDemo.insertOne({"FirstName":"John", "LastName":"Doe"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb8019a623186894665ae31") } > db.specificFieldDemo.insertOne({"FirstName":"John", "LastName":"Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb801ab623186894665ae32") } > db.specificFieldDemo.insertOne({"FirstName":"David", "LastName":"Miller"}); {   ... Read More

What is a Septet class in Java Tuples?

Samual Sam

Samual Sam

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

63 Views

A Septet class is a Tuple of seven elements. It is part of the JavaTuples library.The following is the declaration −public final class Septet extends Tuple implements IValue1, IValue2, IValue3, IValue4, IValue5, IValue6, IValue7Let us first see what we need to work with JavaTuples. To work with Septet class in ... Read More

Advertisements