Karthikeya Boyini has Published 2193 Articles

How to select the table with the greatest number of columns in MySQL?

karthikeya Boyini

karthikeya Boyini

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

127 Views

You can use INFORMATION_SCHEMA.COLUMNS to get the table with the greatest number of columns. The syntax is as follows −SELECT TABLE_NAME, COUNT(*) AS anyAliasName FROM INFORMATION_SCHEMA.COLUMNS GROUP BY TABLE_NAME ORDER BY yourAliasName DESC LIMIT 1;Following is the query to select the table that has the greatest number of columns. We are ... Read More

JavaTuples setAt0() method for Septet class

karthikeya Boyini

karthikeya Boyini

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

103 Views

The setAt0() method is used to set the Septet value in JavaTuples and a copy with new value at the specified index i.e. index 0 here.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package ... Read More

What is the use of jsp text action element?

karthikeya Boyini

karthikeya Boyini

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

159 Views

The action can be used to write the template text in JSP pages and documents. Following is the simple syntax for this action −Template dataThe body of the template cannot contain other elements; it can only contain text and EL expressions (Note − EL expressions are explained in a ... Read More

How to insert into two tables using a single MySQL query?

karthikeya Boyini

karthikeya Boyini

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

5K+ Views

You can use stored procedure to insert into two tables in a single query. Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentFirstName varchar(20) ); Query OK, 0 rows affected (0.56 sec)Here is the query to create second ... Read More

ByteBuffer asDoubleBuffer() method in Java

karthikeya Boyini

karthikeya Boyini

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

147 Views

A view of the ByteBuffer can be created as a DoubleBuffer using the asDoubleBuffer() method in the class java.nio.ByteBuffer. This method requires no parameters and it returns a double buffer as required. This buffer reflects the changes made to the original buffer and vice versa.A program that demonstrates this is ... Read More

How to calculate the possibilities of duplication for random number within a range in Java

karthikeya Boyini

karthikeya Boyini

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

191 Views

To get the duplicate numbers for random numbers in a range, loop through and create two Random class objects −Use nextInt() to get the next number −intrandVal1 = new Random().nextInt(50); intrandVal2 = new Random().nextInt(50);Now, compare both the above numbers −if (randVal1 == randVal2) {    System.out.println("Duplicate number = "+randVal1); }All ... Read More

Is there any easy way to add multiple records in a single MySQL query?

karthikeya Boyini

karthikeya Boyini

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

179 Views

You can easily add multiple items with only one insert command. The syntax is as follows −insert into yourTableName(yourColumnName1, yourColumnName2, ......N) values(yourValue1, yourValue2, ....N), (yourValue1, yourValue2, ....N), ..........N;Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Value1 int,    Value2 ... Read More

ByteBuffer asCharBuffer() method in Java

karthikeya Boyini

karthikeya Boyini

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

138 Views

A view of the ByteBuffer can be created as a CharBuffer using the asCharBuffer() method in the class java.nio.ByteBuffer. This method requires no parameters and it returns a char buffer as required. This buffer reflects the changes made to the original buffer and vice versa.A program that demonstrates this is ... Read More

Set Date value in Java HashMap?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

Create a Calendar instance and Date object −Calendar cal = Calendar.getInstance(); Date date = new Date(); cal.setTime(date);Now, create a HashMap and store Date value −LinkedHashMaphashMap = new LinkedHashMap(); hashMap.put("year", cal.get(Calendar.YEAR)); hashMap.put("month", cal.get(Calendar.MONTH)); hashMap.put("day", cal.get(Calendar.DAY_OF_MONTH));Example Live Demoimport java.util.Calendar; import java.util.Date; import java.util.LinkedHashMap; public class Demo {    public static void main(String[] argv) ... Read More

How do I change the case on every field in a MySQL table in a single call?

karthikeya Boyini

karthikeya Boyini

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

112 Views

You can use update along with lower() function for this. Let us first create a table −mysql> create table DemoTable (    Id varchar(100),    StudentFirstName varchar(20),    StudentLastName varchar(20),    StudentCountryName varchar(10) ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> ... Read More

Advertisements