Smita Kapse has Published 498 Articles

How to create a date spinner in Java?

Smita Kapse

Smita Kapse

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

1K+ Views

To create a date spinner, use the SpinnerDateModel class. Within that set the date format −Date today = new Date(); JSpinner spinner2 = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor editor = new JSpinner.DateEditor(spinner2, "dd/MM/yy"); spinner2.setEditor(editor);Above, we have set the Date format to be −dd/MM/yyThe following is an example to ... Read More

MongoDB query for Partial Object in an array

Smita Kapse

Smita Kapse

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

446 Views

Let us first create a collection with documents −> db.queryForPartialObjectDemo.insertOne({_id:new ObjectId(), "StudentDetails": [{"StudentId":1, "StudentName":"Chris"}]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdfcf55bf3115999ed51206") } > db.queryForPartialObjectDemo.insertOne({_id:new ObjectId(), "StudentDetails": [{"StudentId":2, "StudentName":"David"}]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdfcf55bf3115999ed51207") }Following is the query to display all documents from a collection ... Read More

Except not working in MySQL?

Smita Kapse

Smita Kapse

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

539 Views

You cannot use except in MySQL. You can work with NOT IN operator to get the same result. Let us first create a table −mysql> create table DemoTable1  (  Number1 int  ); Query OK,  0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(100); Query OK,  1 row affected (0.14 sec) mysql> insert into DemoTable1 values(200); Query OK,  1 row affected (0.13 sec) ... Read More

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

Smita Kapse

Smita Kapse

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

498 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

323 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 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

580 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 to add an extra field in a sub document in MongoDB?

Smita Kapse

Smita Kapse

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

545 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

3K+ 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

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

73 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

Advertisements