Programming Articles

Page 1691 of 2547

Java DatabaseMetaData supportsGroupBy() method with example

Rishi Raj
Rishi Raj
Updated on 08-Nov-2024 220 Views

In this article, we will learn how to check whether a database supports the SQL GROUP BY clause using JDBC in Java. The GROUP BY clause is used to organize identical data into groups in SQL queries, typically following the WHERE clause and preceding the ORDER BY clause. With JDBC, we can determine whether the underlying database supports this clause using the supportsGroupBy() method of the DatabaseMetaData interface. Problem StatementGiven a MySQL database, write a Java program that connects to the database and checks if the database supports the SQL GROUP BY clause.Input Database connection URL, username, and ...

Read More

Java DatabaseMetaData getMaxStatements() method with example.

Smita Kapse
Smita Kapse
Updated on 08-Nov-2024 223 Views

In this article, we will learn how to retrieve the maximum number of open statements allowed by a database using the DatabaseMetaData interface in Java. The getMaxStatements() method of the DatabaseMetaData interface is used to find out the maximum number of open statements (objects) that the underlying database allows at one time. This method returns an integer value, representing the maximum number of statements that are allowed to be open at a time. If this value is 0 it indicates that there is no limit or, the limit is unknown. Problem StatementGiven a connection to a database, write a ...

Read More

Java DataBaseMetaData getMaxCatalogNameLength() method with example.

Smita Kapse
Smita Kapse
Updated on 07-Nov-2024 146 Views

In this article, we will learn how to retrieve the maximum number of characters allowed in a catalog name using the getMaxCatalogNameLength() method in Java. This method belongs to the DatabaseMetaData interface, which provides comprehensive information about the database, including its structure and capabilities. The method is useful for understanding the limitations imposed by the underlying database in terms of catalog name length. Problem StatementGiven a connection to a database, write a Java program to retrieve and display the maximum number of characters that the database allows for catalog names using the getMaxCatalogNameLength() method.Input A MySQL database connection URL, ...

Read More

How to Convert JSON to CSV File in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 07-Nov-2024 2K+ Views

JavaScript Object Notation or JSON is recognized widely for data interchange while exporting and importing modular result data is done through CSV (Comma-Separated Values). It is quite common to convert JSON to any other format for reporting purposes or to integrate with different systems. In this article, we will explore different ways to transform JSON data into CSV format in JavaScript, incorporating its code, examples, and clarifications of its principles. Understanding JSON and CSV Formats JSON: JSON represents data as an array of objects, with each object containing key-value pairs. ...

Read More

Java program to find the number occurring odd number of times

AmitDiwan
AmitDiwan
Updated on 07-Nov-2024 700 Views

In this article, we will learn how to find the number in an array that appears an odd number of times using Java. By looping through the array and counting occurrences of each number, the program will detect and return the one with an odd frequency. Problem Statement Given an array identify the integer that occurs an odd number of times. Below is the demostration of the same − Input 34, 56, 99, 34, 55, 99, 90, 11, 12, 11, 11, 34 Output The number that occurs odd number of times in the array is 34 Steps to find the number occurring ...

Read More

Java program to sort a HashMap by Keys and Values

Way2Class
Way2Class
Updated on 07-Nov-2024 2K+ Views

In this article, we will learn the procedures for sorting a HashMap in Java by its keys and values, as well as examine the performance implications associated with each technique. HashMap, a frequently employed data structure, enables programmers to store key-value pairs. This data structure is an exceedingly efficient method for storing data and allows for swift value retrieval based on keys. However, on occasion, it may become necessary to arrange the HashMap by its keys or values.  Different Approaches of Sorting the HashMap Following are the different approaches to sorting a HashMap by Keys and Values − ...

Read More

Nearest 1 in a binary matrix in C++

Aishwarya Naglot
Aishwarya Naglot
Updated on 05-Nov-2024 273 Views

In this article, we will show you how to find the minimum distance from each cell in a binary matrix to the nearest cell that contains the digit 1. We will see brute force as well as optimized approaches. Problem Statement Given a binary matrix, our task is to calculate the minimum distance for each cell to the nearest cell that contains the value 1, and if the current cell itself has 1 as a value, the distance will be 0. If the input matrix is as follows - 0 0 1 1 1 0 0 0 0 The ...

Read More

Longest double string of a Palindrome

Aishwarya Naglot
Aishwarya Naglot
Updated on 05-Nov-2024 177 Views

A contiguous sequence of characters, consisting of uppercase, lowercase, repetitive, or unique alphanumeric characters, forms a C++ string. Each string has a unique length, which may be either odd or even in nature. Longest Double String of a Palindrome A Palindromic string is a sequence of characters that reads the same from both the beginning and the end. In other words, characters at equivalent positions from the start and end have no difference. These palindromes can either have an even length or an odd length. The odd-length palindrome features a middle character separating the two equivalent halves. In this article, ...

Read More

Java program to generate a random number from an array

karthikeya Boyini
karthikeya Boyini
Updated on 04-Nov-2024 6K+ Views

In this article, we will learn how to generate a random number from an array of integers in Java by using Random class. The Random class provides methods to generate random numbers, and we will use the nextInt(int bound) method to get a random index within the bounds of our array length. Problem Statement Given an array of integers, we need to randomly select and display one element from the array using Java. Input arr = { 10, 30, 45, 60, 78, 99, 120, 140, 180, 200}; Output Random number from the array = 30 Steps to generate ...

Read More

Java program to get the prime numbers with BigInteger type

Nancy Den
Nancy Den
Updated on 04-Nov-2024 756 Views

In this article, we will learn how to generate prime numbers using the BigInteger class in Java. A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. Here, we have the BigInteger type, which has operations for modular arithmetic, GCD calculation, primality testing, prime generation, etc. Steps to get the prime numbers with BigInteger type Following are the steps to get the prime numbers with BigInteger type − First, we will import the BigInteger from the java.math package. ...

Read More
Showing 16901–16910 of 25,466 articles
Advertisements