Anvi Jain

Anvi Jain

427 Articles Published

Articles by Anvi Jain

Page 24 of 43

How to handle indexes in JavaDB using JDBC program?

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

Indexes in a table are pointers to the data, these speed up the data retrieval from a table. If we use indexes, the INSERT and UPDATE statements get executed in a slower phase. Whereas SELECT and WHERE get executed with in lesser time.Creating an indexCTREATE INDEX index_name on table_name (column_name);Displaying the IndexesSHOW INDEXES FROM table_name;Dropping an indexDROP INDEX index_name;Following JDBC program creates a table with name Emp in JavaDB. creates an index on it, displays the list of indexes and, deletes the created index.Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class IndexesExample {    public static void main(String ...

Read More

How to check which notifications are active in status bar in iOS?

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

To get the list of notifications which are active on your status bar tray we are going to use getdeliverednotifications, you can read more about it here.https://developer.apple.com/documentation/usernotifications/unusernotificationcenterhttps://developer.apple.com/documentation/usernotifications/unusernotificationcenter/1649520-getdeliverednotificationsWhile it is know that we cannot get the notifications from all apps as that would be a privacy violation, but we can get the notification for our applicationApple provide getDeliveredNotifications(completionHandler:)Which returns a list of the app’s notifications that are still displayed in Notification Center.You can write the following code depending upon your need.UNUserNotificationCenter.current().getDeliveredNotifications { (notifications) in    print(notifications) }

Read More

How to add components with relative X and Y Coordinates in Java?

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

To add components with relative X and Y coordinates, you need to set both the gridx and gridy components −GridBagConstraints constraints = new GridBagConstraints(); constraints.gridy = GridBagConstraints.RELATIVE; constraints.gridx = GridBagConstraints.RELATIVE;The following is an example to add components with relative X and Y Coordinates −Examplepackage my; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame();       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       JPanel panel = new JPanel();       panel.setLayout(new GridBagLayout());       GridBagConstraints constraints = new GridBagConstraints();   ...

Read More

To display a database in the SHOW dbs list, do we need to add collections to it?

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

Yes, to display a database in the list, first create a database and add collection(s), else it won’t be visible in the list. After that, use the SHOW dbs command to display the database name in the list of databases.Following is the query to create a database −> use webcustomertracker; switched to db webcustomertrackerLet us first create a collection with documents −> db.first_Collection.insert({"Name":"Chris"}); WriteResult({ "nInserted" : 1 })Following is the query to display all documents from a collection with the help of find() method −> db.first_Collection.find();This will produce the following output −{ "_id" : ObjectId("5ce2760836e8b255a5eee94a"), "Name" : "Chris" }Following is ...

Read More

Java Program to wrap text in a JTextPane and show Scrollbar

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

Let’s say we have lots of content in our JTextPane component −textPane.setText("This is demo text1. This is demo text2. This is demo text3."    + "This is demo text4.This is demo text5. This is demo text6. "    + "This is demo text7. This is demo text8. This is demo text9. "    + "This is demo text10. This is demo text11. This is demo text12."    + "This is demo text13. This is demo text13. This is demo text14."    + "This is demo text15. This is demo text13. This is demo text16."    + " This is demo ...

Read More

Sort and Group in one MongoDB aggregation query?

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

For sorting and grouping in a single query, use the $group operator along with aggregate framework. Let us first create a collection with documents −> db.sortAndGroupDemo.insertOne({    Price :40,    Product: 10 }); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce8f2bc78f00858fb12e907") } > db.sortAndGroupDemo.insertOne({    Price :100,    Product: 10 }); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce8f2bc78f00858fb12e908") } > db.sortAndGroupDemo.insertOne({    Price :90,    Product: 20 }); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce8f2bc78f00858fb12e909") } > db.sortAndGroupDemo.insertOne({    Price :200,    Product: 10 }); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce8f2bc78f00858fb12e90a") } ...

Read More

MySQL query to decrease the value of a specific record to zero?

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

Use SET to decrease the value and WHERE to set the condition for a specific record to be 0. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Number int ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command &minusmysql> insert into DemoTable(Number) values(10); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Number) values(20); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Number) values(1); Query OK, 1 row affected ...

Read More

MongoDB query select and display only a specific field from the document?

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

Let us first create a collection with documents −> db.querySelectDemo.insertOne({UserId:100, UserName:"Chris", UserAge:25}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce90eb478f00858fb12e90e") } > db.querySelectDemo.insertOne({UserId:101, UserName:"Robert", UserAge:26}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce90ec578f00858fb12e90f") } > db.querySelectDemo.insertOne({UserId:103, UserName:"David", UserAge:27}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce90ed478f00858fb12e910") }Following is the query to display all documents from a collection with the help of find() method −> db.querySelectDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5ce90eb478f00858fb12e90e"),    "UserId" : 100,    "UserName" : "Chris",    "UserAge" : 25 } {    "_id" : ObjectId("5ce90ec578f00858fb12e90f"),    "UserId" : 101, ...

Read More

Which MySQL Data Type can be used to store Negative Number?

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

You can use TINYINT data type in MySQL to store negative number. Following is the syntax −CREATE TABLE yourTableName ( yourColumnName TINYINT . . . . N );Let us first create a table with a column set as type TINYINT −mysql> create table DemoTable ( Number tinyint ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert ...

Read More

Generic way to validate textField inputs in Swift

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

How often you develop an application and you write same validation for every input fields. One such example is User registration, Login screen or Registration screen or any other screen. It becomes tedious to write same line of code for every input field moreover you may tend to mistake the same.As per the design it is never recommend to write validation for each field, rather you should be writing generic validation functions.So in this blog we will be writing generic validation library of input Text Fields.Advantages of writing genetic validation library.Reuse able code for all functions.Chances of human error getting ...

Read More
Showing 231–240 of 427 articles
« Prev 1 22 23 24 25 26 43 Next »
Advertisements