Ankith Reddy has Published 1070 Articles

Get the last record from a table in MySQL database with Java?

Ankith Reddy

Ankith Reddy

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

2K+ Views

To get data from MySQL database, you need to use executeQuery() method from java. First create a table in the MySQL database. Here, we will create the following table in the ‘sample’ databasemysql> create table javaGetDataDemo - > ( - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, - > ... Read More

The addIfAbsent() method of CopyOnWriteArrayList in Java

Ankith Reddy

Ankith Reddy

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

499 Views

The addIfAbsent() method appends the element if it is not in the list. If the element is already in the list, then FALSE is returned.The syntax is as follows.public boolean addIfAbsent(E ele)Here, ele is the element to be added to this list, if it is not already in the list.To ... Read More

How to get default phone MmsUserAgent in android?

Ankith Reddy

Ankith Reddy

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

84 Views

This example demonstrate about How to get default phone MmsUserAgent 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 ... Read More

Upsert in MongoDB while using custom _id values to insert a document if it does not exist?

Ankith Reddy

Ankith Reddy

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

509 Views

You need to use insert() for this. Whenever you insert custom _id values and the document already exist with the custom _id value then an error is visible. Let us first create a collection with documents. Under this, we tried adding the same document again and this resulted in an error> ... Read More

C++ default constructor

Ankith Reddy

Ankith Reddy

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

212 Views

A class constructor is a special member function of a class that is executed whenever we create new objects of that class.A constructor will have exact same name as the class and it does not have any return type at all, not even void. Constructors can be very useful for ... Read More

How to select ID column as null in MySQL?

Ankith Reddy

Ankith Reddy

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

438 Views

Let us first create a table. The query to create a table is as followsmysql> create table selectAllDemo - > ( - > Name varchar(100), - > Age int - > ); Query OK, 0 rows affected (1.90 ... Read More

How to return only a single property “_id” in MongoDB?

Ankith Reddy

Ankith Reddy

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

1K+ Views

Following is the syntax to return only a single property _id in MongoDBdb.yourCollectionName.find({}, {"_id": 1}).pretty();Let us first create a collection with documents> db.singlePropertyIdDemo.insertOne({"_id":101, "UserName":"Larry", "UserAge":21}); { "acknowledged" : true, "insertedId" : 101 } > db.singlePropertyIdDemo.insertOne({"_id":102, "UserName":"Mike", "UserAge":26}); { "acknowledged" : true, "insertedId" : 102 } > db.singlePropertyIdDemo.insertOne({"_id":103, "UserName":"Chris", "UserAge":24}); { ... Read More

Rename Root @ localhost username in MySQL?

Ankith Reddy

Ankith Reddy

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

509 Views

The syntax is as follows to rename Root @localhostUPDATE MySQL.user SET user = ‘yourNewRootName’ WHERE user = 'root';To understand the above concept, let us check all the user names and host. The query is as followsmysql> select user, host from MySQL.user;The following is the output+------------------+-----------+ | user       ... Read More

Strand sort in C++

Ankith Reddy

Ankith Reddy

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

230 Views

In this section we will see how we can sort some array or linked list using standard library of C++. In C++ there are multiple different libraries that can be used for different purposes. The sorting is one of them.The C++ function std::list::sort() sorts the elements of the list in ... Read More

The toString() method of Java AbstractCollection class

Ankith Reddy

Ankith Reddy

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

219 Views

The toString() method of the AbstractCollection class is used to return the string representation of the elements of this collection.The syntax is as followspublic String toString()To work with AbstractCollection class in Java, import the following packageimport java.util.AbstractCollection;The following is an example to implement AbstractCollection toString() method in JavaExample Live Demoimport java.util.ArrayList; ... Read More

Advertisements