Installation & Configuration of JBOSS In Ubuntu Download: 1. Download JDK 6 Update 3 Linux binary (jdk6u3linuxi586.bin) file. http://java.sun.com/javase/downloads/index.jsp 2. Download JBOSS.4.2.2.GA compressed file (jboss4.2.2.GA.zip). http://labs.jboss.com/jbossas/downloads/ JDK Installation In Ubuntu: I have downloaded this file in Desktop root@indranildesktop:/home/indranil/Desktop$ su root@indranildesktop : /home/indranil/Desktop# chmod 777 jdk6u3linuxi586.bin root@indranildesktop:/home/indranil/Desktop# ./jdk6u3linuxi586.bin root@indranildesktop:/home/indranil/Desktop# vim /home/indranil/.bashrc Now append the following line at the end of the file export JAVA_HOME=/home/indranil/Desktop/jdk1.6.0_03 This sets the environment path of the JDK. JBOSS Installation: First, extract the jboss4.2.2.GA.zip. This is all for installtion. Here I have extracted the above file in my Desktop folder. To run the JBOSS Application Server, execute the following commands in terminal root@indranildesktop:/# cd home/indranil/Desktop/jboss4.2.2.GA/ root@indranildesktop:/home/indranil/Desktop/jboss4.2.2.GA# cd bin/ root@indranildesktop:/home/indranil/Desktop/jboss4.2.2.GA/bin# ./run.sh
Author: Indranil Basu Email:
[email protected] MAT3 Impex Pvt. Ltd., Kolkata064
http://localhost:8080
Installation of MySQL In Ubuntu
Installation Process: 1. Open “Synaptic Package Manager”. 2. Select “mysqlserver5” and mark it for installation. 3. And click on “Apply” button to install. 4. After the completion of MySQL installtion.
Connecting MySQL With JBOSS In Ubuntu Download “mysqlconnectorjava5.1.5bin.jar” file http://dev.mysql.com/downloads/connector/j/5.1.html this link will give you a tar file. Get this file extract and after that you will get the above mentioned .jar file. Then copy this .jar file to the following path indranil@indranildesktop:~/Desktop/jboss4.2.2.GA/server/default/lib$ Now execute the following in terminal: # mysql mysql> create database indra; mysql> create table capitals( countryname varchar(30), capitalname varchar(30) ); mysql> insert into capitals values("India","Delhi"); mysql> insert into capitals values("Japan","Tokyo"); mysql> insert into capitals values("Bangladesh","Dhaka"); Author: Indranil Basu Email:
[email protected] MAT3 Impex Pvt. Ltd., Kolkata064
mysql> exit Now create a JSP file with the following code and name it “indranil.jsp” <%@ page import="java.sql.*" %> <% String connectionURL = "jdbc:mysql://localhost/indra"; Connection connection = null; Statement statement = null; ResultSet rs = null; %> <% Class.forName("com.mysql.jdbc.Driver").newInstance(); connection = DriverManager.getConnection(connectionURL, "root", ""); statement = connection.createStatement(); rs = statement.executeQuery("SELECT * FROM capitals"); while (rs.next()) { out.println(rs.getString("countryname")+" "+rs.getString("capitalname")+"
"); }
out.println("
php"); rs.close(); %> Save this “indranil.jsp” file in the following path ./jboss4.2.2.GA/server/default/deploy/jboss web.deployer/ROOT.war/JSP/ Now open your browser, and paste this link (http://localhost:8080/JSP/indranil.jsp) to the address bar.
Author: Indranil Basu Email:
[email protected] MAT3 Impex Pvt. Ltd., Kolkata064
Installation of PHP5 & Apache2 Installation Process: 1. Open “Synaptic Package Manager” 2. Select “php5”, “php5cgi”, “php5common”, “php5gd”, “php5mysql”, “apache2”, “apache2.2common” and mark these for installation. 3. Click “Apply” to start installation. 4. After the completion of installation, click on this “http://localhost/” to open apache. 5. Now create a php file with the following content
$username = "root"; $password = ""; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); print "Connected to MySQL
";
$selected = mysql_select_db("indra",$dbh) or die("Could not select first_test"); if (mysql_query("insert into capitals values('Pakistan','Islamabad')")) { print "successfully inserted record"; } else { print "Failed to insert record"; } mysql_close($dbh);
echo "
JSP"; ?> Save this file in /var/www/apache2default/ folder named as“indranil.php”.
NOTE: I have made one line bold in both the jsp and php file, this would generate a hyperlink in the respective pages which would allow the user to toggle from PHP to JSP pages of a same application. By this way we can run both PHP & JSP with MySQL connection in Ubuntu.
Author: Indranil Basu Email:
[email protected] MAT3 Impex Pvt. Ltd., Kolkata064