Samual Sam has Published 2492 Articles

How to count all characters in all rows of a field in MySQL?

Samual Sam

Samual Sam

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

794 Views

The syntax is as follows to count all characters in all rows of a field −select sum(char_length(yourColumnName)) 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 CountAllCharactersDemo    -> (    -> UserId int NOT ... Read More

LocalDate plusYears() method in Java

Samual Sam

Samual Sam

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

644 Views

An immutable copy of the LocalDate where the years are added to it can be obtained using the plusYears() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of years to be added and it returns the instant with the added years.A program ... Read More

Java Program to divide a number into smaller random ints

Samual Sam

Samual Sam

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

360 Views

We have considered a number 10 here, which will divided into 8 random ints with Random class. The number we have set as HashSet collection −HashSetset = new HashSet(); set.add(0); set.add(0); set.add(0); set.add(number);Now use nextInt to get the next random integer −intarrSize = parts + 1; while (set.size() < arrSize) ... Read More

How to get field name types from a MySQL database?

Samual Sam

Samual Sam

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

252 Views

You can use INFORMATION_SCHEMA.COLUMNS for this. Following is the syntax −SELECT COLUMN_NAME, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='yourTableName';Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientName varchar(60),    ClientAge int,    ClientSalary DECIMAL(10, 4),    isRegularClient bool   ... Read More

How to select part of a Timestamp in a MySQL Query?

Samual Sam

Samual Sam

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

130 Views

To select part of a timestamp in a query, you need to use YEAR() function. The syntax is as follows in MySQL.select YEAR(yourTimestampColumnName) 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 SelectPartOfTimestampDemo ... Read More

What is a Unit class in JavaTuples?

Samual Sam

Samual Sam

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

308 Views

A Unit class is a Tuple of one element. It is in the JavaTuples library.The following is the declaration −public final class Unit extends Tuple implements IValue0Let us first see what we need to work with JavaTuples. To work with Unit class in JavaTuples, you need to import the following ... Read More

LocalDate minusWeeks() Method in Java

Samual Sam

Samual Sam

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

118 Views

An immutable copy of the LocalDate where the weeks are subtracted from it can be obtained using the minusWeeks() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of weeks to be subtracted and it returns the instant with the subtracted weeks.A program ... Read More

Why can't we use column name “desc” in MySQL?

Samual Sam

Samual Sam

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

828 Views

The desc is a MySQL reserved word, therefore you cannot use it. But, if you still want to set the column name as ‘desc’, you need to use backticks. The backtick notation is (` `).To understand the above concept, let us create a table. The query to create a table is ... Read More

Java Program to convert LocalDate to java.util.Date

Samual Sam

Samual Sam

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

721 Views

Let us first set the LocalDate to current date −LocalDate date = LocalDate.now();Create an Instant −Instant i = date.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();Convert it to java.util.Date −java.util.Date.from(i)Example Live Demoimport java.time.Instant; import java.time.LocalDate; import java.time.ZoneId; public class Demo {    public static void main(String[] args) {       LocalDate date = LocalDate.now();       ... Read More

How to print result of a java expression in JSP?

Samual Sam

Samual Sam

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

2K+ Views

The tag displays the result of an expression. This is almost similar to the way works. The difference here is that tag lets you use the simpler "." notation to access properties. For example, to access customer.address.street, use the tag  .The tag can automatically escape XML ... Read More

Advertisements