Achieve Case-Sensitive Uniqueness and Case-Insensitive Search in MySQL

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

1K+ Views

You can achieve case sensitive uniqueness and case insensitive search with the help of the following two ways −VARBINARY data type_bin collationVARBINARY data typeTo work with the VARBINARY data type, let us first create a table. The query to create a table is as follows −mysql> create table SearchingDemo2 -> ( -> UserId VARBINARY(128) NOT NULL, -> UNIQUE KEY index_on_UserId2(UserId ) -> )ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; Query OK, 0 rows affected, 1 warning (0.99 sec)Keep in mind UserId has data type VARBINARY(128) and Index(‘index_on_UserId2’) on a column ‘UserId’._bin ... Read More

Set Title for Action Bar in Android

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

5K+ Views

This example demonstrates How to set title for action bar 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 text view to show status bar tittle.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity ... Read More

Period withMonths Method in Java

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

173 Views

An immutable copy of a Period with the number of months as required is done using the method withMonths() in the Period class in Java. This method requires a single parameter i.e. the number of months in the Period and it returns the Period with the number of months as required.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 = "P5Y7M15D";       Period p1 = Period.parse(period);       System.out.println("The Period is: " + p1);       Period p2 ... Read More

LocalTime toString Method in Java

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

862 Views

The string value of the LocalTime object can be obtained using the method toString() in the LocalTime class in Java. This method requires no parameters and it returns the string value of the LocalTime object.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.parse("23:15:30");       System.out.println("The LocalTime is: " + lt.toString());    } }OutputThe LocalTime is: 23:15:30Now let us understand the above program.The string value of the LocalTime is obtained using the method toString() and then this value ... Read More

MongoDB Query Condition on Comparing Two Fields

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

400 Views

To query condition on comparing 2 fields, use the following syntax −db.yourCollectionName.find( { $where: function() { return this.yourFirstFieldName < this.yourSecondFieldName } } ).pretty();To understand the syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.comparingTwoFieldsDemo.insertOne({"StudentName":"John", "StudentAge":21, "StudentMathMarks":99, "StudentPhysicsMarks":98}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ac09e6cea1f28b7aa0807") } > db.comparingTwoFieldsDemo.insertOne({"StudentName":"Carol", "StudentAge":22, "StudentMathMarks":79, "StudentPhysicsMarks":89}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ac0b46cea1f28b7aa0808") } > db.comparingTwoFieldsDemo.insertOne({"StudentName":"David", "StudentAge":24, "StudentMathMarks":39, "StudentPhysicsMarks":45}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ac0c96cea1f28b7aa0809") } > db.comparingTwoFieldsDemo.insertOne({"StudentName":"Bob", "StudentAge":23, "StudentMathMarks":87, "StudentPhysicsMarks":78}); {    "acknowledged" : ... Read More

Convert Primitive Array to Stream in Java

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

266 Views

To convert Primitive Array to Stream, you need to use the of() method.Let’s say the following is our Primitive Array:int[] myArr = new int[] { 20, 50, 70, 90, 100, 120, 150 };Now, use the of() method to convert the primitive array to stream:IntStream stream = IntStream.of(myArr);The following is an example to convert primitive array to stream in Java:Example Live Demoimport java.util.stream.IntStream; import java.util.*; public class Main {    public static void main(String[] args) {       int[] myArr = new int[] { 20, 50, 70, 90, 100, 120, 150 };       System.out.println("The Primitive Array = "+Arrays.toString(myArr));   ... Read More

MySQL Query to Display Databases Sorted by Creation Date

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

578 Views

You can display databases sorted by creation date with ORDER BY clause. Following is the query to display all databases −mysql> show databases;This will produce the following output −+---------------------------+ | Database                  | +---------------------------+ | bothinnodbandmyisam       | | business                  | | commandline               | | customer_tracker_database | | customertracker           | | database1                 | | databasesample            | | demo ... Read More

Loop Through Map by Map Entry in Java

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

200 Views

Create a Map and insert elements to in the form of key and value −HashMap map = new HashMap (); map.put("1", "A"); map.put("2", "B"); map.put("3", "C"); map.put("4", "D"); map.put("5", "E"); map.put("6", "F"); map.put("7", "G"); map.put("8", "H"); map.put("9", "I");Now, loop through Map by Map.Entry. Here, we have displayed the key and value separately −Sets = map.entrySet(); Iteratori = s.iterator(); while (i.hasNext()) {    Map.Entrye = (Map.Entry) i.next();    String key = (String) e.getKey();    String value = (String) e.getValue();    System.out.println("Key = "+key + " => Value = "+ value); }Example Live Demoimport java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; ... Read More

Perform Custom Sort by Field Value in MySQL

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

167 Views

To perform custom sort by field value in MySQL, use the FIELD() method in ORDER BY. Let us first create a table:mysql> create table DemoTable (StudentId int); Query OK, 0 rows affected (0.58 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(110); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(90); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(70); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(120); Query ... Read More

Create ASM File Using a Text Editor

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

5K+ Views

The program written in assembly language is entered by us by the help of any editor, we prefer a screen editor because when we enter the program it is of no importance for the particular exact column label of instructions and the starting of the program. But the point to be noted that the instruction must start after column 1. More over the aligned program must be lucidly written for reading if its various fields should be assigned properly. There are many features which the editor provides like many help features which the user gets to be more familiar by ... Read More

Advertisements