Get Total Number of Rows While Using LIMIT in MySQL

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

1K+ Views

To get the total number of rows when using LIMIT, use the following syntax −select SQL_CALC_FOUND_ROWS * FROM yourTableName LIMIT 0, yourLastValue;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table RowsUsingLimit -> ( -> Id int NOT NULL, -> Name varchar(10) -> ); Query OK, 0 rows affected (3.50 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into RowsUsingLimit values(10, 'Larry'); Query OK, ... Read More

Iterate Through Triplet Class in JavaTuples

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

291 Views

The iteration in Triplet class works in the same way as Arrays collection.Let us first see what we need to work with JavaTuples. To work with Triplet class in JavaTuples, you need to import the following package −import org.javatuples.Triplet;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Triplet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Triplet; public class Demo {    public static void main(String[] args) {       ... Read More

Implement GROUP BY Range in MySQL

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

1K+ Views

To group by range in MySQL, let us first create a table. The query to create a table is as followsmysql> create table GroupByRangeDemo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > YourRangeValue int    - > ); Query OK, 0 rows affected (0.78 sec)Now you can insert some records in the table using insert command.The query is as followsmysql> insert into GroupByRangeDemo(YourRangeValue) values(1); Query OK, 1 row affected (0.14 sec) mysql> insert into GroupByRangeDemo(YourRangeValue) values(7); Query OK, 1 row affected (0.15 sec) mysql> insert into GroupByRangeDemo(YourRangeValue) values(9); Query OK, 1 ... Read More

Print Date and Time in Specific Format Using JSP

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

1K+ Views

SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. SimpleDateFormat allows you to start by choosing any user-defined patterns for date-time formatting.Let us modify the above example as follows −Example Live Demo           Display Current Date & Time                        Display Current Date & Time                 Compile the above servlet once again and then call this servlet using the URL http://localhost:8080/CurrentDate. You will receive the following result −OutputDisplay Current Date & Time Mon 2010.06.21 at 10:06:44 PM GMT+04:00

Duration ofMinutes Method in Java

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

121 Views

The duration can be obtained in a one minute format using the ofMinutes() method in the Duration class in Java. This method requires a single parameter i.e. the number of minutes and it returns the duration in a one minute format. If the capacity of the duration is exceeded, then the ArithmeticException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { long minutes = 2; Duration duration = Duration.ofMinutes(minutes); ... Read More

Data Analysis and Visualization in Python

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

2K+ Views

Python provides numerous libraries for data analysis and visualization mainly numpy, pandas, matplotlib, seaborn etc. In this section, we are going to discuss pandas library for data analysis and visualization which is an open source library built on top of numpy.It allows us to do fast analysis and data cleaning and preparation.Pandas also provides numerous built-in visualization feautures which we are going to see below.InstallationTo install pandas, run the below command in your terminal −pipinstall pandasOrwe have anaconda, you can usecondainstall pandasPandas-DataFramesData framesa re the main tools when we are working with pandas.code −import numpy as np import pandas as ... Read More

Create Key-Value Tuple in Java

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

235 Views

To create a KeyValue tuple in Java, you can use the with() method, collection or simply the constructor. Here, we will see how to create a KeyValue tuple using a constructor. Let us first see what we need towork with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then RightClick Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run ... Read More

Sort in MongoDB

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

180 Views

To sort in MongoDB, you can use the sort() method.Case 1 − Sort in ascending order. The syntax is as follows −db.yourCollectionName.find().sort({yourField:1});Case 2 − Sort in descending order. The syntax is as follows −db.yourCollectionName.find().sort({yourField:-1});To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.sortingDemo.insertOne({"Value":100}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8f8e2ed3c9d04998abf006") } > db.sortingDemo.insertOne({"Value":1}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8f8e31d3c9d04998abf007") } > db.sortingDemo.insertOne({"Value":150}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8f8e34d3c9d04998abf008") } > db.sortingDemo.insertOne({"Value":250}); {    "acknowledged" : true, ... Read More

Update Column of a Row in CachedRowSet Object in JDBC

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

686 Views

The CachedRowSet is the base implementation of disconnected row sets. It connects to the data source, reads data from it, disconnects with the data source and the processes the retrieved data, reconnects to the data source and writes the modifications.You can create a Cached RowSet object using the createCachedRowSet() method of the RowSetFactory.You can create a RowSetFactory object using the newfactory() method of the RowSetProvider method.Updating a Particular column of a rowThe updateXXX() methods of the CachedRowSet interface allows you to update column values of a particular row in a RowSet object.Get the required row and update the desired column ... Read More

Difference Between Parcelable and Serializable in Android

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

456 Views

This example demonstrate about Difference between Parcel able and Serializable in androidSerializableSerializable is a markable interface or we can call as empty interface. It doesn’t have any pre-implemented methods. Serializable is going to convert object to byte stream. So user can pass the data between one activity to another activity. The main advantage of serializable is creation and passing data is very easy but it is a slow process compare to parcelable.A simple example of serializable as shown below –import java.io.Serializable; class serializableObject implements Serializable {    String name;    public serializableObject(String name) {       this.name = name; ... Read More

Advertisements