Overloading Stream Insertion and Extraction Operators in C++

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

10K+ Views

C++ is able to input and output the built-in data types using the stream extraction operator >> and the stream insertion operator and insertion operator

Get the Last N Records in MongoDB

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

1K+ Views

To get the last N records in MongoDB, you need to use limit(). The syntax is as follows:db.yourCollectionName.find().sort({$natural:-1}).limit(yourValue);To understand the above syntax, let us create a collection with document. The query to create a collection with document is as follows:> db.getLastNRecordsDemo.insertOne({"EmployeeName":"Maxwell"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf3d6fd07954a4890689") } > db.getLastNRecordsDemo.insertOne({"EmployeeName":"Carol"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf496fd07954a489068a") } > db.getLastNRecordsDemo.insertOne({"EmployeeName":"Bob"}); { "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf4e6fd07954a489068b") } > db.getLastNRecordsDemo.insertOne({"EmployeeName":"Sam"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf546fd07954a489068c") } > db.getLastNRecordsDemo.insertOne({"EmployeeName":"Robert"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf596fd07954a489068d") } > db.getLastNRecordsDemo.insertOne({"EmployeeName":"Mike"}); ... Read More

Working Example of Session Maintenance in JSP

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

310 Views

This example describes how to use the HttpSession object to find out the creation time and the last-accessed time for a session. We would associate a new session with the request if one does not already exist.           Session Tracking                   Session Tracking                         Session info          Value     ... Read More

Get Particular Date Records from Timestamp in Android SQLite

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

723 Views

Before getting into example, we should know what sqlite data base 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 get particular date records from time stamp in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill ... Read More

period plusMonths Method in Java

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

147 Views

An immutable copy of the Period object where some months are added to it can be obtained using the plusMonths() method in the Period class in Java. This method requires a single parameter i.e. the number of months to be added and it returns the Period object with the added months.A program that demonstrates this is given as follows:Example 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

LocalDateTime getYear Method in Java

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

644 Views

The year for a particular LocalDateTime can be obtained using the getYear() method in the LocalDateTime class in Java. This method requires no parameters and it returns the year which can range from MIN_YEAR to MAX_YEAR.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalDateTime ldt = LocalDateTime.parse("2019-02-18T15:28:35");       System.out.println("The LocalDateTime is: " + ldt);       System.out.println("The year is: " + ldt.getYear());    } }OutputThe LocalDateTime is: 2019-02-18T15:28:35 The year is: 2019Now let us understand the above program.First the ... Read More

See Spaces in Data with MySQL Command Line Client

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

204 Views

Use quote() function for this. The syntax is as follows −select yourColumnName, quote(yourColumnName) from yourTableName;To understand the concept, let us create a table. The query to create a table is as follows −mysql> create table seeSpacesDemo    -> (    -> spaceValue varchar(10)    -> ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into seeSpacesDemo values(""); Query OK, 1 row affected (0.70 sec) mysql> insert into seeSpacesDemo values(" "); Query OK, 1 row affected (0.45 sec) mysql> insert into seeSpacesDemo values(" "); Query OK, 1 ... Read More

Delete a Row from ResultSet Object using JDBC

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

1K+ Views

The deleteRow() method of the ResultSet interface deletes the current row from the current ResultSet object.//Deleting a column from the ResultSet object rs.deleteRow();Assume we have a table named Cricketers_Data with 6 records as shown below:+----+------------+------------+---------------+----------------+-------------+ | ID | First_Name | Last_Name  | Year_Of_Birth | Place_Of_Birth | Country     | +----+------------+------------+---------------+----------------+-------------+ | 1  | Shikhar    | Dhawan     | 1981-12-05    | Delhi          | India | | 2  | Jonathan   | Trott      | 1981-04-22    | CapeTown       | SouthAfrica | | 3 ... Read More

Working with PDF Files in Python

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

1K+ Views

Python is a very versatile language as it provides huge set of libraries to work on different requirements. We all work on Portable Document Format (PDF) files. Python provides different ways to work with pdf files. In this we are going to use python library called PyPDF2 to work with pdf file.PyPDF2 is a pure-python PDF library capable of splitting, merging together, cropping, and transforming the pages of PDF files. It can also add custom data, viewing options, and passwords to PDF files. It can retrieve text and metadata from PDFs as well as merge entire files together.As we can ... Read More

Building Multiple Indexes at Once in MongoDB

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

2K+ Views

In order to build multiple indexes at once, you need to use createIndexes() and pass multiple keys into an array. Following is the query for building multiple indexes at once.>db.multipleIndexesDemo.createIndexes([{"First":1}, {"Second":1}, {"Third":1}, {"Fourth":1}, {"Fifth":1}]);This will produce the following output{    "createdCollectionAutomatically" : true,    "numIndexesBefore" : 1,    "numIndexesAfter" : 6,    "ok" : 1 }Now get all the indexes> db.multipleIndexesDemo.getIndexes();This will produce the following output[    {       "v" : 2,       "key" : {          "_id" : 1       },       "name" : "_id_",       ... Read More

Advertisements