Friday, September 2, 2011

How to view check-sum values in JAR file

I had couple of jar files  and i need to check bot files are same or not. Hence those are signed jars i checked check sum values both of that jars. Following are the commands i have used.

1. Open terminal and traversed to the jar file location.
    Ex :  cd /wso2/project/support

2. Do checksum as follows.
    Ex :  md5sum axis2-1.6.1.wso2v1.jar

3. You will see this output
     "18da73bd555fc231ad0ee7c93291549d  axiom-1.2.11.wso2v1.jar"




Monday, August 29, 2011

How to create user in oracle database

Following are the commands to create new user in Oracle database.

1. You have to log in to the oracle command window. In command prompt enter below command.
Syntax : sqlplus sys/DB_password@Database as sysdba;
Ex : sqlplus sys/password@orcl as sysdba;

2. Create user New_User_Name identified by password account unlock;

3. grant connect to New_User_Name;

4. grant create session, dba to New_User_Name;

5. commit;

Thursday, August 18, 2011

How to restore oracle dmp file to the database.

Here are the easiest steps to restore oracle dmp file to your database.

1. First you need to login to the sql command line terminal. Open command prompt if you are using windows and if you are using Linux environment open terminal.

2. Then you have to login to the SQL-PLUS as a system administrator. To do that use following command.
"sqlplus sys/admin@ORADB as sysdba"
Eg: D:\Documents and Settings\Administrator>sqlplus sys/admin@ORADB as sysdba

3. Then you have to create a new database user.
3.1 "create user username identified by password account unlock;"
Eg : create user chamara identified by chamara account unlock;
3.2 "grant connect to username;"
Eg : grant connect to chamara;
3.3 "grant create session, dba to chamara;"
Eg : grant create session, dba to chamara;


4. Now you have to exit from the SQL-PLUS and use "exit" command for that.

5. Finally restore your dmp file using this command.

"imp SYSTEM/test@ORADB fromuser=dbadmin touser=username IGNORE=Y FILE=file_path.dmp"

Eg : D:\Documents and Settings\Administrator>imp SYSTEM/test@ORADB fromuser=WSO2_RSCE touser=chamara IGNORE=Y FILE=D:\chamara\sample.dmp

Wednesday, April 27, 2011

Sample java code for start axis2 simple http server with service

Some times you may want to use sample web service to communicate with your client written by java.This example will show you how to start/stop apache simple HTTP server programatically and upload axis2 service to the simple axis2 service programatically.

import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.deployment.DeploymentEngine;
import org.apache.axis2.description.AxisServiceGroup;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.transport.http.SimpleHTTPServer;

import java.io.File;

public class HTTPServerManager {
private static SimpleHTTPServer server;
protected int serverPort = 9000;

public synchronized void startHTTPServer() {
ConfigurationContext context;
try {
context = ConfigurationContextFactory.
createConfigurationContextFromFileSystem(location of axis2.xml, null);
server = new SimpleHTTPServer(context, serverPort);
String resourcePath = HTTPServerManager.class.getResource("location of axis2service.aar").getPath();
AxisServiceGroup serviceGroup = DeploymentEngine.loadServiceGroup(new File(resourcePath), context);
AxisConfiguration xConfig = context.getAxisConfiguration();
xConfig.addServiceGroup(serviceGroup);
server.start();

} catch (AxisFault axisFault) {
axisFault.printStackTrace();
}
}

/**
* Method used to stop SimpleHTTPServer
*/
public synchronized void stopHTTPServer() {
server.stop();
}

public static void main {
startHTTPServer();
stopHTTPServer()
}
}

Monday, April 25, 2011

How to write Java code to listen runtime changes in text file

I had a requirement to write a java code to listen continues changing text file.i have used following code to do that.

public void listenServer() throws IOException {
Reader fileReader = new FileReader("/home/chamara/server.log");
BufferedReader input = new BufferedReader(fileReader);
String line = null;
while (true) {
if ((line = input.readLine()) != null) {
System.out.println(line);
continue;
}
try {
Thread.sleep(1000L);
} catch (InterruptedException x) {
Thread.currentThread().interrupt();
break;
}
}
input.close();
return isException;
}

Thursday, April 7, 2011

How to start simple HTTP server

Few days ago i had a requirement to host my own axis2 web service to the web sever.to that
How to run maven build without test
This is simple one line command.go to the build directory from command prompt and type following command.
mvn clean install -Dmaven.test.skip=true