Smita Kapse has Published 558 Articles

How to get the leaves of nodes in a JTree with Java?

Smita Kapse

Smita Kapse

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

372 Views

To get the leaves of nodes, use the getLeafCount() method.Let’s say you want the leaves of the entire tree, then use the root node, Let’s say “node” is our root node −node.getLeafCount()Now, let’s say we want to get the leaves of a node, which is not a root node, therefore ... Read More

Find the exact match in array without using the $elemMatch operator in MongoDB?

Smita Kapse

Smita Kapse

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

250 Views

As an alternative, use the $eq operator. Let us first create a collection with documents −> db.equalDemo.insertOne({_id:1, "StudentFriendNames":["John", "Carol", "Sam"]}); { "acknowledged" : true, "insertedId" : 1 } > db.equalDemo.insertOne({_id:2, "StudentFriendNames":null}); { "acknowledged" : true, "insertedId" : 2 } > db.equalDemo.insertOne({_id:3, "StudentFriendNames":["Carol"]}); { "acknowledged" : true, "insertedId" : 3 } ... Read More

How to run a timer in background within your iOS app

Smita Kapse

Smita Kapse

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

1K+ Views

If you wish to run a timer in background within your iOS Application, Apple provides beginBackgroundTaskWithExpirationHandler method, you can read more about the same https://developer.apple.com/documentation/uikit/uiapplication/1623031-beginbackgroundtaskwithexpiration.We will be using the same for writing our code for running the timer in background.So let’s begin.Step 1 − Open Xcode → Single View Application → ... Read More

Create empty border with BorderFactory class in Java?

Smita Kapse

Smita Kapse

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

365 Views

To create empty border, use the createEmptyBorder() method. Let us first create a label component −JLabel label = new JLabel("Label with empty border!");Now, create empty border with BorderFactory class −label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));The following is an example to create empty border −Examplepackage my; import javax.swing.BorderFactory; import java.awt.Font; import javax.swing.JFrame; import ... Read More

How can I remove a value from an enum in MySQL?

Smita Kapse

Smita Kapse

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

749 Views

Use ALTER command to remove a value from an enum in MySQL. Let us first create a table −mysql> create table DemoTable    (    `Rank` ENUM('LOW', 'MEDIUM', 'HIGH')    ); Query OK,  0 rows affected (0.52 sec)Let us check the description of table.mysql> DESC DemoTable;This will produce the following output −+-------+-----------------------------+------+-----+---------+-------+ | Field | Type       ... Read More

How to add an extra field in a sub document in MongoDB?

Smita Kapse

Smita Kapse

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

444 Views

You can use update(). Let us first create a collection with documents −> db.addExtraFieldDemo.insertOne(    {       "_id": 1,       "UserName": "Larry" ,       "UserOtherDetails":[          {             "UserCountryName": "US",             ... Read More

How to write data into BLOB and CLOB type columns in a table using JDBC?

Smita Kapse

Smita Kapse

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

2K+ Views

CLOB stands for Character Large Object. in general, an SQL Clob is a built-in datatype which is used to store large amount of textual data. Using this datatype, you can store data up to 2, 147, 483, 647 characters. MYSQL database provides support Clob datatype TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT.The java.sql.Clob ... Read More

Java Program to paste clipboard text to JTextArea

Smita Kapse

Smita Kapse

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

569 Views

To paste clopboard text to JTextArea, use tha paste () method. Let’s say the following is our text area −JTextArea textArea = new JTextArea("");Now, paste the clipboard text −textArea.paste();Note − Let’s say our clipboard text is “This is clipboard text that got inserted in the text area”.The following is an ... Read More

MySQL search results by month in format 2015-07-01 11:15:30?

Smita Kapse

Smita Kapse

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

46 Views

Use MONTH() and YEAR() for this. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ShippingDate datetime ); Query OK, 0 rows affected (0.54 sec)Insert some records in the ... Read More

MongoDB query to return specific fields from an array?

Smita Kapse

Smita Kapse

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

583 Views

To return specific fields, use aggregate $project. Let us first create a collection with documents −> db.returnSpecificFieldDemo.insertOne(    {       "StudentId":1,       "StudentDetails": [          {             "StudentName":"Larry",             "StudentAge":21,       ... Read More

Advertisements