Monday, 24 February 2025

The total number of locks exceeds the lock table size

 SHOW VARIABLES LIKE 'innodb_buffer_pool_size';

SET GLOBAL innodb_buffer_pool_size = 2147483648;  -- 2GB

Note: The value is in bytes (2GB = 2 * 1024 * 1024 * 1024). Adjust it based on your available memory.

🔸 Limitations:

  • This change is temporary and will reset when MySQL restarts.
  • To make it permanent, you need to update my.cnf or my.ini

Thursday, 19 September 2024

Wednesday, 18 September 2024

How to print log4j logs in Intellij Console

 log4j.properities file

log4j.rootLogger=INFO, console log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1} - %m%n


Add this to VM options

-Dlog4j.configuration=file:{path}/log4j.properties

Thursday, 19 November 2020

Access Mysql user without sudo in ubuntu command line

 First login in as the root user using sudo command

sudo mysql -u root -p password

CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%' WITH GRANT OPTION;
or
GRANT ALL PRIVILEGES ON DatabaseName.* TO 'newuser
'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

now everything is completed, logout from the sudo user with Exit
or Ctrl + Z. Then try with 

mysql -u newuser -p password

Thursday, 10 October 2019

MSSQL Data formatter

Below is a list of formats and an example of the output.  The date used for all of these examples is "2006-12-30 00:38:54.840".
DATE ONLY FORMATS
Format #QuerySample
1select convert(varchar, getdate(), 1)12/30/06
2select convert(varchar, getdate(), 2)06.12.30
3select convert(varchar, getdate(), 3)30/12/06
4select convert(varchar, getdate(), 4)30.12.06
5select convert(varchar, getdate(), 5)30-12-06
6select convert(varchar, getdate(), 6)30 Dec 06
7select convert(varchar, getdate(), 7)Dec 30, 06
10select convert(varchar, getdate(), 10)12-30-06
11select convert(varchar, getdate(), 11)06/12/30
12select convert(varchar, getdate(), 12)061230
23select convert(varchar, getdate(), 23)2006-12-30
101select convert(varchar, getdate(), 101)12/30/2006
102select convert(varchar, getdate(), 102)2006.12.30
103select convert(varchar, getdate(), 103)30/12/2006
104select convert(varchar, getdate(), 104)30.12.2006
105select convert(varchar, getdate(), 105)30-12-2006
106select convert(varchar, getdate(), 106)30 Dec 2006
107select convert(varchar, getdate(), 107)Dec 30, 2006
110select convert(varchar, getdate(), 110)12-30-2006
111select convert(varchar, getdate(), 111)2006/12/30
112select convert(varchar, getdate(), 112)20061230
TIME ONLY FORMATS
8select convert(varchar, getdate(), 8)00:38:54
14select convert(varchar, getdate(), 14)00:38:54:840
24select convert(varchar, getdate(), 24)00:38:54
108select convert(varchar, getdate(), 108)00:38:54
114select convert(varchar, getdate(), 114)00:38:54:840
DATE & TIME FORMATS
0select convert(varchar, getdate(), 0)Dec 12 2006 12:38AM
9select convert(varchar, getdate(), 9)Dec 30 2006 12:38:54:840AM
13select convert(varchar, getdate(), 13)30 Dec 2006 00:38:54:840AM
20select convert(varchar, getdate(), 20)2006-12-30 00:38:54
21select convert(varchar, getdate(), 21)2006-12-30 00:38:54.840
22select convert(varchar, getdate(), 22)12/30/06 12:38:54 AM
25select convert(varchar, getdate(), 25)2006-12-30 00:38:54.840
100select convert(varchar, getdate(), 100)Dec 30 2006 12:38AM
109select convert(varchar, getdate(), 109)Dec 30 2006 12:38:54:840AM
113select convert(varchar, getdate(), 113)30 Dec 2006 00:38:54:840
120select convert(varchar, getdate(), 120)2006-12-30 00:38:54
121select convert(varchar, getdate(), 121)2006-12-30 00:38:54.840
126select convert(varchar, getdate(), 126)2006-12-30T00:38:54.840
127select convert(varchar, getdate(), 127)2006-12-30T00:38:54.840
ISLAMIC CALENDAR DATES
130select convert(nvarchar, getdate(), 130)date output
131select convert(nvarchar, getdate(), 131)10/12/1427 12:38:54:840AM
You can also format the date or time without dividing characters, as well as concatenate the date and time string:
Sample statementOutput
select replace(convert(varchar, getdate(),101),'/','')12302006
select replace(convert(varchar, getdate(),101),'/','') + replace(convert(varchar, getdate(),108),':','')12302006004426

Tuesday, 8 October 2019

MySql script to provide tables names and its row count in a DB

SELECT table_name, table_rows
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = '**YOUR SCHEMA**';
SELECT CONCAT(
    'SELECT "', 
    table_name, 
    '" AS table_name, COUNT(*) AS exact_row_count FROM `', 
    table_schema,
    '`.`',
    table_name, 
    '` UNION '
) 
FROM INFORMATION_SCHEMA.TABLES 
WHERE table_schema = '**my_schema**';
ref link: https://stackoverflow.com/questions/286039/get-record-counts-for-all-tables-in-mysql-database

MSSQL server script to provide tables names and its row count in a DB

SELECT 
    TableName = t.NAME,
    TableSchema = s.Name,
    RowCounts = p.rows
FROM 
    sys.tables t
INNER JOIN 
    sys.schemas s ON t.schema_id = s.schema_id
INNER JOIN      
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
WHERE 
    t.is_ms_shipped = 0
GROUP BY
    t.NAME, s.Name, p.Rows
ORDER BY 
    s.Name, t.Name
ref link: https://stackoverflow.com/questions/9954775/script-that-provides-the-row-counts-and-table-names

Wednesday, 8 May 2019

How to call a request before executing an API call in postman?

Add the below code in the Pre-request Script tab

pm.sendRequest({
    url: "http://localhost:8080/login",
    method: 'POST',
    header: {'Content-Type': 'application/json'},
    body: {
        mode: 'raw',
        raw: JSON.stringify({
            username: postman.getEnvironmentVariable("username"),
            password:postman.getEnvironmentVariable("password") })
    }
}, function (err, res) {
    postman.setEnvironmentVariable("userId", res.json().userId);
});

Reference: https://gist.github.com/madebysid/b57985b0649d3407a7aa9de1bd327990

Monday, 7 January 2019

Import Mysql script

Problem:

When importing a Sql script into Mysql DB and the process hangs

Solutions:

1. Due to memory issue. In this case memory need to be increased, which can be achieved by the below script

SET GLOBAL max_allowed_packet=1073741824;

Wednesday, 12 September 2018

How to fix Port already in use windows ?

Open command prompt and run the following commands


C:\Users\username>netstat -o -n -a | findstr 0.0:8080
   TCP    0.0.0.0:8080      0.0.0.0:0              LISTENING       2138

C:\Users\username>taskkill /F /PID 2138

Monday, 27 November 2017

How to run maven build through command prompt?


Change directory and move into the folder where the pom.xml file exists. Then run the following two commands to build the maven.

Clean Compile:

mvn clean compile -Dmaven.test.skip=true

Run:

mvn install -Dmaven.test.skip=true

-Dmaven.test.skip=true  will skip the test folder and files.

Wednesday, 22 November 2017

How to create admin and db based user in mongodb?


Admin User:

db.createUser(
    {
      user: "admin",
      pwd: "password123",
      roles: ["userAdminAnyDatabase","userAdmin","readWrite","dbAdmin","clusterAdmin","readWriteAnyDatabase","dbAdminAnyDatabase"]
    }
)

DB based User:

User who can access only a specific database.

db.createUser(
   {
     user: "myuser",
     pwd: "password123",
     roles: [ { role: "readWrite", db: "databasename" } ]
   }
);

Monday, 20 November 2017

How to get total number of active connections in linux?


Solution

netstat -n | grep [:portnumber] | grep ESTABLISHED | wc -l

Example

netstat -n | grep :8080 | grep ESTABLISHED | wc -l

Explanation 

netstat
(network statistics) command displays network connections (both incoming and outgoing), routing tables, and a number of network interface (network interface controller or software-defined network interface) and network protocol statistics.

-n: Show numerical addresses instead of trying to determine symbolic host, port or user names

grep (global regular expression print) command processes text line by line and prints any lines which match a specified pattern.

wc (word count) command prints a count of newlines, words, and bytes for each input file. 

-l: print the newline counts.

The total number of locks exceeds the lock table size

 SHOW VARIABLES LIKE 'innodb_buffer_pool_size'; SET GLOBAL innodb_buffer_pool_size = 2147483648;  -- 2GB Note: The value is in byte...