Sunday, October 7, 2007

Executing SQL scripts on MYSQL

OK, this one IS in the manual :)

But nonetheless, why not take a shortcut & just google it :)

Anyhoo, let's assume you have a database called MYDB at machine localhost which you can access under user name web with password password. The file you want to execute is called sql_script.sql which contains SQL commands delimited by ; as shown below.

DROP TABLE IF EXISTS general_detail;
DROP TABLE IF EXISTS general;

Here's how you can execute this script on MySQL 5.0 :

mysql MYDB -h localhost -u web -ppassword < sql_script.sql

BTW, if you want to execute an SQL command quickly via the command line, type :

mysql MYDB -h localhost -u web -ppassword -e "alter table general AUTO_INCREMENT = 1"


"Exception creating identity" error for JBoss 4.2.1 in Linux

Recently when trying to run JBoss on PCLinuxOS, I keep getting the "Exception creating identity" error which terminates JBoss immediately. While suspecting the fact that there is no DNS server running in my LAN could be the culprit, I couldn't figure out how and where to solve this.

So I tried a somewhat hack-ish solution : the /etc/hosts file. It's been a while since I edit one of these. Anyway the hack was to add the name of the identity which JBoss said it can't refer to, meaning if JBoss' log says the following :


Exception creating identity dhcpp01


Then edit your /etc/hosts file as follows :


127.0.0.1 localhost dhcppc1


From herein, JBoss will start normally.