JDBC API is available in two packages java.sql, core API and javax.sql JDBC optional packages. Following are the important classes and interfaces of JDBC.Class/interfaceDescriptionDriverManagerThis class manages the JDBC drivers. You need to register your drivers to this.It provides methods such as registerDriver() and getConnection().DriverThis interface is the Base interface for every driver class i.e. If you want to create a JDBC Driver of your own you need to implement this interface. If you load a Driver class (implementation of this interface), it will create an instance of itself and register with the driver manager.StatementThis interface represents a static SQL statement. ... Read More
This example demonstrate about How to get default phone IMEI 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 code, we have taken a text view to show phone IMEI.Step 3 − Add the following code to java/MainActivity.xmlpackage com.example.myapplication; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.telephony.TelephonyManager; import android.widget.TextView; import static android.Manifest.permission.READ_PHONE_NUMBERS; import static ... Read More
The ZERO field sets the duration to zero in the Duration class in Java. This field is quite the same as the null value in different data types in Java.A program that demonstrates the ZERO field is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { Duration d = Duration.ZERO; boolean flag = d.isZero(); System.out.println("The duration is: " + d); if(flag) System.out.println("The above duration is of zero length"); else ... Read More
Python provides various easy to use libraries for data visualization. Good thing is that these libraries works with small or large datasets.Some of the most commonly used python libraries for data visualizations are −MatplotlibPandasPlotlySeabornBelow we are going to plot different types of visualization chart for one fixed data to better analyse that data.We are going to analyze below data set to visualize through different charts −Country or AreaYear(s)VariantValueIndia2019Medium1368737.513India2019High1378419.072India2019Low1359043.965India2019Constant fertility1373707.838India2019Instant replacement1366687.871India2019Zero migration1370868.782India2019Constant mortality1366282.778India2019No change1371221.64India2019Momentum1367400.614Basic Plot Let's create some basic plots: Line plots, scatter plots and histogramsLine PlotsLine graphs are plots where a line is drawn to indicate a relationship between a particular ... Read More
The generate() method of the LongStream class returns an infinite sequential unordered stream where each element is generated by the provided LongSupplier.The syntax is as follows:static LongStream generate(LongSupplier s)Here, s is the LongSupplier for generate elements. The LongSupplier is the supplier of long-valued results.To use the LongStream class in Java, import the following package:import java.util.stream.LongStream;The following is an example to implement LongStream generate() method in Java −Example Live Demoimport java.util.stream.LongStream; public class Demo { public static void main(String[] args){ LongStream longStream = LongStream.generate(() -> { return (long)(Math.random() * 100); }); ... Read More
You can use SET command, but SET OPTIOn deprecated. Therefore, use SET SQL_SELECT_LIMIT.The syntax is as follows −SET SQL_SELECT_LIMIT=yourIntegerValue;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table MySQLSelectDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY -> ); Query OK, 0 rows affected (0.99 sec)Insert some records in the table using insert command. The query is as follows −mysql> INSERT INTO MySQLSelectDemo VALUES(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ... Read More
ReferencesWhen a variable is declared as reference, it becomes an alternative name for an existing variable.SyntaxType &newname = existing name;InitializatioType &pointer; pointer = variable name;PointersPointers are used to store the address of variable.SyntaxType *pointer;InitializationType *pointer; pointer = variable name;The main differences between references and pointers are -References are used to refer an existing variable in another name whereas pointers are used to store address of variable.References cannot have a null value assigned but pointer can.A reference variable can be referenced by pass by value whereas a pointer can be referenced but pass by reference.A reference must be initialized on declaration ... Read More
To create an index in MongoDB, use the ensureIndex() method. Let us first create a collection using following query> db.createCollection(&qu/ot;creatingUniqueIndexDemo"); { "ok" : 1 }Following is the query to create an index on the above collection:> db.creatingUniqueIndexDemo.ensureIndex({"UserCountryName":1}, {unique:true}); { "createdCollectionAutomatically" : false, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 }Following is the query to insert some documents in the above collection>db.creatingUniqueIndexDemo.insertOne({"UserName":"John", "UserAge":21, "UserCountryName":"US"}); { "acknowledged" : true, "insertedId" : ObjectId("5c9947bd330fd0aa0d2fe4d8") } >db.creatingUniqueIndexDemo.insertOne({"UserName":"Mike", "UserAge":23, "UserCountryName":"UK"}); { "acknowledged" : true, "insertedId" : ObjectId("5c9947c9330fd0aa0d2fe4d9") } >db.creatingUniqueIndexDemo.insertOne({"UserName":"Robert", "UserAge":26, "UserCountryName":"US"}); 2019-03-26T02:57:52.670+0530 E QUERY [js] WriteError: ... Read More
Social logins in applications have become a very common thing these days. Facebook login is one of them, in this article we’ll see how we can make use of facebook login, to access basic user information and login to the application.Implementing facebook login in an application is a series of multiple steps, out of which even a single step can not be skipped.The first step is to register as a developer on: https://developers.facebook.com/Once you sign up as a developer and complete the required steps to sign up, you will be taken to dashboard. Which at present looks like as shown ... Read More
You can use $ne operator for this. Let us first create a collection with documents −> db.searchByPropertyName.insertOne({"FirstName":"Larry", "Age":23}); { "acknowledged" : true, "insertedId" : ObjectId("5cbaf7af7219729fde21ddb5") } > db.searchByPropertyName.insertOne({"FirstName":null, "Age":21}); { "acknowledged" : true, "insertedId" : ObjectId("5cbaf7b97219729fde21ddb6") } > db.searchByPropertyName.insertOne({"FirstName":"John", "Age":22}); { "acknowledged" : true, "insertedId" : ObjectId("5cbaf7c57219729fde21ddb7") } > db.searchByPropertyName.insertOne({"FirstName":null, "Age":25}); { "acknowledged" : true, "insertedId" : ObjectId("5cbaf7d07219729fde21ddb8") } > db.searchByPropertyName.insertOne({"FirstName":"David", "Age":20}); { "acknowledged" : true, "insertedId" : ObjectId("5cbaf7df7219729fde21ddb9") }Following is the query to display all documents from the collection with the help of find() prettyprint −> db.searchByPropertyName.find().pretty();This will produce ... Read More