Get the returned record set ordered by (ORDER BY) position in MySQL 'IN' clause

Anvi Jain
Updated on 30-Jul-2019 22:30:25
To return record set order, you need to use FIND_IN_SET(). Let us first create a table −mysql> create table recordSetOrderDemo    -> (    -> EmployeeId int,    -> EmployeeName varchar(30)    -> ); Query OK, 0 rows affected (0.63 sec)Following is the query to insert some records in the table using insert command −mysql> insert into recordSetOrderDemo values(20, "John"); Query OK, 1 row affected (0.20 sec) mysql> insert into recordSetOrderDemo values(10, "Larry"); Query OK, 1 row affected (0.14 sec) mysql> insert into recordSetOrderDemo values(100, "Mike"); Query OK, 1 row affected (0.14 sec) mysql> insert into recordSetOrderDemo ... Read More

Java Program to adjust LocalDate to last Day of Month with TemporalAdjusters class

Krantik Chavan
Updated on 30-Jul-2019 22:30:25
Let us first set a date:LocalDate localDate = LocalDate.of(2019, Month.JUNE, 15)Now, adjust LocalDate to last Day of month;LocalDate day = localDate.with(TemporalAdjusters.lastDayOfMonth());Exampleimport java.time.LocalDate; import java.time.Month; import java.time.temporal.TemporalAdjusters; public class Demo {    public static void main(String[] args) {       LocalDate localDate = LocalDate.of(2019, Month.JUNE, 15);       System.out.println("Current Date = "+localDate);       System.out.println("Current Month = "+localDate.getMonth());       LocalDate day = localDate.with(TemporalAdjusters.firstDayOfMonth());       System.out.println("First day of month = "+day);       day = localDate.with(TemporalAdjusters.lastDayOfMonth());       System.out.println("Last day of month = "+day);       day = localDate.with(TemporalAdjusters.firstDayOfNextMonth());       ... Read More

MySQL query to list all the items in a group in one record?

George John
Updated on 30-Jul-2019 22:30:25
You can use GROUP_CONCAT() function to list all the items in a group in one record. Let us first create a table −mysql> create table DemoTable (    ProductId int,    ProductName varchar(40),    ProductCategory varchar(40) ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Product-1', '1Product'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(101, 'Product-2', '2Product'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(100, 'Product-1', '3Product'); Query OK, 1 row affected (0.14 sec)Following is the query to display all ... Read More

FloatBuffer allocate() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25
A new FloatBuffer can be allocated using the method allocate() in the class java.nio.FloatBuffer. This method requires a single parameter i.e. the capacity of the buffer. It returns the new FloatBuffer that is allocated. If the capacity provided is negative, then the IllegalArgumentException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       int n = 5;       try {          FloatBuffer buffer = FloatBuffer.allocate(n);          buffer.put(4.5F);          buffer.put(1.2F);   ... Read More

KeyPairGenerator getAlgorithm() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25
The algorithm name for the key pair generator can be obtained using the method getAlgorithm() in the class java.security.KeyPairGenerator. This method requires no parameters and it returns the algorithm name for the key pair generator.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("DSA");          String algorithm = kpGenerator.getAlgorithm();          System.out.println("The Algorithm is: " + algorithm);       } catch (NoSuchAlgorithmException e) {     ... Read More

How to use OR Conjunctive Operators in Android sqlite?

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25
Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use OR Conjunctive Operators in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details ... Read More

How to remove unused space for arraylist Listview in Android?

Nitya Raut
Updated on 30-Jul-2019 22:30:25
This example demonstrates How to remove unused space for arraylist Listview in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                     In the above code, we have taken name and record number as Edit text, when user click on save button it will store the data into arraylist. Click on ... Read More

How can I create custom tag in JSP which can accept attribute from parent jsp page?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25
You can use various attributes along with your custom tags. To accept an attribute value, a custom tag class needs to implement the setter methods, identical to the JavaBean setter methods as shown below −package com.tutorialspoint; import javax.servlet.jsp.tagext.*; import javax.servlet.jsp.*; import java.io.*; public class HelloTag extends SimpleTagSupport {    private String message;    public void setMessage(String msg) {       this.message = msg;    }    StringWriter sw = new StringWriter();    public void doTag()    throws JspException, IOException {       if (message != null) {          /* Use message from attribute ... Read More

How to escape characters that can be interpreted as XML markup in JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25
The fn:escapeXml() function escapes characters that can be interpreted as XML markup.SyntaxThe fn:escapeXml() function has the following syntax −java.lang.String escapeXml(java.lang.String)ExampleFollowing is the example to explain the functionality of the fn:escapeXml() function − Using JSTL Functions With escapeXml() Function: string (1) : ${fn:escapeXml(string1)} string (2) : ${fn:escapeXml(string2)} Without escapeXml() Function: string (1) : ${string1} string (2) : ${string2} You will receive the following result −With escapeXml() Function: string (1) : This is first String. string (2) : This is second String. Without escapeXml() Function − string (1) : This is first String. string (2) : This is second String.

How to use MEDIUMTEXT value in Android sqlite?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25
Before getting into an example, we should know what SQLite database in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built-in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrates How to use MEDIUMTEXT value in Android SQLite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a ... Read More
Advertisements