Krantik Chavan

Krantik Chavan

176 Articles Published

Articles by Krantik Chavan

Page 9 of 18

How can I create a stored procedure to insert values in a MySQL table?

Krantik Chavan
Krantik Chavan
Updated on 22-Jun-2020 15K+ Views

We can create a stored procedure with an IN operator to insert values in a MySQL table. To make it understand we are taking an example of a table named ‘student_info’ having the following data −mysql> Select * from student_info; +------+---------+-----------+------------+ | id   | Name    | Address   | Subject    | +------+---------+-----------+------------+ | 100  | Aarav   | Delhi     | Computers  | | 101  | YashPal | Amritsar  | History    | | 105  | Gaurav  | Jaipur    | Literature | | 110  | Rahul  | Chandigarh | History    | +------+---------+------------+------------+ 4 rows ...

Read More

What is the difference between BLOB and CLOB datatypes?

Krantik Chavan
Krantik Chavan
Updated on 07-Jun-2020 16K+ Views

Blob and Clob together are known as LOB(Large Object Type). The following are the major differences between Blob and Clob data types.BlobClobThe full form of Blob is a Binary Large Object.The full form of Clob is Character Large Object.This is used to store large binary data.This is used to store large textual data.This stores values in the form of binary streams.This stores values in the form of character streams.Using this you can stores files like videos, images, gifs, and audio files.Using this you can store files like text files, PDF documents, word documents etc.MySQL supports this with the following datatypes:TINYBLOBBLOBMEDIUMBLOBLONGBLOBMySQL ...

Read More

Which is the best book for Java interview preparation

Krantik Chavan
Krantik Chavan
Updated on 25-Feb-2020 219 Views

Following books are on top from popularity and content wise and are a good resource to learn java programming from beginner to advance level.

Read More

How can we export data to a CSV file along with columns heading as its first line?

Krantik Chavan
Krantik Chavan
Updated on 07-Feb-2020 248 Views

For adding the column values we need to use UNION statement. It can be demonstrated with the help of the following example −ExampleIn this example data from student_info will be exporting to CSV file. The CSV file will have the first line as the name of the columns.mysql>(SELECT 'id', 'Name', 'Address', 'Subject')UNION(SELECT id, Name, Address, Subject From student_info INTO OUTFILE 'C:/mysql/bin/mysql-files/student_25.CSV' FIELDS ENCLOSED BY '"' TERMINATED BY ';' ESCAPED BY '"' LINES TERMINATED BY '\r'); Query OK, 7 rows affected (0.04 sec)After executing the above query MySQL creates Student_25.CSV file which have the following values −id;    "Name";     ...

Read More

Can we get the supported image types in Java

Krantik Chavan
Krantik Chavan
Updated on 30-Jul-2019 176 Views

Yes, we can get the supported image types with ImageIO class in Java. The following is an example to get supported image types in Java:Examplepackage my; import javax.imageio.ImageIO; public class SwingDemo {    public static void main(String[] args) throws Exception {       String[] imgTypes = ImageIO.getReaderFileSuffixes();       System.out.print("Supported Image Types = ");       for (String type : imgTypes) {          System.out.print("" + type);       }    } }OutputSupported Image Types = jpg tif tiff bmp gif png wbmp jpeg

Read More

How to change Button Border in Java Swing

Krantik Chavan
Krantik Chavan
Updated on 30-Jul-2019 1K+ Views

For Button border, use createLineBorder() method in Java, which allows you to set the color of the Border as well:JButton button = new JButton("Demo Button!"); Border border = BorderFactory.createLineBorder(Color.BLUE);The following is an example to change button border in Java:Exampleimport java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.border.Border; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Button Border");       Container container = frame.getContentPane();       JButton button = new JButton("Demo Button!");       Border border = BorderFactory.createLineBorder(Color.BLUE);       button.setBorder(border);   ...

Read More

How to set action command to JButton in Java

Krantik Chavan
Krantik Chavan
Updated on 30-Jul-2019 4K+ Views

With set action command, here we are displaying a message in the console on the click of a button.Set the button first:JButton btn = new JButton("Demo Button");Now, set Action Listener to fire when the button is clicked:ActionListener actionListener = new ActionListener() {    public void actionPerformed(ActionEvent event) {       String str = event.getActionCommand();       System.out.println("Clicked = " + str);    } };The following is an example to set action command to JButton:Exampleimport java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JOptionPane; public class SwingDemo {    public static void main(final String args[]) {       JButton btn ...

Read More

I want to call JButton doClick() method to simulate a click action in Java

Krantik Chavan
Krantik Chavan
Updated on 30-Jul-2019 1K+ Views

Let us first set a JButton:JButton btn = new JButton("DemoButton");Now, attach action listener:btn.addActionListener(new ClickListener());If you have an ActionListener attached to your button it'll fire when you call the method doClick():btn.doClick();The following is an example to call JButton doClick() method to simulate a click action:Exampleimport java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JOptionPane; public class SwingDemo {    public static void main(final String args[]) {       JButton btn = new JButton("DemoButton");       btn.addActionListener(new ClickListener());       JOptionPane.showMessageDialog(null, btn);       btn.doClick();    } } class ClickListener implements ActionListener {    public void actionPerformed(ActionEvent e) {   ...

Read More

How to change JButton font dynamically in Java?

Krantik Chavan
Krantik Chavan
Updated on 30-Jul-2019 2K+ Views

The following is an example to change JButton font dynamically:Exampleimport java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; public class SwingDemo extends JFrame {    JButton button = new JButton("Change");    int fontSize = 10;    public SwingDemo() {       setSize(500, 400);       setDefaultCloseOperation(EXIT_ON_CLOSE);       add(button);       // changing font size dynamically on button click       button.addActionListener(new ActionListener() {          public void actionPerformed(ActionEvent ev) {             button.setFont(new Font("Dialog", Font.PLAIN, ++fontSize));             button.revalidate();          }       });       setVisible(true);    }    public static void main(String[] args) {       new SwingDemo();    } }OutputClick “Change” button above to change the font:

Read More

How to disable JCheckBox if not checked in Java

Krantik Chavan
Krantik Chavan
Updated on 30-Jul-2019 887 Views

The following is an example to disable JCheckBox if not checked in Java:Exampleimport java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JCheckBox; import javax.swing.JOptionPane; public class SwingDemo {    public static void main(String[] args) {       JCheckBox checkBox = new JCheckBox("Demo", true);       checkBox.addActionListener(new ActionListener() {          public void actionPerformed(ActionEvent e) {             if (checkBox.isEnabled())                checkBox.setEnabled(false);             else                checkBox.setEnabled(true);          }       });       JOptionPane.showMessageDialog(null, checkBox);    } }OutputNow, when you will uncheck the above checkbox, it will get disabled:

Read More
Showing 81–90 of 176 articles
« Prev 1 7 8 9 10 11 18 Next »
Advertisements