Monday, 25 June 2012
Monday, 18 June 2012
creating the hosts in the tomcat server in ubuntu
creating the hosts in the tomcat server in Ubuntu
step1: In the /var/lib/tomcat6/conf/Catalina path we create folder with hostname
example: 'restarant'
step2: In that folder we create the file with name 'ROOT.xml'
/var/lib/tomcat6/conf/Catalina/restaurant/ROOT.xml
step3: put following code in the ROOT.xml file
<Host name="hostname" appBase="webapps/warfilename/"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
</Host>
step5: in Filesystem/etc/hosts file add the hostname and localhost port like
example: 127.0.0.1 restaurant
step6: restart the server
step7: In browser enter url like
example: http://restaurant:8080/(hostname:portnumber)
step1: In the /var/lib/tomcat6/conf/Catalina path we create folder with hostname
example: 'restarant'
step2: In that folder we create the file with name 'ROOT.xml'
/var/lib/tomcat6/conf/Catalina/restaurant/ROOT.xml
step3: put following code in the ROOT.xml file
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="hostname" docBase="/var/lib/tomcat6/webapps/warfilename/" path="" workDir="work/Catalina/hostname/_">
</Context>
example :
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="restaurant" docBase="/var/lib/tomcat6/webapps/Restaurant/" path=""
workDir="work/Catalina/restaurant/_">
</Context>
step4: In the /var/lib/tomcat6/conf/server.xml file host tag(<Host>) data will be re paste in the file after close the host tag(</Host> and change the data in the
example:<Host name="hostname" appBase="webapps/warfilename/"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
</Host>
step5: in Filesystem/etc/hosts file add the hostname and localhost port like
example: 127.0.0.1 restaurant
step6: restart the server
step7: In browser enter url like
example: http://restaurant:8080/(hostname:portnumber)
Labels:
tomcat
Tuesday, 5 June 2012
database and java
Changing the engine in the all tables of the database progrmetically for mysql
Connection connection = null;
try{
//for getting the connecion
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/hydhouse","root","password");
try{
// Create statement object
Statement stmt = connection.createStatement();
//for getting the tables from that database
DatabaseMetaData dbm = connection.getMetaData();
String[] types = {"TABLE"};
ResultSet rs = dbm.getTables(null,null,"%",types);
while (rs.next()){
String table = rs.getString("TABLE_NAME");
//for change the engine in mysql
String sql="ALTER TABLE "+table+" ENGINE = innodb ";
int i=stmt.executeUpdate(sql);
System.out.println(i);
}
}
catch (SQLException s){
connection.close();
System.out.println("SQL Exception " + s);
}