Smita Kapse has Published 558 Articles

Java DatabaseMetaData getMaxCatalogNameLength() method with example.

Smita Kapse

Smita Kapse

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

15 Views

The getMaxCatalogNameLength() method of the DatabaseMetaData interface is used to find out the maximum number of characters that the underlying database allows in the name of a catalog.This method returns an integer value, representing the maximum number of characters allowed in a catalog name. If this value is 0 it ... Read More

How select specific rows in MySQL?

Smita Kapse

Smita Kapse

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

493 Views

To select specific rows, use FIND_IN_SET() function in MySQL. Let us first create a table −mysql> create table DemoTable    (    ListOfValues varchar(200)    ); Query OK, 0 rows affected (0.31 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('112, 114, 567, Java, 345'); ... Read More

MySQL query to display ASC order in number column?

Smita Kapse

Smita Kapse

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

206 Views

You can achieve this with the help of CAST() function. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Score int    ); Query OK,  0 rows affected (0.72 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Score) values(10); Query OK,  1 row affected (0.19 sec) mysql> insert into DemoTable(Score) values(100); Query OK,  1 row affected (0.14 sec) ... Read More

Listing all rows by group with MySQL GROUP BY?

Smita Kapse

Smita Kapse

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

1K+ Views

To list all rows by group, you can use GROUP_CONCAT(). Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(20),    Value varchar(100)    ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table ... Read More

Java DatabaseMetaData getMaxColumnsInIndex() method with example.

Smita Kapse

Smita Kapse

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

18 Views

The getMaxColumnsInIndex() method of the DatabaseMetaData interface is used to find out the maximum number of columns that the underlying database allows in an index.This method returns an integer value, representing the maximum number of columns allowed in an index. If this value is 0 it indicates that there is ... Read More

Allow multiple selection of nodes not necessarily contigous in JTree

Smita Kapse

Smita Kapse

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

246 Views

To allow multiple selection of nodes not necessarily contiguous, set the selection mode for tree to be DISCONTIGUOUS_TREE_SELECTION −tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);The following is an example to allow multiple selection of nodes, which are not necessarily contigous −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeSelectionModel; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Demo");       DefaultMutableTreeNode node = new DefaultMutableTreeNode("Products"); ... Read More

Display all deadlock logs in MySQL?

Smita Kapse

Smita Kapse

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

3K+ Views

First of all, you need to enable innodb_print_all_deadlocks. Following is the syntax −set global innodb_print_all_deadlocks=1;After executing the above statement, let us execute the below syntax in order to display all deadlock logs −show engine innodb status;Let us implement the above syntax −mysql> set global innodb_print_all_deadlocks=1; Query OK, 0 rows affected ... Read More

How to align multiple buttons with different height in Java?

Smita Kapse

Smita Kapse

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

394 Views

To align multiple buttons with different height in Java, try the following example, Here, we have set 5 buttons with GridBagConstraints −GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(5, 5, 5, 5); constraints.anchor = GridBagConstraints.WEST;In addition, to set different height for different buttons, we have used −component. getPreferredSize().heightThe following ... Read More

Select last 3 rows from database order by id ASC?

Smita Kapse

Smita Kapse

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

317 Views

You can use subquery. Following is the syntax −SELECT * FROM (    SELECT * FROM yourTableName ORDER BY yourIdColumnName DESC LIMIT 3 ) anyAliasName ORDER BY yourIdColumnName;Let us first create a table −mysql> create table DemoTable (    ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientName varchar(100) ); Query OK,  0 rows affected (0.60 sec)Insert some records in the table using insert command ... Read More

Matching an array field that contains any combination of the provided array in MongoDB?

Smita Kapse

Smita Kapse

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

190 Views

Use $nin operator along with $elemMatch and $not for this. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.combinationOfArrayDemo.insertOne({"StudentName":"Larry", "StudentAge":21, "StudentFavouriteTechnicalSubject":["C", "Java"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f77cc8d10a061296a3c58") } > ... Read More

Advertisements