Tuesday, June 17, 2025

.::: Trial Backup & Restore MariaDB MySQL with crontab -l / crontab -e & /etc/crontab :::.

 


A. Prepare Script backup & Restore

1. create backup script

[root@teguhth cron]# pwd
/data/cron
[root@teguhth cron]# cat backup_test.sh
echo "backup full mulai" > log_backup.txt
date >> log_backup.txt

mysqldump -uroot -pxxx -CfQq --max-allowed-packet=1G --hex-blob --order-by-primary --single-transaction --routines=true --triggers=true --no-data=false teguhth | gzip -c > teguhth_ori.sql.gz ;

echo "backup full selesai " >> log_backup.txt
date  >> log_backup.txt
[root@teguhth cron]#

Thursday, June 12, 2025

.::: Simulation Query Select from Java to MariaDB using mariadb-java-client-3.5.3.jar (MariaDB Driver) :::.

  

https://teguhth.blogspot.com/2025/06/simulation-connection-java-to-mariadb.html

1. Script java 

[root@teguhth maria]# cat queryjoin.java
import java.sql.*;

public class queryjoin {
    public static void main(String[] args) {
        String url = "jdbc:mariadb://10.10.10.90:3306/teguhth"; // Ganti IP jika perlu
        String user = "admin";
        String pass = "admin";

        try {
            Connection conn = DriverManager.getConnection(url, user, pass);

            // Jalankan query
//            String query = "select b.NAMA_BARANG,s.NAMA_SUPLIER,p.TANGGAL_PASOK,p.JUMLAH_PASOK from barang b,suplier s,pasok p where b.KODE_BARANG=p.KODE_BARANG and s.KODE_SUPLIER=p.KODE_SUPLIER;";

//String query = "SELECT b.NAMA_BARANG, s.NAMA_SUPLIER, p.TANGGAL_PASOK, p.JUMLAH_PASOK, (SELECT SLEEP(20)) as DELAY FROM barang b, suplier s, pasok p WHERE b.KODE_BARANG = p.KODE_BARANG AND s.KODE_SUPLIER = p.KODE_SUPLIER;";

//String query ="select * from pembelian;";
 

Thursday, June 5, 2025

.::: Simulation connection java to MariaDB for Success & Fail using mysql-connector-j-8.0.33.jar (MySQL Driver) (com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.) :::..

 

1. Download (Platform independent) MySQL Driver

https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/8.0.33/mysql-connector-j-8.0.33.jar

java -version
dnf install java-17-openjdk-devel -y    # CentOS 9


2. check login mariadb

[root@teguhth ~]# mysql -h 10.10.10.90 -uadmin -p teguhth
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 11.4.4-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

.::: Simulation connection java to MariaDB for Success & Fail using mariadb-java-client-3.5.3.jar (MariaDB Driver) (java.sql.SQLNonTransientConnectionException: Socket fail to connect to 10.10.10.9. No route to host) :::.

 

1. Download (Platform independent)

https://mariadb.com/downloads/connectors/connectors-data-access/java8-connector
 

java -version
dnf install java-17-openjdk-devel -y    # CentOS 9


2. check login mariadb

[root@teguhth ~]# mysql -h 10.10.10.90 -uadmin -p teguhth
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 11.4.4-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Monday, June 2, 2025

.::: Move TempDB to other folder (move SQL Server MDF and LDF Files location):::.

 
 
correlation https://teguhth.blogspot.com/2023/06/move-sql-server-mdf-and-ldf-files.html

1. check 

sp_helpdb tempdb

USE tempdb;
GO
SELECT 
    name AS [Logical Name],
    physical_name AS [File Path],
    type_desc AS [File Type],
    size * 8 / 1024 AS [Size (MB)],
    max_size,
    growth,
    is_percent_growth
FROM sys.master_files
WHERE database_id = DB_ID('tempdb');

SELECT name, physical_name FROM sys.master_files WHERE database_id = DB_ID('tempdb');

Popular Posts