Tuesday, December 8, 2009

Mysql-PHP in JAVA using quercus resin server in windows

Mysql connection with the quercus resin server from java module

In the previous post you can see the installation of the resin server with the hello world example now in this post you can see the mysql connection with the java module in quercus resin server

Here I want to show that basic php-mysql application can be make it run with the java module using resin server where you can write db connection in java and make use of connection in php pages

List of API or jar files required to execute this .

1.mysql-connector-java-5.1.5-bin.jar (from mysql’s download page) (http://www.mysql.com/products/connector/)
2. quercus.jar (in the quercus zip from caucho)
3. resin-util.jar (in the quercus zip from caucho)
4. script-10.jar (in the quercus zip from caucho)
Put all this jar files in lib folder

Follow the steps to setup the mysql-php-java module

Step 1.
Inside \resin-pro-3.1.9\webapps\ROOT\WEB-INF folder create web.xml with the following code

servlet-class="com.caucho.quercus.servlet.QuercusServlet"/>



jdbc:mysql://localhost:3306/test
root





Step2.
inside \resin-pro-3.1.9\webapps\ROOT\WEB-INF\classes\example create java class file with the

DBconnect .java

package example;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import com.caucho.quercus.module.AbstractQuercusModule;
public class DBconnect extends AbstractQuercusModule{
/**
* The DataSource for the table.
*/
private DataSource _ds = null;
/**
* Sets the data source.
*/
public void setDataSource(DataSource ds)
{
_ds = ds;
}
/**
* Initializes the reference to the CourseBean home interface.
*/
public String test_fun()
{
return "Hello raki ";
}
public String conn_db()
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String rtn_str=" ";

try
{
conn=DriverManager.getConnection("jdbc:mysql://localhost/testdb?" + "user=root"); //change testdb to your database name
stmt = conn.createStatement();
//rtn_str+="\n middle \n";
if (stmt.execute("SELECT * FROM table")) {
rs = stmt.getResultSet();
while(rs.next())
{
String filed1 = rs.getString("filed1");//change filed1 to your table column
String filed2 = rs.getString("filed2");//change filed2 to your table column
rtn_str+= " filed1:-"+ filed1 + " filed2:- " + filed2 +"
";
//rtn_str+=" \n"+rs.getInt(1)+"\n";
}
}

}
catch(Exception e)
{
}


//rtn_str+="<\pre>";
return rtn_str;
}


}

Step3.
inside \resin-pro-3.1.9\webapps\ROOT\WEB-INF\classes\META-INF\services create the following file with name “com.caucho.quercus.QuercusModule” put the content

example.DBconnect


step4.
Now inside \resin-pro-3.1.9\webapps\ROOT create the php page which calls the java module with name php_mysql_java.php

echo "your module data comes here “."
";
echo conn_db ().”
";

?>


Step 5.
Now run the hello_world.php from the URL as
http://localhost:8080/ php_mysql_java.php

You should see “your module data comes here
The data base values should comes here ”

PHP in JAVA using quercus resin server in windows

Quercus is Caucho Technology's fast, open-source, 100% Java implementation of the PHP language

Quercus is written for Resin, a Java application server.

If your using resin server then you can able to call java module from the php page . but here I am showing running of php file with the tomcat server using java compiler
The interesting thing is you can import java libraries or module from php page.
Follow the setps to install the quercus (resin server)

Step1.
Download the resin server installation package from the this page(http://www.caucho.com/download/)

Step2.
Unzip downloaded file and put it inside the your c drive

Step3.
dont forgot to install JDk(1.5 or >) and set the environment path for the same

Step4.
when you open resin main folder(\resin-pro-3.1.9) you can see http file click on it and that will start your resin server
NOTE:-in case if you’re not able to run the resin server
Step1.you can see the setup file inside the main resin folder run that folder it will ask you some configuration

Step2.click on the apache server option and give the root path to the apache where you have installed apache so that it can able to access the apache http.conf file form there.

Step3.then press apply and then start http file it should start your resin server now

Step4. In worst case you can able to start the resin sever from the command prompt eit the following command . change the path in to your resin main folder and then run this command” cd:\resin>java –jar lib/resin.jar start” .

Step5.now open browser and type http://localhost:8080/ you should see the default page of the resin server if that comes your installation is correct. then proceed further

Step 6. Inside \resin-pro-3.1.9\webapps\ROOT\WEB-INF folder create web.xml with the following code


servlet-class="com.caucho.quercus.servlet.QuercusServlet"/>




Step7.
inside \resin-pro-3.1.9\webapps\ROOT\WEB-INF\classes\example create java class file with the

HelloWorld .java

package example;

import com.caucho.quercus.module.AbstractQuercusModule;

public class HelloWorld extends AbstractQuercusModule {
/*
** Notice the careful use of the naming
** convention hello_test. This is done
** in order to prevent name collisions
** among different libraries.
*/
public String hello_test(String name)
{
return "Hello, " + name;
}
}

Step8.
inside \resin-pro-3.1.9\webapps\ROOT\WEB-INF\classes\META-INF\services create the following file with name “com.caucho.quercus.QuercusModule” put the content

example.Helloworld

step9.
Now inside \resin-pro-3.1.9\webapps\ROOT create the php page which calls the java module with name hello_world.php

echo "your module data comes here “."
";
echo hello_test("World")."
";

?>

Step 10.
Now run the hello_world.php from the URL as
http://localhost:8080/hello_world.php

You should see “your module data comes here
hello world”

Thursday, February 12, 2009

Basic about Typo3

TYPO3 is a small to midsize enterprise-class Content Management Framework offering the best of both worlds: out-of-the-box operation with a complete set of standard modules and a clean and sturdy high-performance architecture accomodating virtually every kind of custom solution or extension.

For authors, TYPO3 is a user-friendly, intuitive tool, allowing content editors to produce and maintain web pages, using sophisticated functions in just a few clicks of the mouse.

With TYPO3, everyone can participate in web-based communication and customer relations. Seamless integration of multimedia content types and dynamic server-side image manipulation and generation are among the numerous standard options inside this comprehensive toolbox for web-based communication. Also included is an internal messaging and workflow communication system for shared authoring and collaboration.

For administrators and content managers, TYPO3 features an extremely detailed user permissions system for implementing professional content creation and editing workflows. TYPO3 is a server-side platform-independent application that can be used with virtually every browser available.

Web developers and agencies will appreciate the complete separation of design and content. TYPO3 does not limit the design options expected by professional website designers and site redesigns are easily accommodated.

TYPO3 is database-driven and scales easily to deliver web pages and embedded formats in an enterprise content providing environment.

INSTTALING procedure


-If u wants to work with the your present WAMP then make sure Mysql and apache server running proper.

-Place the extracted typo3 folder inside www folder inside your wamp folder where your wamp is running .

-Go to your browser and type your typo3 folder path then it will lunch the typo3 installer.

And follow the below images.....in order


-here enter username and password to access ur database to create database for ur typo3



-in this step u can create new database or use existing database

NOTE- better to create new database



-finally click on login front end and login typo3 by using user name “typo3″ and password “typo3″ if it is a wininstaller other wise use “admin ” for both



-click on import database which import all tables in to ur typo3 database