Count the Number of Days in MySQL

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

447 Views

Let us first create a table with one column as datetime and another wherein the days are stored:mysql> create table DemoTable (    ShippingDate datetime,    CountOfDate int ); Query OK, 0 rows affected (0.52 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable values('2018-01-31', 6); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('2016-12-01', 15); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('2016-12-01', 10); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2016-12-01', 5); Query OK, 1 row affected (0.17 sec) ... Read More

LinkedTransferQueue in Java

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

71 Views

The LinkedTransferQueue Class in Java has a transfer queue that has unbounded functionality and is based on linked nodes. It uses FIFO for ordering elements. This class implements the Collection interface as well as the AbstractQueue class. It is a part of the Java Collection Framework.A program that demonstrates this is given as follows −Example Live Demoimport java.util.concurrent.LinkedTransferQueue; public class Demo {    public static void main(String[] args) throws InterruptedException {       LinkedTransferQueue ltQueue = new LinkedTransferQueue();       ltQueue.add("Amy");       ltQueue.add("John");       ltQueue.add("May");       ltQueue.add("Harry");       ltQueue.add("Anne");     ... Read More

CharBuffer Duplicate Method in Java

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

121 Views

A duplicate buffer of a buffer can be created using the method duplicate() in the class java.nio.CharBuffer. 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 class Demo {    public static void main(String[] args) {       int n = 5;       try {          CharBuffer buffer1 = CharBuffer.allocate(5);          buffer1.put('A');          buffer1.put('P');          buffer1.put('P');          buffer1.put('L'); ... Read More

C++ Program to Implement Bucket Sort

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

2K+ Views

In the Bucket Sorting technique, the data items are distributed of a set of buckets. Each bucket can hold similar type of data. After distributing, each bucket is sorted using another sorting algorithm. After that all elements are gathered into the main list to get the sorted form.The complexity of Bucket Sort TechniqueTime Complexity: O(n + k) for best case and average case and O(n2 ) for worst case.Space Complexity: O(nk) for worst caseInput − A list of unsorted data: 0.25 0.36 0.58 0.41 0.29 0.22 0.45 0.79 0.01 0.69 Output − Array after Sorting: 0.01 0.22 0.25 0.29 0.36 ... Read More

Use SQLite Version in Android

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

195 Views

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 demonstrate about How to use sqlite_version () in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create ... Read More

Get Android Build ID Programmatically

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

745 Views

This example demonstrate about How to get programmatically android build id.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 text view to show device id.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.Manifest; import android.app.ProgressDialog; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.webkit.CookieManager; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import ... Read More

Specify Encoding Type for Forms in JSP

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

473 Views

The tag is used to specify the encoding type used by forms that post data back to the Web application.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultkeyName of character encoding you want to apply when decoding request parameters.YesNoneYou use the tag when you want to specify the character encoding for decoding data posted from forms. This tag must be used with character encodings that are different from ISO-8859-1. The tag is required since most browsers do not include a Content-Type header in their requests.The purpose of the tag is to specify the content type of the request. ... Read More

Iterate Through Decade Tuple in Java

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

188 Views

To iterate through Decade Tuple, work it like any other collection in Java i.e. using a for loop, iterate and display the elements. Let us first see what we need to work with JavaTuples. To work with Decade class in JavaTuples, you need to import the following packageimport org.javatuples.Decade;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click 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 JavaTuples:Steps: How to run JavaTuples program ... Read More

period.toTotalMonths() Method in Java

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

79 Views

The total number of months for a particular Period can be obtained using the toTotalMonths() method in the Period class in Java. This method requires no parameters and it returns the total number of months in the Period in the form of a long value.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo {    public static void main(String[] args) {       String period = "P2Y1M15D";       Period p = Period.parse(period);       System.out.println("The Period is: " + p);       System.out.println("The total number of months are: " + ... Read More

Return Type of a Count Query Against MySQL Using Java JDBC

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

482 Views

The return type of count is long. The Java statement is as followsrs.next(); long result= rs.getLong("anyAliasName");First, create a table with some records in our sample database test3. The query to create a table is as followsmysql> create table CountDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into CountDemo(Name) values('John'); Query OK, 1 row affected (0.21 sec) mysql> insert into CountDemo(Name) values('Carol'); Query OK, 1 row affected (0.16 sec) ... Read More

Advertisements