Anvi Jain has Published 629 Articles

How to handle indexes in JavaDB using JDBC program?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

808 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 ... Read More

How to change date format with DATE_FORMAT() in MySQL?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

562 Views

You can change the MySQL date format with a specific format using DATE_FORMAT(). Following is the syntax −select date_format(yourColumnName, yourFormatSpecifier) from yourTableName;Let us first create a table −mysql> create table DemoTable    (    ShippingDate date    ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table ... Read More

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

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

173 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 ... Read More

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

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

436 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 ... 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 22:30:26

64 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; ... Read More

Sum up values in a single MySQL column in a specific way?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

96 Views

Use aggregate function SUM() along with OVER. Let us first create a table −mysql> create table DemoTable    (    CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    CustomerValue int    ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

Java Program to wrap text in a JTextPane and show Scrollbar

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

1K+ 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 ... Read More

Sort and Group in one MongoDB aggregation query?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

613 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: ... Read More

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

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

107 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 ... Read More

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

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

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 ... Read More

Advertisements