You can achieve this with the help of INFORMATION_SCHEMA.COLUMNS. The syntax is as follows −SELECT CONCAT('ALTER TABLE ', TABLE_NAME, ' CHANGE `', COLUMN_NAME, '` `', LOWER(COLUMN_NAME), '` ', COLUMN_TYPE, ';') AS anyAliasName FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ‘yourDatabaseName’;Now use the database which has two tables. The database name is as follows “bothinnodbandmyisam”. This database is having the following tables −employeestudentThe description of the employee table is as follows −mysql> desc employee;The following is the output. Let’s say we have the following columns in the employee table which are not in lowercase −+--------------+-------------+------+-----+---------+-------+ | Field | Type ... Read More
The current instance of the clock with the UTC time zone can be obtained using the method systemUTC() in the Clock Class in Java. This method requires no parameters and it returns the current instance of the clock with the UTC time zone.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { Clock c = Clock.systemUTC(); Instant i = c.instant(); ZonedDateTime zdt = i.atZone(c.getZone()); System.out.println(zdt.toString()); } }Output2019-02-07T08:00:46.924ZNow let us understand the ... Read More
Let us create Unit Tuple in Java using with() method.Let us first see what we need to work with JavaTuples. To work with the Unit class in JavaTuples, you need to import the following package −import org.javatuples.Unit;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Unit Class in Java Tuples, 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.Unit; public class Demo { public static void main(String[] args) { Unit ... Read More
Yes, you can concatenate strings with || in MySQL with the help of sql_mode. Set the sql_mode to PIPES_AS_CONCAT.The syntax is as followsset sql_mode=PIPES_AS_CONCAT;The following is the syntax to concat with the help of ||.SELECT ‘yourValue' || yourColumName AS anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table PipeConcatDemo - > ( - > Name varchar(20) - > ); Query OK, 0 rows affected (0.93 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into PipeConcatDemo values('Larry'); Query ... Read More
Setting cookies with JSP involves three steps −Step 1: Creating a Cookie objectYou call the Cookie constructor with a cookie name and a cookie value, both of which are strings.Cookie cookie = new Cookie("key", "value");Keep in mind, neither the name nor the value should contain white space or any of the following characters −[ ] ( ) = , " / ? @ : ;Step 2: Setting the maximum ageYou use setMaxAge to specify how long (in seconds) the cookie should be valid. The following code will set up a cookie for 24 hours.cookie.setMaxAge(60*60*24);Step 3: Sending the Cookie into the ... Read More
This example demonstrate about How to use replace () in Android textview.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 as Edit text, when user click on button it will take data and replace all a values withStep 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; ... Read More
The toArray() method is inherited from the AbstractCollection() method. It returns an array containing similar elements in this collection.The syntax is as followspublic Object[] toArray()To work with the AbstractSequentialList class in Java, you need to import the following packageimport java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList toArray() method in JavaExample Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList absSequential = new LinkedList(); absSequential.add(210); absSequential.add(290); absSequential.add(350); absSequential.add(490); absSequential.add(540); absSequential.add(670); ... Read More
The toArray() method of the AbstractCollection class is used to return the elements in this collection. The elements are returned in the form of an array.The syntax is as followspublic Object[] toArray()To work with AbstractCollection class in Java, import the following packageimport java.util.AbstractCollection;At first, declare AbstractCollection and add some elementsAbstractCollection absCollection = new ArrayList(); absCollection.add("Laptop"); absCollection.add("Tablet"); absCollection.add("Mobile"); absCollection.add("E-Book Reader");Now, use the toArray() method to return the elements in the form of an arrayObject[] myArr = absCollection.toArray();The following is an example to implement AbstractCollection toArray() method in JavaExample Live Demoimport java.util.ArrayList; import java.util.AbstractCollection; public class Demo { public static void main(String[] ... Read More
The toString() method of the java.sql.Date class returns the escape format: yyyy-mm-dd of the date represented by the current date object. Using this method you can convert a Date object to a String.Date date = rs.getDate("Dispatch_Date"); date.toString());Assume we have a table named dispatch_data 3 records as shown below:+--------------+------------------+---------------+----------------+ | Product_Name | Name_Of_Customer | Dispatch_Date | Location | +--------------+------------------+---------------+----------------+ | KeyBoard | Amith | 1981-12-05 | Hyderabad | | Ear phones | Sumith | 1981-04-22 ... Read More
Yes, we can use the NOT and AND together in MongoDB. The syntax is as followsNOT X AND NOT Y = NOT (X AND Y) Let us see the working of above syntax. If both X and Y will be true then last result will be false. If one of the operands gives result false then last result will be true.Following is the query to create a collection with documents> db.NotAndDemo.insertOne({"StudentName":"John", "StudentCountryName":"US"}); { "acknowledged" : true, "insertedId" : ObjectId("5c98746a330fd0aa0d2fe4a8") } > db.NotAndDemo.insertOne({"StudentName":"John", "StudentCountryName":"UK"}); { "acknowledged" : true, "insertedId" : ObjectId("5c987478330fd0aa0d2fe4a9") } > db.NotAndDemo.insertOne({"StudentName":"David", "StudentCountryName":"AUS"}); { ... Read More