Anvi Jain

Anvi Jain

427 Articles Published

Articles by Anvi Jain

Page 21 of 43

Insert a tab after the first tab of a JTabbedPane container

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 173 Views

We are inserting a tab just after the first tab by using the index value 1. Here, index 1 would be location 2nd i.e. just after the first tab of the JTabbedPane container.The following is an example to insert a tab after the first tab −Examplepackage my; import javax.swing.*; import java.awt.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Devices");       JTabbedPane tabbedPane = new JTabbedPane();       JTextArea text = new JTextArea(100, 100);       JPanel panel1, panel2, panel3, panel4, panel5, panel6, panel7, panel8;   ...

Read More

Android NotificationBuilder Example

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 191 Views

This example demonstrate about Android NotificationBuilder.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.     Step 3 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; public class MainActivity extends AppCompatActivity {    public static final String NOTIFICATION_CHANNEL_ID = "10001" ;    private final static String default_notification_channel_id = "default" ;    @Override    protected void ...

Read More

How to pull even numbers from an array in MongoDB?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 625 Views

Use $mod to get the even numbers and pull them from the array. Let us first create a collection with documents −>db.pullEvenNumbersDemo.insertOne({"AllNumbers":[101, 102, 104, 106, 108, 109, 110, 112, 14, 17, 18, 21]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd45b072cba06f46efe9eea") }Following is the query to display all documents from the collection with the help of find() method −> db.pullEvenNumbersDemo.find().pretty();This will produce the following output −{    "AllNumbers" : [       102,       104,       106,       108,       109,       110,       112,   ...

Read More

JDBC Class.forName vs DriverManager.registerDriver

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 6K+ Views

To connect with a database using JDBC you need to select get the driver for the respective database and register the driver. You can register a database driver in two ways −Using Class.forName() method − The forName() method of the class named Class accepts a class name as a String parameter and loads it into the memory, Soon the is loaded into the memory it gets registered automatically.Class.forName("com.mysql.jdbc.Driver");ExampleFollowing JDBC program establishes connection with MySQL database. Here, we are trying to register the MySQL driver using the forName() method.import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class RegisterDriverExample {    public static ...

Read More

How to send parameters from a notification-click to an Android activity?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 2K+ Views

This example demonstrate about How to send parameters from a notification-click to an Android activity.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.         Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Context ; import android.content.Intent ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.TextView ; public class MainActivity extends AppCompatActivity { ...

Read More

MongoDB divide aggregation operator?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 334 Views

You can use aggregate framework for this. Let us first create a collection with documents −>db.aggregationOperatorDemo.insertOne({"FirstValue":392883,"SecondValue":10000000000}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd541452cba06f46efe9f01") }Following is the query to display all documents from a collection with the help of find() method −> db.aggregationOperatorDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd541452cba06f46efe9f01"),    "FirstValue" : 392883,    "SecondValue" : 10000000000 }Following is the query to use divide aggregation operator −> db.aggregationOperatorDemo.aggregate([ ...   { "$project": { "Value": { "$divide": ["$FirstValue", "$SecondValue"] } } } ... ]);This will produce the following output −{ "_id" : ObjectId("5cd541452cba06f46efe9f01"), "Value" : 0.0000392883 }

Read More

How to add an extra new notification when push notification received in Android App?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 391 Views

This example demonstrate about How to add an extra new notification when push notification received in Android App.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.     Step 3 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.Toast ; public class MainActivity extends AppCompatActivity {    public static final String NOTIFICATION_CHANNEL_ID = "10001" ...

Read More

Update array in MongoDB document by variable index?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 418 Views

To update array in MongoDB document by variable index, use the below syntax. Here, yourIndexValue in the index value, where yourIndexVariableName is the variable name for index −var yourIndexVariableName= yourIndexValue, anyVariableName= { "$set": {} }; yourVariableName["$set"]["yourFieldName."+yourIndexVariableName] = "yourValue"; db.yourCollectionName.update({ "_id":  yourObjectId}, yourVariableName);Let us first create a collection with documents −> db.updateByVariableDemo.insertOne({"StudentSubjects":["MySQL", "Java", "SQL Server", "PL/SQL"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd553c37924bb85b3f4893a") }Following is the query to display all documents from a collection with the help of find() method −> db.updateByVariableDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd553c37924bb85b3f4893a"),    "StudentSubjects" : [       ...

Read More

How to suppress Android notification on lock screen but let it be in notification area?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 495 Views

This example demonstrate about How to suppress Android notification on lock screen but let it be in notification areaStep 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.     Step 3 − Add the following code to res/layout/custom_notification_layout.xml.             Step 4 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.KeyguardManager ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.content.Context ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import ...

Read More

How to start a transaction in JDBC?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 2K+ Views

A transaction is a unit of work that is performed against a database. Transactions are units or sequences of work accomplished in a logical order, whether in a manual fashion by a user or automatically by some sort of a database program.A transaction is the propagation of one or more changes to the database. For example, if you are creating a record or updating a record or deleting a record from the table, then you are performing a transaction on that table. It is important to control these transactions to ensure the data integrity and to handle database errors.Ending a ...

Read More
Showing 201–210 of 427 articles
« Prev 1 19 20 21 22 23 43 Next »
Advertisements