How to log all MySQL queries in Drupal
In order to benchmark a Drupal site performance you need to see all the database queries related to your Drupal site. In case you don’t have access to the my.cnf file If you don’t have access to the my.cnf file, you can log the queries from the Drupal code itself: cp includes/database.mysql-common.inc includes/database.mysql-common.inc.backup.orig vim includes/database.mysql-common.inc [...]
Insert into multiple MySQL tables with one-to-one relationship
I have been asked if there is a way to insert data into two MyISAM tables that connected by a one-to-one relationship in one MySQL query. For example: mysql> CREATE TABLE `user` ( `id` int(10) unsigned NOT NULL auto_increment, `name` varchar(255) NOT NULL default ”, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 mysql> [...]
Connection Pool: MySQL Communications link failure
The Problem And The Solution While using a MySQL connection pool in Java, I received a MySQL Communications link failure Exception (see below). In order to solve communication link failure exception: I have removed JDBC property autoReconnect=true and put only the JDBC property autoReconnectForPools=true I have added the connection properties: testOnBorrow testWhileIdle timeBetweenEvictionRunsMillis minEvictableIdleTimeMillis See [...]
Connection Pool: MySQL connection closed exception
The Problem While using a MySQL connection pool in Java, I received a MySQL Connection Closed Exception (see below). The problem was that the JDBC driver was not compatible to the MySQL server version. I have used version 5.05a for both JDBC and MySQL and it solved the problem The problem is that the connection [...]
How To Switch Java in Centos
* If you need to install a new version of java, download the version from java.sun * run /usr/sbin/alternatives to change the default java. If you will run the next command you will see which java versions are available: # /usr/sbin/alternatives –config java There is 1 programs which provide ‘java’. Selection Command ———————————————– *+ 1 [...]
Adding DbUnit to your project
About DbUnit DbUnit is a JUnit extension (also usable with Ant) targeted at database-driven projects that, among other things, puts your database into a known state between test runs. This is an excellent way to avoid the myriad of problems that can occur when one test case corrupts the database and causes subsequent tests to [...]
How to get directories via FTP
How to GET directories via FTP: You can get a directory files (recursive) by using wget command with flag -m for –mirror wget -m ftp://username:password@ip.of.old.host See using wget to recursively download whole ftp directories
How to setup log rotation on Flume
Flume can be used to rotate logs file into a regular file system. Examples: In BE mode (Best Effort) exec config remuscl2-vm.atomant.net ‘tail("/tmp/error.log")’ ‘agentBESink("remuscl1-vm.atomant.net",35888)’ exec config remuscl1-vm.atomant.net ‘collectorSource( 35888 )’ ‘collectorSink("/tmp/nlog/%Y/%m/%d/errorlog", "mylog_%{host}_%H_",60000 )’ in E2E (End to End) exec config remuscl2-vm.atomant.net ‘tail("/tmp/error.log")’ ‘agentE2ESink("remuscl1-vm.atomant.net",35888)’ exec config remuscl1-vm.atomant.net ‘collectorSource( 35888 )’ ‘collector(600000) {collectorSink("/tmp/nloge/%Y/%m/%d/errorlog", "mylog_%{host}_%H_",600000 )}’ Explanations: collectorSink [...]
How to use the Flume E2E mode
E2E provides the best reliability mode: You can tune the reliability level of the agents, simply by specifying a different kind of agent sink. There are three levels available. One of them is the E2E (End To End) mode, which relies on an acknowledgement, and will retry if no acknowledgement is received. E2E limitations: E2E [...]
How to set up a MySQL connection pool in Java
MySQL connection pool A MySQL connection pool is a pool of connections to MySQL database. Opening and maintaining a database connection for each process (or thread), is time costly (connection creation time) and wastes resources (connections). Connection pool increase the performance of (Java) applications that needs to connect to the database by reusing the connections. [...]
How to install ANT on LINUX
Apache Ant is a Java library and command-line tool that help building software. How to install: Create downloads directory if you dont have one Download tar version from http://ant.apache.org/bindownload.cgi Extract Rename the new directory as ant Insert the path into ANT_HOME Update the global PATH variable to include ANT_HOME Run the Ant script fetch.xml to [...]
How to rename a database in MySQL
In MySQL there is no support for database renaming. In order to rename a MySQL database you can do one of the following: 1. Create new database and rename all tables in the old database to be in the new database: CREATE database new_db_name; RENAME TABLE db_name.table1 TO new_db_name, db_name.table2 TO new_db_name; DROP database db_name; [...]