Articles on Trending Technologies

Technical articles with clear explanations and examples

MySQL Select displaying Data type in a separate column?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 181 Views

You can use INFORMATION_SCHEMA.COLUMNS for this. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(20)    ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('Chris'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable(Name) values('Robert'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable(Name) values('Sam'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following ...

Read More

Can an interface extend multiple interfaces in Java?

raja
raja
Updated on 30-Jul-2019 9K+ Views

Yes, we can do it. An interface can extend multiple interfaces in Java.Example:interface A {    public void test();    public void test1(); } interface B {    public void test();    public void test2(); } interface C extends A,B {    public void test3(); } class D implements C {    public void test() {       System.out.println("Testing");    }    public void test1() {       System.out.println("Testing1");    }    public void test2() {       System.out.println("Testing2");    }    public void test3() {       System.out.println("Testing3");    } } public class Main {    public static void main(String[] args) {       D d=new D();       d.test();       d.test1();       d.test2();       d.test3();    }  }Output:Testing Testing1 Testing2 Testing3

Read More

How to combine FlowLayout and BoxLayout in Java?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 720 Views

To combine both the layouts, here we have created two panels −Frame f = new JFrame("Combining Layouts"); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel();Now, set the layouts accordingly −panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS)); panel2.setLayout(new FlowLayout());Then after adding components to both the panels, add them to the frame −f.add(panel1, BorderLayout.WEST); f.add(panel2, BorderLayout.CENTER);Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import javax.swing.BoxLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; public class SwingDemo {    public static void main(String[] args) {       JFrame f = new JFrame("Combining Layouts");       JPanel panel1 = new JPanel();       ...

Read More

Count the number of distinct values in MySQL?

Rama Giri
Rama Giri
Updated on 30-Jul-2019 284 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Name varchar(100),    -> Code varchar(100)    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', '0001'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Robert', '0002'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('Robert', '0003'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Chris', '0001'); Query OK, 1 row affected (0.12 sec)Display all records from the table using ...

Read More

C++ Program to Generate All Possible Subsets with Exactly k Elements in Each Subset

Samual Sam
Samual Sam
Updated on 30-Jul-2019 443 Views

This is a C++ program to generate all possible subsets with exactly k elements in each subset.AlgorithmsBegin    function PossibleSubSet(char a[], int reqLen, int s, int currLen, bool check[], int l):    If currLen > reqLen    Return    Else if currLen = reqLen       Then print the new generated sequence.    If s = l       Then return no further element is left.       For every index there are two options:          either proceed with a start as ‘true’ and recursively call PossibleSubSet()          with incremented value ...

Read More

Java ResultSet relative() method with example

Rishi Raj
Rishi Raj
Updated on 30-Jul-2019 1K+ Views

When we execute certain SQL queries (SELECT query in general) they return tabular data.The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.The relative() method of the ResultSet interface moves the ResultSet pointer/cursor n number of rows from the current position.This method returns an integer value representing the current row number to which the ResultSet pointer ...

Read More

C++ program to Solve Tower of Hanoi Problem using Binary Value

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 440 Views

This C++ program displays the solution to the Tower of Hanoi problem using binary value.There is one binary digit for each disk.The most significant bit represents the largest disk. A value of 0 indicates that the largest disk is on the initial peg, while a 1 indicates that it’s on the final peg.The bitstring is read from left to right, and each bit can be used to determine the location of the corresponding disk.The corresponding disk is stacked on top the previous disk on the same peg if a bit has the same value as the previous one.If it is ...

Read More

The ResultSet updateRow() method with example

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 2K+ Views

When we execute certain SQL queries (SELECT query in general) they return tabular data.The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.The updateRow() method of the ResultSet interface updates the contents of the current row to the database. For example if we have updated the values of a particular record using the updateXXX() ...

Read More

How to center a Window in Java?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 1K+ Views

To center a Window in Java, use the getCenterPoint() method. Set the width and height and use the below formulae to set bounds −Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); int width = 500; int height = 200; frame.setBounds(center.x - width / 2, center.y - height / 2, width, height);The following is an example to center a window −Examplepackage my; import java.awt.GraphicsEnvironment; import java.awt.GridLayout; import java.awt.Point; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.SwingConstants; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame.setDefaultLookAndFeelDecorated(true);       JFrame frame = new JFrame("Register!");     ...

Read More

Fetch records containing a specific character twice in MySQL

Rama Giri
Rama Giri
Updated on 30-Jul-2019 373 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Words text    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Ever'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Forever'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Good'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Never'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+---------+ | Words ...

Read More
Showing 57891–57900 of 61,297 articles
Advertisements