To count where more than three column values are true, you can use WHERE clause. Let us first create a table −mysql> create table DemoTable -> ( -> isMarried boolean, -> isActive boolean, -> isMember boolean, -> isOn boolean -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(true, false, true, false); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(false, false, false, false); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(true, true, ... Read More
In this section we will see how we can get the product of unique prime factor of a number in an efficient way. There is a number say n = 1092, we have to get product of unique prime factors of this. The prime factors of 1092 are 2, 2, 3, 7, 13. So the unique prime factors are {2, 3, 7, 13}, the product is 546. To solve this problem, we have to follow this rule −When the number is divisible by 2, then multiply 2 with product, and divide the number by 2 repeatedly, then next 2s will ... Read More
To get directories from JFileChoose, use the mode setFileSelectionMode −JFileChooser file = new JFileChooser(); file.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);The following is an example to get Directories from JFileChooser −Exampleimport javax.swing.JFileChooser; public class SwingDemo { public static void main(String[] args) { JFileChooser file = new JFileChooser(); file.setMultiSelectionEnabled(false); file.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int res = file.showOpenDialog(null); if (res == JFileChooser.APPROVE_OPTION) { java.io.File f = file.getSelectedFile(); System.err.println(f.getPath()); } } }Output
This example demonstrate about Android NotificationBuilder.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; public class MainActivity extends AppCompatActivity { public static final String NOTIFICATION_CHANNEL_ID = "10001" ; private final static String default_notification_channel_id = "default" ; @Override protected void ... Read More
You can use update() along with $ operator for this. Let us first create a collection with documents −> db.addAFieldDemo.insertOne( ... { ... ... "ClientName" : "Larry", ... "ClientCountryName" : "US", ... "ClientOtherDetails" : [ ... { ... "ClientProjectName":"Online Banking System" ... } ... ] ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5cd44bdc2cba06f46efe9ee8") }Following is the query to display all documents from a collection with the help of find() method −> db.addAFieldDemo.find().pretty();This ... Read More
Let us first create a toolbar −JToolBar toolbar = new JToolBar();Now, set the orientation to create vertical toolbar −toolbar.setOrientation(SwingConstants.VERTICAL);The following is an example to create a vertical toolbar in Java −package my; import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextArea; import javax.swing.JToolBar; import javax.swing.SwingConstants; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame(); JToolBar toolbar = new JToolBar(); toolbar.setOrientation(SwingConstants.VERTICAL); toolbar.add(new JTextArea()); toolbar.add(new JButton("Submit")); frame.add(toolbar, BorderLayout.WEST); frame.setTitle("Vertical ToolBar"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ... Read More
To get the tab size from a JTextArea, you can use the getTabSize() method −textArea.getTabSize();We will assign it to int variable and display the size in the Console −int size = textArea.getTabSize(); System.out.println("Tab Size = "+size);The following is an example to set the tab size of a JTextArea −Examplepackage my; import java.awt.GridLayout; import javax.swing.*; public class SwingDemo { SwingDemo() { JFrame frame = new JFrame(); JTextArea textArea = new JTextArea("This is demo text."); int size = textArea.getTabSize(); System.out.println("Tab Size = "+size); frame.add(textArea); ... Read More
Let us first create a table −mysql> create table DemoTable1 ( value int ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(10); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;Output+-------+ | value | +-------+ | 10 | +-------+ 1 row in set (0.00 sec)Following is the query to create second table −mysql> create table DemoTable2 ( value1 int ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table ... Read More
CachedRowSet interface does not provide any methods to determine whether a particular column exists.Therefore, to find whether a RowSet contains a specific column, you need to compare the name of each column in the RowSet with the required name. To do so −Retrieve the ResultSetMetaData object from the RowSet using the getMetaData() method.ResultSetMetaData meta = rowSet.getMetaData();Get the number of columns in the RowSet using the getColumnCount() method.int columnCount = meta.getColumnCount();The getColumnName() method returns the name of the column of the specified index. Using this method retrieve the column names of the RowSet from index 1 to column count and compare ... Read More
For this, you can use DATEDIFF() function. The current date time is as follows −mysql> select now(); +---------------------+ | now() | +---------------------+ | 2019-06-09 19:15:56 | +---------------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable -> ( -> ShippingDate datetime -> ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-06-01'); Query OK, 1 row affected (0.19 sec) ... Read More