Rishi Raj

Rishi Raj

77 Articles Published

Articles by Rishi Raj

Page 5 of 8

Java Connection getTransactionIsolation() method with example

Rishi Raj
Rishi Raj
Updated on 30-Dec-2024 813 Views

In this article, we learn the Connection getTransactionIsolation() method in Java, which allows you to determine a database connection's current transaction isolation level. Transaction isolation levels dictate how transactions interact, particularly regarding data locking during reads or writes. What is the getTransactionIsolation() Method? The getTransactionIsolation() method is part of the Connection Interface in Java. It returns an integer constant representing the current isolation level of the database connection. JDBC provides support for 5 transaction isolation levels through the Connection interface − TRANSACTION_NONE: It is represented by an integer value 0 and does not support transactions. ...

Read More

Java DatabaseMetaData getCatalogs() method with example

Rishi Raj
Rishi Raj
Updated on 14-Nov-2024 959 Views

In this article, we’ll look at how to retrieve and display the list of available catalogs (databases) in a MySQL instance using Java’s JDBC (Java Database Connectivity) API. By running a Java program that connects to the MySQL server, we’ll use the DatabaseMetaData class to fetch catalog names with the getCatalogs() method, showing each catalog’s name on the console. This process demonstrates how to access and navigate metadata in MySQL using JDBC, offering insight into the structure of your database environment. Steps to retrieve database catalogs  The getCatalogs() method of the DatabaseMetaData interface returns the name of the underlying database ...

Read More

Java DatabaseMetaData supportsGroupBy() method with example

Rishi Raj
Rishi Raj
Updated on 08-Nov-2024 212 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 Connection getAutoCommit() method with example

Rishi Raj
Rishi Raj
Updated on 18-Oct-2024 1K+ Views

In this program, we will establish a connection to a MySQL database and check the current auto-commit setting using the getAutoCommit() method from the Connection interface. We will first disable the auto-commit feature using setAutoCommit(false) and then retrieve the current auto-commit status with getAutoCommit() to verify if it has been successfully disabled. Steps to use the getAutoCommit() method Following are the steps to use the getAutoCommit() method − First, we will import the required java.sql.Connection and java.sql.DriverManager packages. We'll establish a connection to a MySQL database using the DriverManager.getConnection() method. ...

Read More

Python program to check whether a given string is Heterogram or not

Rishi Raj
Rishi Raj
Updated on 23-Jun-2020 2K+ Views

Here one string is given then our task is to check weather a given string is Heterogram or not.The meaning of heterogram checking is that a word, phrase, or sentence in which no letter of the alphabet occurs more than once. A heterogram may be distinguished from a pangram which uses all of the letters of the alphabet.ExampleString is abc def ghiThis is Heterogram (no alphabet repeated)String is abc bcd dfhThis is not Heterogram. (b, c, d are repeated)AlgorithmStep 1: first we separate out list of all alphabets present in sentence. Step 2: Convert list of alphabets into set because ...

Read More

How can we use INFORMATION_SCHEMA to get the details about triggers in a particular database?

Rishi Raj
Rishi Raj
Updated on 22-Jun-2020 198 Views

It can be done with the help of the following statement −mysql> select * from information_schema.triggers where -> information_schema.triggers.trigger_schema like '%query%'\G *************************** 1. row *************************** TRIGGER_CATALOG: def TRIGGER_SCHEMA: query TRIGGER_NAME: trigger_before_delete_sample EVENT_MANIPULATION: DELETE EVENT_OBJECT_CATALOG: def ...

Read More

How can we test for the existence of any record in MySQL subquery?

Rishi Raj
Rishi Raj
Updated on 22-Jun-2020 234 Views

We can use MySQL EXIST operator to test for the existence of a record in the subquery. In other words, we can say that EXIST operator checks if a subquery returns any rows. The syntax of using EXIST operator with MySQL subquery is as follows −SyntaxWHERE EXISTS (Subquery)The above EXIST (subquery) expression returns TRUE if the subquery returns at least one row, otherwise it returns false.ExampleTo make it understand we are using the data from the following tables −mysql> Select * from Customers; +-------------+----------+ | Customer_Id | Name     | +-------------+----------+ | 1           | ...

Read More

Generating password in Java

Rishi Raj
Rishi Raj
Updated on 21-Jun-2020 14K+ Views

Generate temporary password is now a requirement on almost every website now-a-days. In case a user forgets the password, system generates a random password adhering to password policy of the company. Following example generates a random password adhering to following conditions −It should contain at least one capital case letter.It should contain at least one lower-case letter.It should contain at least one number.Length should be 8 characters.It should contain one of the following special characters: @, $, #, !.Exampleimport java.util.Random; public class Tester{    public static void main(String[] args) {       System.out.println(generatePassword(8));    }    private ...

Read More

How can column data be used within MySQL CASE statement?

Rishi Raj
Rishi Raj
Updated on 20-Jun-2020 234 Views

To understand it consider the data, as follows, from the table ‘Students’ −mysql> Select * from Students; +----+-----------+-----------+----------+----------------+ | id | Name | Country | Language | Course | +----+-----------+-----------+----------+----------------+ | 1 | Francis | UK | English | Literature | | 2 | Rick | USA | English | History ...

Read More

What MySQL returns if we pass column name, containing a NULL value, as one of the arguments of CONCAT() function?

Rishi Raj
Rishi Raj
Updated on 20-Jun-2020 175 Views

As we know that CONCAT() function will return NULL if any of the argument of it is NULL. It means MySQL will return NULL if we pass column name, containing a NULL value, as one of the arguments of CONCAT() function. Following is an example of ‘Student’ table to explain it.ExampleIn this example, we are concatenating the values of two strings and at 5th row one, the value is NULL hence the concatenation result is also NULL.mysql> Select Name, Address, CONCAT(Name, ' Resident of ', Address)AS 'Detail of Student' from Student; +---------+---------+---------------------------+ | Name    | Address | Detail ...

Read More
Showing 41–50 of 77 articles
« Prev 1 3 4 5 6 7 8 Next »
Advertisements