Smita Kapse has Published 498 Articles

Java DatabaseMetaData getMaxColumnsInTable() method with example.

Smita Kapse

Smita Kapse

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

86 Views

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

How to use CHAR_LENGTH() in MySQL CREATE TABLE query?

Smita Kapse

Smita Kapse

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

112 Views

Use CHAR_LENGTH(yourColumnName) at the time of table creation. Let us first see an example and create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Title varchar(200),    `Number_of_characters` int as (char_length(Title))    ); Query OK, 0 rows affected (0.18 sec)Insert some ... Read More

Counting common elements in MySQL?

Smita Kapse

Smita Kapse

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

444 Views

To count common elements, use COUNT() and GROUP BY. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Number int    ); Query OK, 0 rows affected (0.20 sec)Insert some records in the table using insert command −mysql> ... Read More

Lower case column names with MySQL SELECT?

Smita Kapse

Smita Kapse

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

843 Views

Let us first create a table −mysql> create table DemoTable    (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserFirstName varchar(20),    UserLastName varchar(20),    UserAge int,    UserCountryName varchar(20)    ); Query OK, 0 rows affected (0.27 sec)Now check the description of table.mysql> desc DemoTable;This will produce ... Read More

How can I avoid “repair with keycache” in MySQL?

Smita Kapse

Smita Kapse

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

319 Views

To avoid repair with keycache in MySQL, you need to follow the below syntax −create table yourNewTableName as (select *from yourOldTableName); alter table yourNewTableName add index(yourCoumnName);Let us first create a table −mysql> create table DemoTable    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentFirstName varchar(20),    StudentLastName ... Read More

How select specific rows in MySQL?

Smita Kapse

Smita Kapse

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

647 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

315 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

37 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

364 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

Advertisements