Define Ip and netmask
vi /etc/sysconfig/network-scripts/ifcfg-eth0
You should have something like this
# Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.1.255
HWADDR=00:1A:64:99:6A:8C
IPADDR=192.168.1.41
NETMASK=255.255.254.0
#NETWORK=192.168.1.0
ONBOOT=yes
ifcfg-eth0 for your first network card, if you have more than one you can create file ifcfg-eth1, ifcfg-eth2, and so on
Define gateway
vi /etc/sysconfig/network
You should have something like this
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=devserver
GATEWAY=192.168.1.2
Restart your network
/etc/init.d/network restart
Define DNS
vi /etc/resolv.conf
You should have something like this
nameserver 10.0.80.11
nameserver 10.0.80.12
nameserver 202.67.222.222
Posted in Uncategorized | No Comments »
I have the following data source config file (myproject-ds.xml) in my jboss app server
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE datasources
PUBLIC “-//JBoss//DTD JBOSS JCA Config 1.5//EN”
“http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd”>
<datasources>
<!–PROD–>
<local-tx-datasource>
<jndi-name>myDS</jndi-name>
<connection-url>jdbc:mysql:///myProject</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>myuser</user-name>
<password>mypass</password>
</local-tx-datasource>
</datasources>
To get connection manually in your java code based on the datasource file above is
try{
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup( "java:/myDS" );
java.sql.Connection conn = ds.getConnection();
}catch(Exception e){
}
Posted in Uncategorized | No Comments »
To count number of files and sub folders in a directory
ls | wc -l
To count number of files and sub folders in a directory and symbolic links if exist.
ls -l | wc -l
To count files ONLY without the subfolders
find /your/folder -type f -maxdepth 1 | wc -l
To count all files ONLY including files inside subfolders but exclude the subfolders itself
find /your/folderĀ -type f | wc -l
Posted in Uncategorized | No Comments »
To download a file when user click a button in JSF application is very simple. What you have to becareful is you have to know what kind of file that you want to download so you can choose how to read the file. For example if it is a txt file, you can use BufferedReader class to read the txt file line per line, because you can read char in a txt file. But you cannot use the same method if you want to read a pdf or image files, because you need to read it using byte instead of char.
Posted in Uncategorized | No Comments »
From command line you can dumping mysql DB using dump command
mysqldump –add-drop-table -umyuser -pmypass mydb > mydb.sql
But if you want to use dump command in java using Runtime.exec() command, you cannot use it the way you use in command line, because you will get error. This is happened because the output of
mysqldump –add-drop-table -umyuser -pmypass mydb
we can directly forward to mydb.sql using “>” symbol, but will not work in java. So to handle the output of dump command in java, we have to write the output programmatically as shown below
Posted in Uncategorized | 3 Comments »