Insert Current Date in DATETIME Format in MySQL

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

974 Views

To insert the current date (not time), then you can use in-built function CURDATE() from MySQL. The syntax is as follows −INSERT INTO yourTableName values(curdate());Or if you want to add date and time both then you can use the in-built function NOW() from MySQL. The syntax is as follows −INSERT INTO yourTableName values(now());To understand both the syntax, let us first create a table. The query to create a table is as follows −mysql> create table NowAndCurdateDemo −> ( −> YourDueDate datetime −> ); Query OK, 0 rows affected (1.75 sec)Implement both ... Read More

Add Elements in the Middle of an ArrayList in Java

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

6K+ Views

Elements can be added in the middle of an ArrayList by using the java.util.ArrayList.add() method. This method has two parameters i.e. the index at which to insert the element in the ArrayList and the element itself. If there is an element already present at the index specified by ArrayList.add() then that element and all subsequent elements shift to the right by one.A program that demonstrates this is given as follows −Example Live Demoimport java.util.ArrayList; import java.util.List; public class Demo { public static void main(String args[]) throws Exception { List aList = new ... Read More

Check Write Permissions for a File in Java

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

819 Views

The method java.io.File.canWrite() is used to check whether the file can be written to in Java. This method returns true if the file specified by the abstract path name can be written to by an application and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       try {          File file = new File("demo1.txt");          file.createNewFile();          System.out.println("The file can be written to? " + file.canWrite());       } catch(Exception e) { ... Read More

Change Default Charset of a MySQL Table

Chandu yadav
Updated on 30-Jul-2019 22:30:24

890 Views

To change the default charset of a MySQL table, you can use the below syntax. The syntax is as follows −alter table yourTableName convert to character set yourCharsetName;Let us create a table and apply the above syntax to change the default charset. The query to create a table −mysql> create table CharsetDemo -> ( -> Id int, -> Name varchar(200), -> Age int -> ); Query OK, 0 rows affected (0.73 sec)Now you can change the charset of a table. The following is the query ... Read More

Select in MySQL Based on Month and Year

Rishi Rathor
Updated on 30-Jul-2019 22:30:24

2K+ Views

To select MySQL based on month and year, use in-built function YEAR() and MONTH(). The syntax is as follows −select *from yourTableName where YEAR(yourColumnName) = YearValue AND MONTH(yourColumnName) = monthValue;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table selectDataOnYearandMonthDemo −> ( −> BookId int, −> BookName varchar(100), −> BookDueDate datetime −> ); Query OK, 0 rows affected (0.57 sec)Now you can insert some records in the table. The query is as ... Read More

Append All Elements of Other Collection to ArrayList in Java

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

492 Views

The elements of a Collection can be appended at the end of the ArrayList using the method java.util.ArrayList.addAll(). This method takes a single parameter i.e. the Collection whose elements are added to the ArrayList.A program that demonstrates this is given as follows −Example Live Demoimport java.util.ArrayList; import java.util.Vector; public class Demo { public static void main(String[] args) { ArrayList aList = new ArrayList(); aList.add("John"); aList.add("Sally"); aList.add("Harry"); aList.add("Martha"); ... Read More

Importance of Social Reputation for the Scientific Community

Knowledge base
Updated on 30-Jul-2019 22:30:24

150 Views

Social reputation is a common desire for every human being. Having lived in a society, any person acquires some reputation depending on the behavior, etiquettes, profession, maintenance, nature etc. from the people around him. When we refer to a group of people who belong to a certain community, they usually form societies and communities and plan activities as we witness in social media daily, to increase their social reputation. Such activities often involve social causes.Scientific Community PeoplePeople who took science as their profession, especially Scientists, researchers, scholars etc. can be referred to as Scientific Community people. Unlike normal people, they ... Read More

Retrieve the Last Element from a LinkedList in Java

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

2K+ Views

The last element of a Linked List can be retrieved using the method java.util.LinkedList.getLast() respectively. This method does not require any parameters and it returns the last element of the LinkedList.A program that demonstrates this is given as follows −Example Live Demoimport java.util.LinkedList; public class Demo {    public static void main(String[] args) {       LinkedList l = new LinkedList();       l.add("Andy");       l.add("Sara");       l.add("James");       l.add("Betty");       l.add("Bruce");       System.out.println("The last element of the Linked List is : " + l.getLast());    } }OutputThe last ... Read More

What is Personification in English

Ridhi Arora
Updated on 30-Jul-2019 22:30:24

798 Views

Personification is the attributing of human characteristics, thoughts, or emotions to something that is non-human. It is a rhetoric device that is used to convey something more than a literary meaning of a sentence.Example: The heavens wept at the incident.Now, in this sentence, heavens cannot weep but the idea of emotions and weeping is produced through “wept”. Heaven is non-living and it is weeping just like humans do. Hence, the sentence features personification.Example: The thunder clapped angrily from a distance.Definitely, the thunder cannot clap. It is a non-living thing but the writer wants to convey the intensity of clapping by ... Read More

Get Absolute Path for Directory or File in Java

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

3K+ Views

The method java.io.File.getAbsolutePath() is used to obtain the absolute path name of a file or directory in the form of a string. This method requires no parameters.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       File file = new File("C:" + File.separator + "jdk11.0.2" + File.separator, "demo1.java");       System.out.println("The absolute path name is: " + file.getAbsolutePath());    } }The output of the above program is as follows −OutputThe absolute path name is:/C:/jdk11.0.2/demo1.javaNow let us understand the above program.The absolute pathname of ... Read More

Advertisements