Type the following command
1. sudo /etc/init.d/networking restart
2. sudo dhclient -r
3. sudo dhclient
Internet Systems Consortium DHCP Client V3.1.1
Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
wmaster0: unknown hardware address type 801
wmaster0: unknown hardware address type 801
Listening on LPF/pan0/62:d0:a5:7a:31:db
Sending on LPF/pan0/62:d0:a5:7a:31:db
Listening on LPF/wmaster0/
Sending on LPF/wmaster0/
Listening on LPF/eth0/00:26:9e:16:41:56
Sending on LPF/eth0/00:26:9e:16:41:56
Listening on LPF/vboxnet0/0a:00:27:00:00:00
Sending on LPF/vboxnet0/0a:00:27:00:00:00
Listening on LPF/wlan0/00:24:d2:ea:d8:48
Sending on LPF/wlan0/00:24:d2:ea:d8:48
Sending on Socket/fallback
DHCPRELEASE on wlan0 to 123.45.67.2 port 67
paul@platform2u:~$ sudo dhclient
Internet Systems Consortium DHCP Client V3.1.1
Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
wmaster0: unknown hardware address type 801
wmaster0: unknown hardware address type 801
Listening on LPF/pan0/62:d0:a5:7a:31:db
Sending on LPF/pan0/62:d0:a5:7a:31:db
Listening on LPF/wlan0/00:24:d2:ea:d8:48
Sending on LPF/wlan0/00:24:d2:ea:d8:48
Listening on LPF/wmaster0/
Sending on LPF/wmaster0/
Listening on LPF/eth0/00:26:9e:16:41:56
Sending on LPF/eth0/00:26:9e:16:41:56
Listening on LPF/vboxnet0/0a:00:27:00:00:00
Sending on LPF/vboxnet0/0a:00:27:00:00:00
Sending on Socket/fallback
DHCPDISCOVER on wmaster0 to 255.255.255.255 port 67 interval 3
DHCPDISCOVER on vboxnet0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on pan0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on wmaster0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on vboxnet0 to 255.255.255.255 port 67 interval 12
DHCPDISCOVER on pan0 to 255.255.255.255 port 67 interval 15
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 14
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
DHCPOFFER of 123.45.67.50 from 123.45.67.2
DHCPREQUEST of 123.45.67.50 on wlan0 to 255.255.255.255 port 67
DHCPACK of 123.45.67.50 from 123.45.67.2
bound to 123.45.67.50 -- renewal in 357363 seconds.
paul@platform2u:~$ sudo /etc/init.d/networking restart
* Reconfiguring network interfaces... Ignoring unknown interface wlan0=wlan0.
[ OK ]
*** YOU CAN NOW CONNECT YOU WILRELESS CONNECTION BY RELEASING THE IP. ***
Thursday, December 17, 2009
Saturday, November 21, 2009
My Router Configuration Tutorial
Router>enable
Router#config
Router(config)#hostname N115-7206
PaulServer(config)#interface serial 1/1
PaulServer(config-if)ip address 192.168.155.2 255.255.255.0
PaulServer(config-if)no shutdown
PaulServer(config-if)ctrl-z
PaulServer#show interface serial 1/1
PaulServer#config
PaulServer(config)#interface ethernet 2/3
PaulServer(config-if)#ip address 192.168.150.90 255.255.255.0
PaulServer(config-if)#no shutdown
PaulServer(config-if)#ctrl-z
PaulServer#show interface ethernet 2/3
PaulServer#config
PaulServer(config)#router rip
PaulServer(config-router)#network 192.168.155.0
PaulServer(config-router)#network 192.168.150.0
PaulServer(config-router)#ctrl-z
PaulServer#show ip protocols
PaulServer#ping 192.168.150.1
PaulServerconfig
PaulServer(config)#ip name-server 172.16.0.10
PaulServer(config)#ctrl-z
PaulServer#ping paul.ph
PaulServer#config
PaulServer(config)#enable secret password
PaulServer(config)#ctrl-z
PaulServer#copy running-config startup-config
PaulServer#exit
Router#config
Router(config)#hostname N115-7206
PaulServer(config)#interface serial 1/1
PaulServer(config-if)ip address 192.168.155.2 255.255.255.0
PaulServer(config-if)no shutdown
PaulServer(config-if)ctrl-z
PaulServer#show interface serial 1/1
PaulServer#config
PaulServer(config)#interface ethernet 2/3
PaulServer(config-if)#ip address 192.168.150.90 255.255.255.0
PaulServer(config-if)#no shutdown
PaulServer(config-if)#ctrl-z
PaulServer#show interface ethernet 2/3
PaulServer#config
PaulServer(config)#router rip
PaulServer(config-router)#network 192.168.155.0
PaulServer(config-router)#network 192.168.150.0
PaulServer(config-router)#ctrl-z
PaulServer#show ip protocols
PaulServer#ping 192.168.150.1
PaulServerconfig
PaulServer(config)#ip name-server 172.16.0.10
PaulServer(config)#ctrl-z
PaulServer#ping paul.ph
PaulServer#config
PaulServer(config)#enable secret password
PaulServer(config)#ctrl-z
PaulServer#copy running-config startup-config
PaulServer#exit
Monday, October 26, 2009
VOIP voicemail using ASTERISK ^_^
; Voicemail Configuration
;
[general]
; Default formats for writing Voicemail
;format=g723sf|wav49|wav
format=gsm|wav49|wav
; Who the e-mail notification should appear to come from
serveremail=asterisk@tweedledee.paul.com
;serveremail=asterisk@linux-support.net
; Should the email contain the voicemail as an attachment
attach=yes
; Maximum length of a voicemail message
maxmessage=100
; Maximum length of greetings
;maxgreet=60
;
; Each mailbox is listed in the form=,,
; if the e-mail is specified, a message will be sent when a message is
; received, to the given mailbox.
;
[default]
1 => !0,Paul,paul-vm@localhost
2 => !0,John,john@yahoo.com john.com
;
[general]
; Default formats for writing Voicemail
;format=g723sf|wav49|wav
format=gsm|wav49|wav
; Who the e-mail notification should appear to come from
serveremail=asterisk@tweedledee.paul.com
;serveremail=asterisk@linux-support.net
; Should the email contain the voicemail as an attachment
attach=yes
; Maximum length of a voicemail message
maxmessage=100
; Maximum length of greetings
;maxgreet=60
;
; Each mailbox is listed in the form
; if the e-mail is specified, a message will be sent when a message is
; received, to the given mailbox.
;
[default]
1 => !0,Paul,paul-vm@localhost
2 => !0,John,john@yahoo.com john.com
Router Configuration in Red Hat 9.0
Extract the dcp folder
# tar xzvf dhcp-3.0pl2.tar.gz
then cd into dhcp-3.0pl2 directory that is created. Type in ./configure then make then make install you now need to get out of the dhcp-3.0pl2 directory by typing this
# cd ..
Dhcpd
now you should be in a prompt with
root@localhost root#
Now you need to make a few files. You do this by the touch command in your terminal.
# touch /etc/dhcpd.conf
you then need to make a directory. You do this by using the mkdir command in your terminal
# mkdir /var/state/dhcp
you then make a text file in this directory while still in root
# touch /var/state/dhcp/dhcpd.leases
Now you must configure your /etc/dhcpd.conf file. Using nano:
# nano /etc/dhcpd.conf
(here nano is used as an editor but any other available editor like vi, emacs will do equally well). An example of a /etc/dhcpd.conf file would be this (class A network):
ddns-update-style interim;
subnet 10.0.0.0 netmask 255.255.0.0 {
default-lease-time 63000;
max-lease-time 72000;
option routers 10.0.0.1;
option subnet-mask 255.255.0.0;
option [domain-name-servers]
range 10.0.0.2 10.0.0.253;
}
domain-name-servers are provider-dependant, use ip-address of router; if there are more than one dns server separate by a comma;
iptables
You now need to make the file /etc/sysconfig/iptables. You again use the touch command to do this.
# touch /etc/sysconfig/iptables
Once you have created this file you need to go into it and place your iptables rules. Again edit the file and enter the following data (using nano):
# nano /etc/sysconfig/iptables
An example of /etc/sysconfig/iptables is:
#iptables - configuration files for iptables in Red Hat Linux 8.0
#This is appropriate for protecting a single workstation.
#The script could be a lot more rigorous, e.g., only allow
#selected outbound ports, rather than allowing all outbound
#traffic, use REJECT rather than DROP, etc. However, the
#goal of this script was to provide some protection for ports
#while minimizing the number of checks made on each packet.
#This file should be owned by user root, group root.
#The permissions on this file should be set to 600.
#Edit lines as necessary, then uncomment (remove hash mark) the
#lines you wish to use.
#Although every precaution has been taken in the preparation of this
#file, the author assumes no responsibility for errors or omissions.
#Neither is any liability assumed for damages resulting from the use of
#the information contained herein.
#m-woo@uiuc.edu 9 Jan 2003
filter
INPUT DROP [0:0]
FORWARD DROP [0:0]
OUTPUT DROP [0:0]
#Drop all incoming fragments
-A INPUT -i eth0 -f -j DROP
#Drop outside packets with localhost address - anti-spoofing measure
-A INPUT -s 10.0.0.1/255.0.0.0 -i ! lo -j DROP
#Pass all locally-originating packets
-A INPUT -i lo -j ACCEPT -A OUTPUT -o lo -j ACCEPT
#Accept ICMP ping echo request packets
#(this allows other people to ping your machine, among other things),
-A INPUT -p icmp --icmp-type echo-request -j ACCEPT
#Accept all traffic from a specific machine with IP x.x.x.x
#replace x.x.x.x with the desired IP, then uncomment the line.
-A INPUT -p tcp -m tcp --syn -s 10.0.0.0 -j ACCEPT
#Accept traffic on port p from a specific machine with IP x.x.x.x
#replace p with the desired port number, and replace x.x.x.x with
#the desired IP, then uncomment the line.
-A INPUT -p tcp -m tcp --syn -s 10.0.0.1 --dport 80 -j ACCEPT
#Accept all inbound ssh traffic
-A INPUT -p tcp -m tcp --syn --dport 22 -j ACCEPT
#Accept all inbound identd
-A INPUT -p tcp -m tcp --syn --dport 113 -j ACCEPT
#or you can reject and send back a TCP RST packet instead
-A INPUT -p tcp -m tcp --dport 113 -j REJECT --reject-with tcp-reset
#Allow all sendmail SMTP traffic
-A INPUT -p tcp -m tcp --syn --dport 25 -j ACCEPT
#Allow all sendmail MSA traffic
-A INPUT -p tcp -m tcp --syn --dport 587 -j ACCEPT
#Allow all web server access (port 80)
-A INPUT -p tcp -m tcp --syn --dport 80 -j ACCEPT
#Allow all secure web server access (port 443)
-A INPUT -p tcp -m tcp --syn --dport 443 -j ACCEPT
#Allow inbound established and related outside communication
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#Drop outside initiated connections
-A INPUT -m state --state NEW -j REJECT
#Allow all outbound tcp, udp, icmp traffic with state
-A OUTPUT -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p udp -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p icmp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
COMMIT
You also need to add the line
echo 1 > /proc/sys/net/ipv4/ip_forward
to your /etc/rc.d/rc.local file
also hit enter twice after the above line and put
dhcpd
This will automatically start your dhcpd server for you on startup of your machine.
Firestarter firewall
Now you need to install firestarter. You do this using the rpm command
# rpm –i firestarter-0.9.2-3.i386.rpm
# tar xzvf dhcp-3.0pl2.tar.gz
then cd into dhcp-3.0pl2 directory that is created. Type in ./configure then make then make install you now need to get out of the dhcp-3.0pl2 directory by typing this
# cd ..
Dhcpd
now you should be in a prompt with
root@localhost root#
Now you need to make a few files. You do this by the touch command in your terminal.
# touch /etc/dhcpd.conf
you then need to make a directory. You do this by using the mkdir command in your terminal
# mkdir /var/state/dhcp
you then make a text file in this directory while still in root
# touch /var/state/dhcp/dhcpd.leases
Now you must configure your /etc/dhcpd.conf file. Using nano:
# nano /etc/dhcpd.conf
(here nano is used as an editor but any other available editor like vi, emacs will do equally well). An example of a /etc/dhcpd.conf file would be this (class A network):
ddns-update-style interim;
subnet 10.0.0.0 netmask 255.255.0.0 {
default-lease-time 63000;
max-lease-time 72000;
option routers 10.0.0.1;
option subnet-mask 255.255.0.0;
option [domain-name-servers]
range 10.0.0.2 10.0.0.253;
}
domain-name-servers are provider-dependant, use ip-address of router; if there are more than one dns server separate by a comma;
iptables
You now need to make the file /etc/sysconfig/iptables. You again use the touch command to do this.
# touch /etc/sysconfig/iptables
Once you have created this file you need to go into it and place your iptables rules. Again edit the file and enter the following data (using nano):
# nano /etc/sysconfig/iptables
An example of /etc/sysconfig/iptables is:
#iptables - configuration files for iptables in Red Hat Linux 8.0
#This is appropriate for protecting a single workstation.
#The script could be a lot more rigorous, e.g., only allow
#selected outbound ports, rather than allowing all outbound
#traffic, use REJECT rather than DROP, etc. However, the
#goal of this script was to provide some protection for ports
#while minimizing the number of checks made on each packet.
#This file should be owned by user root, group root.
#The permissions on this file should be set to 600.
#Edit lines as necessary, then uncomment (remove hash mark) the
#lines you wish to use.
#Although every precaution has been taken in the preparation of this
#file, the author assumes no responsibility for errors or omissions.
#Neither is any liability assumed for damages resulting from the use of
#the information contained herein.
#m-woo@uiuc.edu 9 Jan 2003
filter
INPUT DROP [0:0]
FORWARD DROP [0:0]
OUTPUT DROP [0:0]
#Drop all incoming fragments
-A INPUT -i eth0 -f -j DROP
#Drop outside packets with localhost address - anti-spoofing measure
-A INPUT -s 10.0.0.1/255.0.0.0 -i ! lo -j DROP
#Pass all locally-originating packets
-A INPUT -i lo -j ACCEPT -A OUTPUT -o lo -j ACCEPT
#Accept ICMP ping echo request packets
#(this allows other people to ping your machine, among other things),
-A INPUT -p icmp --icmp-type echo-request -j ACCEPT
#Accept all traffic from a specific machine with IP x.x.x.x
#replace x.x.x.x with the desired IP, then uncomment the line.
-A INPUT -p tcp -m tcp --syn -s 10.0.0.0 -j ACCEPT
#Accept traffic on port p from a specific machine with IP x.x.x.x
#replace p with the desired port number, and replace x.x.x.x with
#the desired IP, then uncomment the line.
-A INPUT -p tcp -m tcp --syn -s 10.0.0.1 --dport 80 -j ACCEPT
#Accept all inbound ssh traffic
-A INPUT -p tcp -m tcp --syn --dport 22 -j ACCEPT
#Accept all inbound identd
-A INPUT -p tcp -m tcp --syn --dport 113 -j ACCEPT
#or you can reject and send back a TCP RST packet instead
-A INPUT -p tcp -m tcp --dport 113 -j REJECT --reject-with tcp-reset
#Allow all sendmail SMTP traffic
-A INPUT -p tcp -m tcp --syn --dport 25 -j ACCEPT
#Allow all sendmail MSA traffic
-A INPUT -p tcp -m tcp --syn --dport 587 -j ACCEPT
#Allow all web server access (port 80)
-A INPUT -p tcp -m tcp --syn --dport 80 -j ACCEPT
#Allow all secure web server access (port 443)
-A INPUT -p tcp -m tcp --syn --dport 443 -j ACCEPT
#Allow inbound established and related outside communication
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#Drop outside initiated connections
-A INPUT -m state --state NEW -j REJECT
#Allow all outbound tcp, udp, icmp traffic with state
-A OUTPUT -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p udp -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p icmp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
COMMIT
You also need to add the line
echo 1 > /proc/sys/net/ipv4/ip_forward
to your /etc/rc.d/rc.local file
also hit enter twice after the above line and put
dhcpd
This will automatically start your dhcpd server for you on startup of your machine.
Firestarter firewall
Now you need to install firestarter. You do this using the rpm command
# rpm –i firestarter-0.9.2-3.i386.rpm
Wednesday, September 16, 2009
Java with MYSQL
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JdbcExample2 {
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///test",
"root", "123456");
if(!con.isClosed())
System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}
import java.sql.DriverManager;
import java.sql.SQLException;
public class JdbcExample2 {
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///test",
"root", "123456");
if(!con.isClosed())
System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}
Wednesday, September 2, 2009
Thursday, August 27, 2009
new KDE 9.10 ^_^ and My Updated Project in PHP in Linux and Windows Platform
My Webform Admin Access Login Account

My PHP report generating Microsoft Excel .xls file report. ^_^


My Summary report within realtime of webform

My Reporting System Program that I Developed in PHP

Windows XP Service Pack 2 inside in Linux Kubunti 9.10(KDE) using Sun Microsystem Virtual Box. ^_^
)
Using MC console in Linux Kubuntu 9.10(KDE)

Memory status of linux Kubuntu 9.10 (KDE)
+%5E_%5E)
Filesystem Tree Using Bash Command "pstree" in Linux Kubuntu 9.10 (Kde) ^_^


New KDE 9.10 Desktop (jaunty version) ^_^

My PHP report generating Microsoft Excel .xls file report. ^_^


My Summary report within realtime of webform

My Reporting System Program that I Developed in PHP

Windows XP Service Pack 2 inside in Linux Kubunti 9.10(KDE) using Sun Microsystem Virtual Box. ^_^
Using MC console in Linux Kubuntu 9.10(KDE)

Memory status of linux Kubuntu 9.10 (KDE)
Filesystem Tree Using Bash Command "pstree" in Linux Kubuntu 9.10 (Kde) ^_^

New KDE 9.10 Desktop (jaunty version) ^_^
Saturday, August 15, 2009
Other Framework that i used to build a website
Saturday, August 8, 2009
Using Linux(Ubuntu) for Symbian.C++ 3rd edition application
Using Linux(Ubuntu) for Symbian.C++ 3rd edition application
Step 1: Setting "EPOCROOT" and Points where you have symbian tools.
a) export PATH=~/gnupoc:${PATH}
b) export EPOCROOT=~/symbian-sdks/s60_31/
Step 2: Compiling source code
a) cd ~/symbian-sdks/s60_31/s60ex/helloworldbasic/group
b) bldmake bldfiles
c) abld build gcce urel
Step 3: Create a .SIS File
a) cd ../sis
b) makesis helloworldbasic_gcce.pkg helloworldbasic.sis
Step 4: Genearet key and certificate pair for Symbian application
makekeys -cert myselfcer.key myselfcer.cer
Step 5: Signing .SIS App
signsis helloworldbasic.sis helloworldbasic.sisx myselfcer.cer myselfcer.key
Step 1: Setting "EPOCROOT" and Points where you have symbian tools.
a) export PATH=~/gnupoc:${PATH}
b) export EPOCROOT=~/symbian-sdks/s60_31/
Step 2: Compiling source code
a) cd ~/symbian-sdks/s60_31/s60ex/helloworldbasic/group
b) bldmake bldfiles
c) abld build gcce urel
Step 3: Create a .SIS File
a) cd ../sis
b) makesis helloworldbasic_gcce.pkg helloworldbasic.sis
Step 4: Genearet key and certificate pair for Symbian application
makekeys -cert myselfcer.key myselfcer.cer
Step 5: Signing .SIS App
signsis helloworldbasic.sis helloworldbasic.sisx myselfcer.cer myselfcer.key
Friday, July 10, 2009
MYSQL++ "MYSQL Connected to C++"
using namespace std;
int main()
{
MYSQL* conn;
conn = mysql_init(NULL);
if (mysql_real_connect(conn,"","root","johnpaul","mysql",0,NULL,0) !=0)
{
cout << "Connected to MySQL database success" << endl;
}
mysql_close(conn);
system("PAUSE");
return 0;
}
int main()
{
MYSQL* conn;
conn = mysql_init(NULL);
if (mysql_real_connect(conn,"","root","johnpaul","mysql",0,NULL,0) !=0)
{
cout << "Connected to MySQL database success" << endl;
}
mysql_close(conn);
system("PAUSE");
return 0;
}
Sunday, June 28, 2009
Writing SED Script
Testing and Saving Output
Follow this 3 steps
- Makes a copy of the input line.
- Modifies that copy in the pattern space.
- Outputs the copy to standard output
Script and Command
$ sed -f sedscr paulfile
$ sed -f sedscr paulfile > newpaulfile
$ diff paulfile newpaulfile
for x
do
sed -f sedscr $x > tmp.$x
done
Follow this 3 steps
- Makes a copy of the input line.
- Modifies that copy in the pattern space.
- Outputs the copy to standard output
Script and Command
$ sed -f sedscr paulfile
$ sed -f sedscr paulfile > newpaulfile
$ diff paulfile newpaulfile
for x
do
sed -f sedscr $x > tmp.$x
done
Monday, June 22, 2009
Connection of JAVA to Oracle
// You need to import the java.sql package to use JDBC (Java Database Connection)
import java.sql.*;
import javax.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.*;
import oracle.jdbc.xa.OracleXid;
import oracle.jdbc.xa.OracleXAException;
import oracle.jdbc.xa.client.*;
import javax.transaction.xa.*;
class XA4
{
public static void main (String args [])
throws SQLException
{
try
{
String URL1 = "jdbc:oracle:oci8:@";
String URL2 ="jdbc:oracle:thin:@(description=(address=(host=dlsun991)
(protocol=tcp)(port=5521))(connect_data=(sid=rdbms2)))";
DriverManager.registerDriver(new OracleDriver());
// You can put a database name after the to the connection URL.
Connection conna =
DriverManager.getConnection (URL1, "ip", "host");
// Prepare a statement to create the table
Statement stmta = conna.createStatement ();
Connection connb =
DriverManager.getConnection (URL2, "user", "pass");
// Prepare a statement to create the table
Statement stmtb = connb.createStatement ();
try
{
// Drop the test table
stmta.execute ("drop table table1");
}
catch (SQLException e)
{
// Ignore an error here
}
try
{
// Create a test table
stmta.execute ("create table my_table (col1 int)");
}
catch (SQLException e)
{
// Ignore an error here too
}
try
{
// Drop the test table
stmtb.execute ("drop table table1");
}
catch (SQLException e)
{
// Ignore error
}
try
{
// Create a test table
stmtb.execute ("create table my_tab (col1 char(30))");
}
catch (SQLException e)
{
// Ignore an error here too
}
// Create XADataSource instances and set properties.
OracleXADataSource oxds1 = new OracleXADataSource();
oxds1.setURL("jdbc:oracle:oci8:@");
oxds1.setUser("scott");
oxds1.setPassword("tiger");
OracleXADataSource oxds2 = new OracleXADataSource();
oxds2.setURL("jdbc:oracle:thin:@(description=(address=(host=dlsun991)
(protocol=tcp)(port=5521))(connect_data=(sid=rdbms2)))");
oxds2.setUser("scott");
oxds2.setPassword("tiger");
// Get XA connections to the underlying data sources
XAConnection pc1 = oxds1.getXAConnection();
XAConnection pc2 = oxds2.getXAConnection();
// Get the physical connections
Connection conn1 = pc1.getConnection();
Connection conn2 = pc2.getConnection();
// Get the XA resources
XAResource oxar1 = pc1.getXAResource();
XAResource oxar2 = pc2.getXAResource();
// Create the Xids With the Same Global Ids
Xid xid1 = createXid(1);
Xid xid2 = createXid(2);
// Start the Resources
oxar1.start (xid1, XAResource.TMNOFLAGS);
oxar2.start (xid2, XAResource.TMNOFLAGS);
// Execute SQL operations with conn1 and conn2
doSomeWork1 (conn1);
doSomeWork2 (conn2);
// END both the branches -- IMPORTANT
oxar1.end(xid1, XAResource.TMSUCCESS);
oxar2.end(xid2, XAResource.TMSUCCESS);
// Prepare the RMs
int prp1 = oxar1.prepare (xid1);
int prp2 = oxar2.prepare (xid2);
System.out.println("Return value prepare 1 is " + prp1);
System.out.println("Return value prepare 2 is " + prp2);
boolean do_commit = true;
}
import java.sql.*;
import javax.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.*;
import oracle.jdbc.xa.OracleXid;
import oracle.jdbc.xa.OracleXAException;
import oracle.jdbc.xa.client.*;
import javax.transaction.xa.*;
class XA4
{
public static void main (String args [])
throws SQLException
{
try
{
String URL1 = "jdbc:oracle:oci8:@";
String URL2 ="jdbc:oracle:thin:@(description=(address=(host=dlsun991)
(protocol=tcp)(port=5521))(connect_data=(sid=rdbms2)))";
DriverManager.registerDriver(new OracleDriver());
// You can put a database name after the to the connection URL.
Connection conna =
DriverManager.getConnection (URL1, "ip", "host");
// Prepare a statement to create the table
Statement stmta = conna.createStatement ();
Connection connb =
DriverManager.getConnection (URL2, "user", "pass");
// Prepare a statement to create the table
Statement stmtb = connb.createStatement ();
try
{
// Drop the test table
stmta.execute ("drop table table1");
}
catch (SQLException e)
{
// Ignore an error here
}
try
{
// Create a test table
stmta.execute ("create table my_table (col1 int)");
}
catch (SQLException e)
{
// Ignore an error here too
}
try
{
// Drop the test table
stmtb.execute ("drop table table1");
}
catch (SQLException e)
{
// Ignore error
}
try
{
// Create a test table
stmtb.execute ("create table my_tab (col1 char(30))");
}
catch (SQLException e)
{
// Ignore an error here too
}
// Create XADataSource instances and set properties.
OracleXADataSource oxds1 = new OracleXADataSource();
oxds1.setURL("jdbc:oracle:oci8:@");
oxds1.setUser("scott");
oxds1.setPassword("tiger");
OracleXADataSource oxds2 = new OracleXADataSource();
oxds2.setURL("jdbc:oracle:thin:@(description=(address=(host=dlsun991)
(protocol=tcp)(port=5521))(connect_data=(sid=rdbms2)))");
oxds2.setUser("scott");
oxds2.setPassword("tiger");
// Get XA connections to the underlying data sources
XAConnection pc1 = oxds1.getXAConnection();
XAConnection pc2 = oxds2.getXAConnection();
// Get the physical connections
Connection conn1 = pc1.getConnection();
Connection conn2 = pc2.getConnection();
// Get the XA resources
XAResource oxar1 = pc1.getXAResource();
XAResource oxar2 = pc2.getXAResource();
// Create the Xids With the Same Global Ids
Xid xid1 = createXid(1);
Xid xid2 = createXid(2);
// Start the Resources
oxar1.start (xid1, XAResource.TMNOFLAGS);
oxar2.start (xid2, XAResource.TMNOFLAGS);
// Execute SQL operations with conn1 and conn2
doSomeWork1 (conn1);
doSomeWork2 (conn2);
// END both the branches -- IMPORTANT
oxar1.end(xid1, XAResource.TMSUCCESS);
oxar2.end(xid2, XAResource.TMSUCCESS);
// Prepare the RMs
int prp1 = oxar1.prepare (xid1);
int prp2 = oxar2.prepare (xid2);
System.out.println("Return value prepare 1 is " + prp1);
System.out.println("Return value prepare 2 is " + prp2);
boolean do_commit = true;
}
Thursday, June 18, 2009
BUBBLE SORT IN C++
include
template
void bubbleSort(Iterator first, Iterator last)
{Iterator jp, m;
for (jp = first; jp != last; ++jp)
for (j = first; m < jp; ++m)
if (*jp < *j)
std::iter_swap(i, j);}
{Iterator jp, m;
for (jp = first; m != last; ++i)
for (m = first; m < jp; ++j)
if (compare(*jp, *m))
std::iter_swap(jp, m);}
template
void bubbleSort(Iterator first, Iterator last)
{Iterator jp, m;
for (jp = first; jp != last; ++jp)
for (j = first; m < jp; ++m)
if (*jp < *j)
std::iter_swap(i, j);}
{Iterator jp, m;
for (jp = first; m != last; ++i)
for (m = first; m < jp; ++j)
if (compare(*jp, *m))
std::iter_swap(jp, m);}
DOJO Tuorial
DOJO Tutorial
How to call ajax google apps into DOJO script
Code:
//Connect to Goolge Apps
src="http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js">
dojo.addOnLoad(function(){
setTimeout(function(){
//Connect with Google analytics
dojo.require("dojox.analytics.Urchin")
dojo.addOnLoad(function(){
var tracker = new dojox.analytics.Urchin({
acct: "UA-XXXXXX-X" // your tracking # here
})
})
}, 100)
})
How to call ajax google apps into DOJO script
Code:
//Connect to Goolge Apps
src="http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js">
dojo.addOnLoad(function(){
setTimeout(function(){
//Connect with Google analytics
dojo.require("dojox.analytics.Urchin")
dojo.addOnLoad(function(){
var tracker = new dojox.analytics.Urchin({
acct: "UA-XXXXXX-X" // your tracking # here
})
})
}, 100)
})
SYMBIAN C++ Tutorial
Symbian C++ in developing GUI APPS
Syntax
RESOURCE {
= ;
[ = ; ...]
}
Here the is defined in files included from some .rh files. For example we can have MENU_BAR, MENU_PANE and so on.
Each can have a scalar value, a list value or a struct value. A scalar value is a number or a string. A list value is a sequence enclosed in braces. Examples:
name = "Hello" ;
list = { 1 , 2, 3 };
A struct value has this syntax:
{
= ;
[ = ; ...]
}
Where can be a scalar, list or structure value, so the structure can nest. Here is a complete (and real) example:
RESOURCE MENU_PANE r_simplemenu_menu_pane
{
items =
{
MENU_ITEM
{
command = ESimpleMenuCmdNewGame;
txt = NEW_GAME_TEXT;
cascade = r_simplemenu_game_submenu_menu_pane;
},
MENU_ITEM
{
command = CmdExit;
txt = EXIT_TEXT;
}
};
}
Creating a MENU in Symbian C++
RESOURCE MENU_BAR r_demo_menubar {
titles = {
MENU_TITLE {
menu_pane = r_demo_menu;
}
};
}
Then the menu pane:
RESOURCE MENU_PANE r_demo_menu {
{
items = {
MENU_ITEM {
command = EHelloWorldCommand1;
txt = COMMAND_ONE;
},
MENU_ITEM {
command = EAknCmdExit;
txt = text_softkey_exit;
}
};
}
}
Note the EHelloWorldCommand1 coming from the .hrh and COMMAND_ONE included from .loc
Creating a LISTBOX
RESOURCE LISTBOX r_list_listbox {
array_id = r_list_items;
flags = EAknListBoxSelectionList;
}
RESOURCE ARRAY r_list_items {
items =
{
LBUF { txt = "tFirst"; },
LBUF { txt = "xtSecond"; },
LBUF { txt = "tThird"; }
};
}
Now the code to create a list object. In the class we declare CAknColumnListBox* iListBox;, then in the HelloAppView::ConstrucL(), we create and load resource is it as follows:
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC(reader, R_LIST_LISTBOX);
iListBox->ConstructFromResourceL(reader);
CleanupStack:PopAndDestroy(); // reader
The following is the code needed to display the listbox in the view.
void CHelloAppView::SizeChanged() {
iListBox->SetExtent (TPoint(0,0), iListBox->MinimumSize());
}
TInt CHelloAppView::CountComponentControls() const {
return 1;
}
CCoeControl* CHelloAppView::ComponentControl(TInt aIndex) const {
switch(aIndex) {
case 0: return iListBox;
default: return NULL;
}
}
#define M_SHOP_REMOVE_PROMPT "Are you sure to remove?"
The resource for a confirmation query is:
RESOURCE DIALOG r_shop_confirmation_query
{
flags=EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_YES_NO;
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EListDlgCId1;
control = AVKON_CONFIRMATION_QUERY
{
layout = EConfirmationQueryLayout;
label = M_SHOP_REMOVE_PROMPT;
};
}
};
}
RESOURCE TBUF r_shop_data_query_prompt
{
buf = M_SHOP_ADD_PROMPT;
}
Bluetooth GPS(Global Positioning System) device using C++ Mobile on a Symbian Series 60 cellphone
MY CODE
void Cbttest1Container::OniBtDiscovery1DeviceFound( CBase * aDiscovery )
{
_LIT(KDeviceFound, "Device Found");
iEikLabel1->SetTextL(KDeviceFound);
this->DrawDeferred();
CSdpSearchPattern * list = CSdpSearchPattern::NewL( );
list->AddL( 0x1101 );
iBtSdpQuery1->SetSearchPattern(list);
CSdpAttrIdMatchList * matchList = CSdpAttrIdMatchList::NewL( );
matchList->AddL( TAttrRange( KSdpAttrIdProtocolDescriptorList ) );
iBtSdpQuery1->SetAttrIdMatchList(matchList);
iBtSdpQuery1->StartNextSdpL(iBtDiscovery1->BDAddr());
}
Syntax
RESOURCE
[
}
Here the
Each
name = "Hello" ;
list = { 1 , 2, 3 };
A struct value has this syntax:
[
}
Where
RESOURCE MENU_PANE r_simplemenu_menu_pane
{
items =
{
MENU_ITEM
{
command = ESimpleMenuCmdNewGame;
txt = NEW_GAME_TEXT;
cascade = r_simplemenu_game_submenu_menu_pane;
},
MENU_ITEM
{
command = CmdExit;
txt = EXIT_TEXT;
}
};
}
Creating a MENU in Symbian C++
RESOURCE MENU_BAR r_demo_menubar {
titles = {
MENU_TITLE {
menu_pane = r_demo_menu;
}
};
}
Then the menu pane:
RESOURCE MENU_PANE r_demo_menu {
{
items = {
MENU_ITEM {
command = EHelloWorldCommand1;
txt = COMMAND_ONE;
},
MENU_ITEM {
command = EAknCmdExit;
txt = text_softkey_exit;
}
};
}
}
Note the EHelloWorldCommand1 coming from the .hrh and COMMAND_ONE included from .loc
Creating a LISTBOX
RESOURCE LISTBOX r_list_listbox {
array_id = r_list_items;
flags = EAknListBoxSelectionList;
}
RESOURCE ARRAY r_list_items {
items =
{
LBUF { txt = "tFirst"; },
LBUF { txt = "xtSecond"; },
LBUF { txt = "tThird"; }
};
}
Now the code to create a list object. In the class we declare CAknColumnListBox* iListBox;, then in the HelloAppView::ConstrucL(), we create and load resource is it as follows:
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC(reader, R_LIST_LISTBOX);
iListBox->ConstructFromResourceL(reader);
CleanupStack:PopAndDestroy(); // reader
The following is the code needed to display the listbox in the view.
void CHelloAppView::SizeChanged() {
iListBox->SetExtent (TPoint(0,0), iListBox->MinimumSize());
}
TInt CHelloAppView::CountComponentControls() const {
return 1;
}
CCoeControl* CHelloAppView::ComponentControl(TInt aIndex) const {
switch(aIndex) {
case 0: return iListBox;
default: return NULL;
}
}
#define M_SHOP_REMOVE_PROMPT "Are you sure to remove?"
The resource for a confirmation query is:
RESOURCE DIALOG r_shop_confirmation_query
{
flags=EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_YES_NO;
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EListDlgCId1;
control = AVKON_CONFIRMATION_QUERY
{
layout = EConfirmationQueryLayout;
label = M_SHOP_REMOVE_PROMPT;
};
}
};
}
RESOURCE TBUF r_shop_data_query_prompt
{
buf = M_SHOP_ADD_PROMPT;
}
Bluetooth GPS(Global Positioning System) device using C++ Mobile on a Symbian Series 60 cellphone
MY CODE
void Cbttest1Container::OniBtDiscovery1DeviceFound( CBase * aDiscovery )
{
_LIT(KDeviceFound, "Device Found");
iEikLabel1->SetTextL(KDeviceFound);
this->DrawDeferred();
CSdpSearchPattern * list = CSdpSearchPattern::NewL( );
list->AddL( 0x1101 );
iBtSdpQuery1->SetSearchPattern(list);
CSdpAttrIdMatchList * matchList = CSdpAttrIdMatchList::NewL( );
matchList->AddL( TAttrRange( KSdpAttrIdProtocolDescriptorList ) );
iBtSdpQuery1->SetAttrIdMatchList(matchList);
iBtSdpQuery1->StartNextSdpL(iBtDiscovery1->BDAddr());
}
PYNET TUTORIAL
MSN Gateway using PYNET
msnp.py is an implementation of the MSN instant messaging protocol in the Python programming language. This pure Python package makes it extremely easy, quick, and efficient to build applications that need to interact with the MSN messaging service.
MY CODE:
import msnp
import time
class MsnListener(msnp.SessionCallbacks):
def state_changed(self, state):
if state == msnp.States.ONLINE:
print 'online kn ^_^!'
msn = msnp.Session(MsnListener())
msn.login('johnpaul86@hotmail.com', 'jpmama')
while True:
msn.process()
time.sleep(1)
IM - Instant Messaging
#using msnp.py - msn protocol
import msnp
import time
class MsnChatListener(msnp.ChatCallbacks):
def message_received(self, passport_id, display_name, text, charset):
print '%s: %s' % (passport_id, text)
self.chat.send_message(text, charset)
class MsnListener(msnp.SessionCallbacks):
def chat_started(self, chat):
callbacks = MsnChatListener()
chat.callbacks = callbacks
callbacks.chat = chat
msn = msnp.Session(MsnListener())
msn.login('johnpaul86@hotmail.com', 'jpmama')
while True:
msn.process(chats = True)
time.sleep(1)
msnp.py is an implementation of the MSN instant messaging protocol in the Python programming language. This pure Python package makes it extremely easy, quick, and efficient to build applications that need to interact with the MSN messaging service.
MY CODE:
import msnp
import time
class MsnListener(msnp.SessionCallbacks):
def state_changed(self, state):
if state == msnp.States.ONLINE:
print 'online kn ^_^!'
msn = msnp.Session(MsnListener())
msn.login('johnpaul86@hotmail.com', 'jpmama')
while True:
msn.process()
time.sleep(1)
IM - Instant Messaging
#using msnp.py - msn protocol
import msnp
import time
class MsnChatListener(msnp.ChatCallbacks):
def message_received(self, passport_id, display_name, text, charset):
print '%s: %s' % (passport_id, text)
self.chat.send_message(text, charset)
class MsnListener(msnp.SessionCallbacks):
def chat_started(self, chat):
callbacks = MsnChatListener()
chat.callbacks = callbacks
callbacks.chat = chat
msn = msnp.Session(MsnListener())
msn.login('johnpaul86@hotmail.com', 'jpmama')
while True:
msn.process(chats = True)
time.sleep(1)
Wednesday, June 17, 2009
CREATING PYTHON SCRIPT WITH MYSQL
mysql> SELECT * FROM name;
+----------+----------+
| name | Lastname |
+----------+----------+
| John Paul| Mam |
| Will | Smith |
| Asyong | Taga |
+----------+----------+
5 rows in set (0.01 sec)
and then consider this short Python script, which connects to the database and prints out the data within the table.
#!/usr/bin/python
# import MySQL module
import MySQLdb
# connect
db = MySQLdb.connect(host="localhost", user="paul", passwd="jpm1986",
db="db56a")
# create a cursor
cursor = db.cursor()
# execute SQL statement
cursor.execute("SELECT * FROM name")
# get the resultset as a tuple
result = cursor.fetchall()
# iterate through resultset
for record in result:
print record[0] , "-->", record[1]
The first step is to import the MySQLdb module, via Python's "import" function.
# import MySQL module
import MySQLdb
You can open up a connection to the MySQL database server, by passing the module's connect() method a series of connection parameters - the server name, the database user name and password, and the database name.
# connect
db = MySQLdb.connect(host="localhost", user="paul", passwd="jpm1986",
db="db1")
A successful connection returns a Connection object, which you can use to create a cursor.
# create a cursor
cursor = db.cursor()
This cursor is needed to execute an SQL statement, and to retrieve the generated resultset.
# execute SQL statement
cursor.execute("SELECT * FROM name")
# get the resultset as a tuple
result = cursor.fetchall()
A number of methods are available to retrieve the SQL resultset - the one used here is the fetchall() method, which returns a tuple of tuples, each inner tuple representing a row of the resultset. This tuple can then be iterated over with a regular "for" loop, and its elements printed to the standard output.
# iterate through resultset
for record in result:
print record[0] , "-->", record[1]
PYTHON SCRIPT
#!/usr/bin/python
# import MySQL module
import MySQLdb
# connect
db = MySQLdb.connect(host="localhost", user="paul", passwd="jpm1986",
db="db56a")
# create a cursor
cursor = db.cursor()
# execute SQL statement
cursor.execute("SELECT * FROM name")
# get the number of rows in the resultset
numrows = int(cursor.rowcount)
# get and display one row at a time
for x in range(0,numrows):
row = cursor.fetchone()
print row[0], "-->", row[1]
+----------+----------+
| name | Lastname |
+----------+----------+
| John Paul| Mam |
| Will | Smith |
| Asyong | Taga |
+----------+----------+
5 rows in set (0.01 sec)
and then consider this short Python script, which connects to the database and prints out the data within the table.
#!/usr/bin/python
# import MySQL module
import MySQLdb
# connect
db = MySQLdb.connect(host="localhost", user="paul", passwd="jpm1986",
db="db56a")
# create a cursor
cursor = db.cursor()
# execute SQL statement
cursor.execute("SELECT * FROM name")
# get the resultset as a tuple
result = cursor.fetchall()
# iterate through resultset
for record in result:
print record[0] , "-->", record[1]
The first step is to import the MySQLdb module, via Python's "import" function.
# import MySQL module
import MySQLdb
You can open up a connection to the MySQL database server, by passing the module's connect() method a series of connection parameters - the server name, the database user name and password, and the database name.
# connect
db = MySQLdb.connect(host="localhost", user="paul", passwd="jpm1986",
db="db1")
A successful connection returns a Connection object, which you can use to create a cursor.
# create a cursor
cursor = db.cursor()
This cursor is needed to execute an SQL statement, and to retrieve the generated resultset.
# execute SQL statement
cursor.execute("SELECT * FROM name")
# get the resultset as a tuple
result = cursor.fetchall()
A number of methods are available to retrieve the SQL resultset - the one used here is the fetchall() method, which returns a tuple of tuples, each inner tuple representing a row of the resultset. This tuple can then be iterated over with a regular "for" loop, and its elements printed to the standard output.
# iterate through resultset
for record in result:
print record[0] , "-->", record[1]
PYTHON SCRIPT
#!/usr/bin/python
# import MySQL module
import MySQLdb
# connect
db = MySQLdb.connect(host="localhost", user="paul", passwd="jpm1986",
db="db56a")
# create a cursor
cursor = db.cursor()
# execute SQL statement
cursor.execute("SELECT * FROM name")
# get the number of rows in the resultset
numrows = int(cursor.rowcount)
# get and display one row at a time
for x in range(0,numrows):
row = cursor.fetchone()
print row[0], "-->", row[1]
Subscribe to:
Comments (Atom)

