Krantik Chavan has Published 308 Articles

How to add items in a JComboBox on runtime in Java

Krantik Chavan

Krantik Chavan

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

1K+ Views

The following is an example to add items on runtime on a JComboBox in Java:Exampleimport java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame();       ... Read More

How to handle action event for JComboBox in Java?

Krantik Chavan

Krantik Chavan

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

633 Views

The following is an example to handle action event for JComboBox in Java:Exampleimport java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame();       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   ... Read More

LocalDate getDayOfYear() method in Java

Krantik Chavan

Krantik Chavan

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

341 Views

The day of the year for a particular LocalDate can be obtained using the getDayOfYear() method in the LocalDate class in Java. This method requires no parameters and it returns the day of the year which can be in the range of 1 to 365 and also 366 for leap ... Read More

Is it possible to make a case-insensitive query in MongoDB?

Krantik Chavan

Krantik Chavan

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

316 Views

Yes, you can use regexp to make a case-insensitive query in MongoDB. The syntax is as follows:db.yourCollectionName.find({"yourFieldName":/^yourvalue$/i});To understand the above syntax, let us create a collection with some documents. The query to create a collection with documents is as follows:> db.caseInsensitiveDemo.insertOne({"Name":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6d7a67f2db199c1278e7ef") ... Read More

Update field in exact element array in MongoDB?

Krantik Chavan

Krantik Chavan

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

211 Views

You can update the in exact element array in MongoDB with the help of below statement. The syntax is as follows:{"yourArrayDocumentName.$.yourNestedArrayDocument.yourPosition":"yourValue"}});To understand the above syntax, let us create a collection with some documents. The query to create a collection with document is as follows:> db.updateExactField.insertOne({"ActorId":1, "ActorDetails":[{"ActorName":"Johnny Depp", "MovieList": ["The Tourist", ... Read More

Find document with array that contains a specific value in MongoDB

Krantik Chavan

Krantik Chavan

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

704 Views

You can use find() method to find document with array that contains a specific value. The syntax is as follows:db.yourCollectionName.find({"yourArrayFieldName":"yourValue"}, .......N).pretty();To understand the above syntax, let us create a collection with documents. The query to create a collection with documents is as follows:>db.findSpecificValue.insertOne({"StudentId":1, "StudentName":"Larry", "FavouriteSubject":["C", "C++", "Java"]}); {    "acknowledged" ... Read More

What are Lob Data Types? What are the restrictions on these datatypes in JDBC?

Krantik Chavan

Krantik Chavan

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

164 Views

A BLOB is binary large object that can hold a variable amount of data with a maximum length of 65535 charactersThese are used to store large amounts of binary data, such as images or other types of files.A CLOB stands for Character Large Object in general, an SQL Clob is ... Read More

Get the count of only unique rows in a MySQL column?

Krantik Chavan

Krantik Chavan

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

138 Views

In MySQL, COUNT() will display the number of rows. DISTINCT is used to ignore duplicate rows and get the count of only unique rows.Let us first create a table:mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(10) ); Query OK, 0 rows affected ... Read More

How to remove array element in MongoDB?

Krantik Chavan

Krantik Chavan

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

704 Views

To remove array element in MongoDB, you can use $pull and $in operator. The syntax is as follows:db.yourCollectionName.update({},    {$pull:{yourFirstArrayName:{$in:["yourValue"]}, yourSecondArrayName:"yourValue"}},    {multi:true} );To understand the above syntax, let us create a collection with document. The query to create a collection with document is as follows:>db.removeArrayElement.insertOne({"StudentName":"Larry", "StudentCoreSubject":["MongoD B", "MySQL", "SQL ... Read More

How to handle date in JDBC?

Krantik Chavan

Krantik Chavan

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

1K+ Views

You can insert date values in SQL using the date datatype, The java.sql.Date class maps to the SQL DATE type.The PreparedStatement interface provides a method named setDate(). Using this you can insert date into a table. This method accepts two parameters −An integer representing the parameter index of the place ... Read More

Advertisements