Digital Signature is a mathematical technique which is used to authenticate a digital document. This is equivalent to handwritten signature or a stamped seal and offers far more security and integrity to the message or digital document. It solves the problem of impersonation in digital communications by providing evidence of origin, identity and status of the digital transactions. Many countries like the United States of America consider digital signatures as legal. They even publish public laws, private laws and the Budget with digital signatures.How does a Digital Signature Work?Digital signatures are based on asymmetric cryptography, which means that the information ... Read More
If you will try to use the method drop(), then it will delete all information about the collection. Indexing is fast. However, if you will use the method remove(), then it removes all records but keeps the collection and indexes.Let us check with the help of example.Using drop()Let us first create a collection with documents −> db.dropWorkingDemo.createIndex({"FirstName":1}); { "createdCollectionAutomatically" : true, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > db.dropWorkingDemo.insertOne({"FirstName":"John"}); { "acknowledged" : true, "insertedId" : ObjectId("5cdd8742bf3115999ed511e9") }Following is the query to display all documents from a collection with the ... Read More
C++ has a standard library that contains common functionality you use in building your applications like containers, algorithms, etc. If names used by these were out in the open, for example, if they defined a queue class globally, you'd never be able to use the same name again without conflicts. So they created a namespace, std to contain this change.The using namespace statement just means that in the scope it is present, make all the things under the std namespace available without having to prefix std:: before each of them.While this practice is okay for example code, pulling in the ... Read More
We use gcc and g++ compilers in different times. Here we will see what are the differences between gcc and g++.The gcc is GNU C compiler, and g++ is GNU C++ compiler. The main differences are like below −gcc can compile *.c or *.cpp files as C and C++ respectivelyg++ can also compile *.c and *.cpp files, but take both as C++ fileIf we want to use g++ to link the object files, it automatically links in the STD C++ libraries. The gcc does not do thatgcc compiles C files which has fewer predefined macrosgcc compiles C++ files with more ... Read More
ResultSet holdability determines whether the ResultSet objects (cursors) should be closed or held open when a transaction (that contains the said cursor/ ResultSet object) is committed using the commit() method of the Connection interface.ResultSet interface provides two values to specify the holdability namely CLOSE_CURSORS_AT_COMMIT and HOLD_CURSORS_OVER_COMMITIf the holdability of the ResultSet object is set to this value. Whenever you commit/save a transaction using the commit() method of the Connection interface, the ResultSet objects created in the current transaction (that are already opened) will be held open.Therefore, if you need to hold the ResultSet cursor open after the commit automatically, set ... Read More
You can use $match operator under aggregate() to get the first record. Let us first create a collection with documents −> db.conditionalFirstDemo.insertOne({_id:100, "StudentName":"Chris", "StudentSubject":null}); { "acknowledged" : true, "insertedId" : 100 } > db.conditionalFirstDemo.insertOne({_id:101, "StudentName":"Chris", "StudentSubject":null}); { "acknowledged" : true, "insertedId" : 101 } >db.conditionalFirstDemo.insertOne({_id:102, "StudentName":"Chris", "StudentSubject":"MongoDB"}); { "acknowledged" : true, "insertedId" : 102 } >db.conditionalFirstDemo.insertOne({_id:103, "StudentName":"Chris", "StudentSubject":"MongoDB"}); { "acknowledged" : true, "insertedId" : 103 } > db.conditionalFirstDemo.insertOne({_id:104, "StudentName":"Chris", "StudentSubject":null}); { "acknowledged" : true, "insertedId" : 104 }Following is the query to display all documents from a collection with the help of find() method −> db.conditionalFirstDemo.find();This will produce the following ... Read More
To prevent resizing columns, use the method setResizingAllowed(). Here, we will set setResizingAllowed() to false for table header to disallow resizing of columns from header −table.getTableHeader().setResizingAllowed(false);Let us first see an example wherein we can easily resize columns in a table by resizing the table column header −Examplepackage my; import java.awt.Color; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; public class SwingDemo { public static void main(String[] argv) throws Exception { DefaultTableModel tableModel = new DefaultTableModel(); JTable table = new JTable(tableModel); tableModel.addColumn("Language/ Technology"); tableModel.addColumn("Text Tutorial"); ... Read More
Consensus protocol is one of the most important aspects that makes the Block chain network a fool proof system. It is the revolutionary protocol that makes the Block chain network an irrefutable system where the majority of devices (nodes) connected to the network agree on each and every transaction. This prevents exploitation of the system as more than 51% consensus is required to create a new block. It is the core of the Block Chain which makes it certain that the information stored on the Block Chain is accurate and honest.The very core of the Nakamoto’s Block chain consensus protocol ... Read More
Let’s say you have saved the Login date of users. Now, you want the count of records for specific date only i.e. login date. For this, use $gte and $lt operator along with count(). Let us first create a collection with documents −> db.findDataByDateDemo.insertOne({"UserName":"John", "UserLoginDate":new ISODate("2019-01-31")}); { "acknowledged" : true, "insertedId" : ObjectId("5cdd8cd7bf3115999ed511ed") } > db.findDataByDateDemo.insertOne({"UserName":"Larry", "UserLoginDate":new ISODate("2019-02-01")}); { "acknowledged" : true, "insertedId" : ObjectId("5cdd8ce7bf3115999ed511ee") } > db.findDataByDateDemo.insertOne({"UserName":"Sam", "UserLoginDate":new ISODate("2019-05-02")}); { "acknowledged" : true, "insertedId" : ObjectId("5cdd8cf3bf3115999ed511ef") } > db.findDataByDateDemo.insertOne({"UserName":"David", "UserLoginDate":new ISODate("2019-05-16")}); { "acknowledged" : true, "insertedId" : ObjectId("5cdd8d00bf3115999ed511f0") } > db.findDataByDateDemo.insertOne({"UserName":"Carol", ... Read More
A Json array is an ordered collection of values that are enclosed in square brackets i.e. it begins with ‘[’ and ends with ‘]’. The values in the arrays are separated by ‘, ’ (comma).Sample JSON array{ "books": [ Java, JavaFX, Hbase, Cassandra, WebGL, JOGL] }The json-simple is a light weight library which is used to process JSON objects. Using this you can read or, write the contents of a JSON document using Java program.JSON-Simple maven dependencyFollowing is the maven dependency for the JSON-simple library − com.googlecode.json-simple json-simple ... Read More