Friday, December 2, 2011

Updating Table for Particular Records or Rows

Scenario :  We have to update the particular column of a table for some rows range. Using csv data file.


Address Table







add idadd1add2Street city
100sampsamp2testtstcity
101sampsamp2testtstcity
102sampsamp2testtstcity

Monday, November 28, 2011

Inserting CVS Data to DB Using Db command


Command:
  db2 import from C:\test.csv of del insert into address    (addressId,status,nickname,firstname,lastname,email1)

Imp Points:
  • According to csv file the corresponding coloumns have to be specified for the table.
  • Have to be login to DB with Administrative Privilages.

Thursday, November 3, 2011

Creating Datasource in WAS6.0 for MySql -- RAD7.0

This Post about Creating Mtsql Datasource in RAD 7.0 for WAS 6.0 / WAS 6.1
By default WAS 6.0 does not provide datasource for MySql. We have to create User defined JDBC provider for the My Sql.

The detailed Steps for the Creation.

Step1:
In Admin console select Data Source under Resources.




 


















Step : 3
On the new screen, select User-Defined in Database type field (because WAS doesn’t have MySQL pre-defined), com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource in Implementation Class Name field and MySQL JDBC Provider in Name field.



Step 4: Specify the Jar file path for MySql JDBC connection.


Step 5: Click Finish button.



Step 7: After finishing Again click on the "Test"(what we created just now) Datasource on list of data sources, and Click on the right side JASS-J2C Authentication.


Step 8: Fill the database authentication details like username and password.

Step 9: Just Last Step. We have to fill in some custom properties. like databaseName, URL (of the Database).



Step 10 : in Custom properties look for the URL and enter the Database Access url.







Step 11: now select the authentication we creatted now.

Step 13; now test the connection. its successful.


Retriving Image From Database


// column is column index in ResultSet containing the image,
// we assume that the type is LONGVARBINARY
Image myImage = null;
InputStream stream = rset.getBinaryStream(column);
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
int a1 = stream.read();
while (a1 >= 0) {
output.write((char)a1);
a1 = stream.read();
}
myImage =
Toolkit.getDefaultToolkit().createImage(output.toByteArray());
output.close();
}
catch(Exception e){}

Wednesday, November 2, 2011

Map Sorting Using Comparator

This Post about sorting TreeMap.

TreeMap Actually sorts values by key. Inorder to sort Map by values we have to use comparator. The below program illustrates this.


public class ComparatorClassDemo {
 
    public static void main(String[] args) {
     
        HashMap<Integer,String> map = new HashMap<Integer,String>();
        ValueComparator bvc =  new ValueComparator(map);
        TreeMap<Integer,String> sorted_map = new TreeMap(bvc);
     
     
        map.put(1,"Arogya");
        map.put(2,"wer");
        map.put(3,"dfg");
        map.put(6,"io");
        map.put(5,"lkaldfk");
        map.put(4,"bkjaskj");
       
System.out.println("Before usage of comparator"+map);
     
     
        sorted_map.putAll(map);
     
        System.out.println("results");
        for (int key : sorted_map.keySet()) {
            System.out.println("key/value: " + key + "/"+sorted_map.get(key));
        }
    }
 
}
class ValueComparator implements Comparator {
    Map base;
  public ValueComparator(Map base) {
      this.base = base;
  }

  public int compare(Object a, Object b) {
    String name=(String)base.get(a);
    String name1=(String)base.get(b);
    return name.compareTo(name1);
  }
}



OutPut:





{2=wer, 4=bkjaskj, 6=io, 1=Arogya, 3=dfg, 5=lkaldfk}
results
key/value: 1/Arogya
key/value: 4/bkjaskj
key/value: 3/dfg
key/value: 6/io
key/value: 5/lkaldfk
key/value: 2/wer



Thursday, October 27, 2011

Checking of Crond Service is Running Or Not

In order to check wether "crond" service is running or not, First you have to be root user or you must have permissions of root/sudo user.

Command:-

sudo /sbin/service crond status

The Result for Above commad:

crond (pid 3342) is running...


Means crond service is running.

Friday, October 7, 2011

Calculating Difference between two dates Excluding Weekends


This script calculates the difference between two dates excluding weekdays. If Saturday and Sunday  are there in given dates it will exclude these days and gives the remaining days result.


<html>
<body>


<script type="text/javascript">
 var iWeeks, iDateDiff, iAdjust = 0;
      var fromDateSplit1 = "2011-08-05 18:31:36.0".split(" ");  // Date,mm,Year
      var toDateSplit1 = "2011-08-08 18:31:36.0".split(" ");
      var fromDateSplit =  fromDateSplit1[0].split("-");
      var toDateSplit =  toDateSplit1[0].split("-");
      
      var startDate = new Date(fromDateSplit[0],fromDateSplit[1]-1,fromDateSplit[2]);
      var endDate = new Date(toDateSplit[0],toDateSplit[1]-1,toDateSplit[2]);
      alert(startDate);
      alert(endDate );
       // if (endDate < startDate) return -1; // error code if dates transposed
        var iWeekday1 = startDate.getDay(); // day of week
        var iWeekday2 = endDate.getDay();
        iWeekday1 = (iWeekday1 == 0) ? 7 : iWeekday1; //change Sunday from 0 to 7
        iWeekday2 = (iWeekday2 == 0) ? 7 : iWeekday2;
        if ((iWeekday1 > 5) && (iWeekday2 > 5)) iAdjust = 1; //bth days on weekend
        iWeekday1 = (iWeekday1 > 5) ? 5 : iWeekday1; // only count weekdays
        iWeekday2 = (iWeekday2 > 5) ? 5 : iWeekday2;
      // differnece in weeks (1000mS * 60sec * 60min * 24hrs * 7 days = 604800000)
        iWeeks = Math.floor((endDate.getTime() - startDate.getTime()) / 604800000)


        if (iWeekday1 <= iWeekday2) {
          iDateDiff = (iWeeks * 5) + (iWeekday2 - iWeekday1)
        } else {
          iDateDiff = ((iWeeks + 1) * 5) - (iWeekday1 - iWeekday2)
        }


        iDateDiff -= iAdjust // take into account both days on weekend


        alert(iDateDiff + 1); 
</script>


</body>
</html>

Wednesday, September 28, 2011

Connecting to MySql DB Through Terminal



Mysql Client Syntax :
mysql -u {mysql-user} -p {mysql-password} -h {mysql-server}

Example command:
mysql -u root -p testPassword -h localhost

 -- it will connect to mysql DB and session will be created.


As usual we can work on this session.
All normal commands will work.

For further Help: Type " man mysql "

It will show more additional options.

Friday, August 12, 2011

Converting Jsp/Html Form Values To XML

Requirements:

1. For this i used Castor Framework, it makes my work simple.
   http://www.castor.org/download.html

Go for the  " Full documentation including all JavaDocs and specs (big) "
b'cos it includes all the dependency jar files.

2. Include those Jars project.

Procedure:

Write a Jsp with minimal form elements and calling to servlet or action.
i called action in this example.




<form name="sample" action="AccessDB" method="get">

<table>

<tbody><tr>

<td>CUSTOMER Id</td>

<td> <input type="text" name="custid" value="" size="15" /></td>

</tr>

<tr>

<td>CUSTOMER NAME</td>

<td><input type="text" name="name" value="" size="25" /></td>

</tr>

<tr>

<td>DISCOUNT ID</td>

<td><select name="discountid">

<option>H</option>

<option>M</option>

<option>L</option>

<option>N</option>

</select></td>

</tr>

<tr><td> ZIP</td>

<td><input type="text" name="zip" value="" size="10" /></td>

</tr>

<tr>

<td><input type="submit" value="Submit"/></td>

</tr>

</tbody>

</form>


Here AccessDb is servlet.
below is the servlet code:



CustomerBean cb=new CustomerBean();

cb.setCustid(request.getParameter("custid").toString());

cb.setName(request.getParameter("name").toString());

cb.setDiscountid(request.getParameter("discountid").toString());

cb.setZip(request.getParameter("zip"));




FileWriter writer = new FileWriter("/home/miracle/Desktop/cbs.xml");

Marshaller.marshal(cb, writer);



CustomerBean  is a normal pojo class with normal setters and getters. 

It will create a XMl file on specified path.

<?xml version="1.0" encoding="UTF-8"?>
<customer-bean><discountid>H</discountid><name>Venkat</name><custid>1003</custid><zip>53662</zip></customer-bean>

Friday, August 5, 2011

CronTab Usage

Actual Syntax Of CronTab

* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)


 Task: Run the file daily at 11:30pm

30---> Minutes
23---> Hours
*  ---> DayOfthemonth
*  ---> Month
*  ---> Week

will call the "sample.sh" file at every day 11:30pm

To enter new cron Job,  type in terminal : crontab -e

30 23 * * * /home/sample.sh        


The above specified cron job will on every day

we have restart the crond service to get it effective.

  • # /etc/init.d/crond start
  • # /etc/init.d/crond stop
  • # /etc/init.d/crond restart

To See List Of CronJobs:

  •  # crontab -l

To Edit CronJob:  #crontab -e

After Edit you have to restart the "crond"  service to make it effective.

Wednesday, July 13, 2011

Earn Online

Full Training Provided. Part time data entry jobs with bi-weekly payments! Make Rs.1500 to 3000/day with legit data entry jobs. Bi-weekly Payments? Earn up to Rs. 75/- per data entry form. Make Rs.1500 to 3000/- a Day working full/part time data entry operators. There are already 2,40,000 people around the world grabbed this opportunity and making tons of money every month. No Investment. Bi-weekly Payments.
Pls visit : http://www.onlinejobsopen.com/?id=637568

Friday, July 1, 2011

JTA Transactions--- TWO Phase Commit Implementation

Understanding JTA—the Java Transaction API (cont.)


Distributed Transactions and the Transaction Manager
As we stated previously, a distributed transaction is a transaction that accesses and updates data on two or more networked resources. These resources could consist of several different RDBMSs housed on a single sever, for example, Oracle, SQL Server, and Sybase; or they could include several instances of a single type of database residing on a number of different servers. In any case, a distributed transaction involves coordination among the various resource managers. This coordination is the function of the transaction manager.
The transaction manager is responsible for making the final decision either to commit or rollback any distributed transaction. A commit decision should lead to a successful transaction; rollback leaves the data in the database unaltered. JTA specifies standard Java interfaces between the transaction manager and the other components in a distributed transaction: the application, the application server, and the resource managers. This relationship is illustrated in the following diagram:
The numbered boxes around the transaction manager correspond to the three interface portions of JTA:
1—UserTransaction—The javax.transaction.UserTransaction interface provides the application the ability to control transaction boundaries programmatically. The javax.transaction.UserTransaction method starts a global transaction and associates the transaction with the calling thread.
2—Transaction Manager—The javax.transaction.TransactionManager interface allows the application server to control transaction boundaries on behalf of the application being managed.
3—XAResource—The javax.transaction.xa.XAResource interface is a Java mapping of the industry standard XA interface based on the X/Open CAE Specification (Distributed Transaction Processing: The XA Specification).
Notice that a critical link is support of the XAResource interface by the JDBC driver. The JDBC driver must support both normal JDBC interactions, through the application and/or the application server, as well as the XAResource portion of JTA.
Developers of code at the application level should not be concerned about the details of distributed transaction management. This is the job of the distributed transaction infrastructure—the application server, the transaction manager, and the JDBC driver. The only caveat for application code is that is should not invoke a method that would affect the boundaries of a transaction while the connection is in the scope of a distributed transaction. Specifically, an application should not call the Connection methods commit, rollback, and setAutoCommit(true) because they would interfere with the infrastructure's management of the distributed transaction.
The Distributed Transaction Process
The transaction manager is the primary component of the distributed transaction infrastructure; however, the JDBC driver and application server components should have the following characteristics:
  • The driver should implement the JDBC 2.0 API, including the Optional Package interfaces XADataSource and XAConnection, and the JTA interface XAResource.

  • The application server should provide a DataSource class that is implemented to interact with the distributed transaction infrastructure and a connection pooling module (for improved performance).
The first step of the distributed transaction process is for the application to send a request for the transaction to the transaction manager. Although the final commit/rollback decision treats the transaction as a single logical unit, there can be many transaction branches involved. A transaction branch is associated with a request to each resource manager involved in the distributed transaction. Requests to three different RDBMSs, therefore, require three transaction branches. Each transaction branch must be committed or rolled back by the local resource manager. The transaction manager controls the boundaries of the transaction and is responsible for the final decision as to whether or not the total transaction should commit or rollback. This decision is made in two phases, called the Two-Phase Commit Protocol.
In the first phase, the transaction manager polls all of the resource managers (RDBMSs) involved in the distributed transaction to see if each one is ready to commit. If a resource manager cannot commit, it responds negatively and rolls back its particular part of the transaction so that data is not altered.
In the second phase, the transaction manager determines if any of the resource managers have responded negatively, and, if so, rolls back the whole transaction. If there are no negative responses, the translation manager commits the whole transaction, and returns the results to the application.
Developers of transaction manager code must be conversant with all three interfaces of JTA: UserTransaction, TransactionManager, and XAResource, which are described in the Sun JTA specification. The JDBC API Tutorial and Reference, Second Edition is also a useful reference. JDBC driver developers need only be concerned with the XAResource interface. This interface is a Java mapping of the industry standard X/Open XA protocol that allows a resource manager to participate in a transaction. The component of the driver connected with the XAResource interface is responsible for "translating" between the transaction manager and the resource manager. The following section provides examples of XAResource calls.
The JDBC Driver and XAResource
To simplify the explanation of XAResource, these examples illustrate how an application would use JTA when there is no application server and transaction manager involved. Basically, the application in these examples is also acting as application server and transaction manager. Most enterprises use transaction managers and application servers because they manage distributed transactions much more efficiently than an application can. By following these examples, however, an application developer can test the robustness of JTA support in a JDBC driver. Some examples may not work for a particular database because of inherent problems associated with that database.
Before using JTA, you must first implement an Xid class for identifying transactions (this would normally be done by the transaction manager). The Xid contains three elements: formatID, gtrid (global transaction ID), and bqual (branch qualifier ID).
The formatID is usually zero, meaning that you are using the OSI CCR (Open Systems Interconnection Commitment, Concurrency, and Recovery standard) for naming. If you are using another format, the formatID should be greater than zero. A value of -1 means that the Xid is null.
The gtrid and bqual can each contain up to 64 bytes of binary code to identify the global transaction and the branch transaction, respectively. The only requirement is that the gtrid and bqual taken together must be globally unique. Again, this can be achieved by using the naming rules specified in the OSI CCR.
The following example illustrates implementation of an Xid:

import javax.transaction.xa.*;
public class MyXid implements Xid
{
    protected int formatId;
    protected byte gtrid[];
    protected byte bqual[];

    public MyXid()
    {
    }

    public MyXid(int formatId, byte gtrid[], byte bqual[])
    {
        this.formatId = formatId;
        this.gtrid = gtrid;
        this.bqual = bqual;
    }


    public int getFormatId()
    {
        return formatId;
    }

    public byte[] getBranchQualifier()
    {
        return bqual;
    }

    public byte[] getGlobalTransactionId()
    {
        return gtrid;
    }

}
Second, you need to create a datasource for the database that you are using:

public DataSource getDataSource()
    throws SQLException
{
    SQLServerDataSource xaDS = new
        com.merant.datadirect.jdbcx.sqlserver.SQLServerDataSource();
    xaDS.setDataSourceName("SQLServer");
    xaDS.setServerName("server");
    xaDS.setPortNumber(1433);
    xaDS.setSelectMethod("cursor");
    return xaDS;
}
Example 1—This example uses the two-phase commit protocol to commit one transaction branch:

XADataSource xaDS;
XAConnection xaCon;
XAResource   xaRes;
Xid          xid;
Connection   con;
Statement    stmt;
int          ret;

xaDS = getDataSource();
xaCon = xaDS.getXAConnection("jdbc_user", "jdbc_password");
xaRes = xaCon.getXAResource();

con = xaCon.getConnection();
stmt = con.createStatement();

xid = new MyXid(100, new byte[]{0x01}, new byte[]{0x02});

try {
    xaRes.start(xid, XAResource.TMNOFLAGS);
    stmt.executeUpdate("insert into test_table values (100)");
    xaRes.end(xid, XAResource.TMSUCCESS);

    ret = xaRes.prepare(xid);
    if (ret == XAResource.XA_OK) {
        xaRes.commit(xid, false);
    }
}
catch (XAException e) {
    e.printStackTrace();
}
finally {
    stmt.close();
    con.close();
    xaCon.close();
}
Because the initialization code is the same or very similar for all the examples, only significantly different code is represented from this point forward.
Example 2—This example, similar to Example 1, illustrates a rollback:

xaRes.start(xid, XAResource.TMNOFLAGS);
stmt.executeUpdate("insert into test_table values (100)");
xaRes.end(xid, XAResource.TMSUCCESS);

ret = xaRes.prepare(xid);
if (ret == XAResource.XA_OK) {
    xaRes.rollback(xid);
}
Example 3—This example shows how a distributed transaction branch suspends, lets the same connection do a local transaction, and them resumes the branch later. The two-phase commit actions of distributed transaction do not affect the local transaction.

xid = new MyXid(100, new byte[]{0x01}, new byte[]{0x02});

xaRes.start(xid, XAResource.TMNOFLAGS);
stmt.executeUpdate("insert into test_table values (100)");
xaRes.end(xid, XAResource.TMSUSPEND);

// This update is done outside of transaction scope, so it
// is not affected by the XA rollback.
stmt.executeUpdate("insert into test_table2 values (111)");

xaRes.start(xid, XAResource.TMRESUME);
stmt.executeUpdate("insert into test_table values (200)");
xaRes.end(xid, XAResource.TMSUCCESS);

ret = xaRes.prepare(xid);
if (ret == XAResource.XA_OK) {
    xaRes.rollback(xid);
}
Example 4—This example illustrates how one XA resource can be shared among different transactions. Two transaction branches are created, but they do not belong to the same distributed transaction. JTA allows the XA resource to do a two-phase commit on the first branch even though the resource is still associated with the second branch.

xid1 = new MyXid(100, new byte[]{0x01}, new byte[]{0x02});
xid2 = new MyXid(100, new byte[]{0x11}, new byte[]{0x22});

xaRes.start(xid1, XAResource.TMNOFLAGS);
stmt.executeUpdate("insert into test_table1 values (100)");
xaRes.end(xid1, XAResource.TMSUCCESS);

xaRes.start(xid2, XAResource.TMNOFLAGS);

// Should allow XA resource to do two-phase commit on
// transaction 1 while associated to transaction 2
ret = xaRes.prepare(xid1);
if (ret == XAResource.XA_OK) {
    xaRes.commit(xid2, false);
}

stmt.executeUpdate("insert into test_table2 values (200)");
xaRes.end(xid2, XAResource.TMSUCCESS);

ret = xaRes.prepare(xid2);
if (ret == XAResource.XA_OK) {
    xaRes.rollback(xid2);
}
Example 5—This example illustrates how transaction branches on different connections can be joined as a single branch if they are connected to the same resource manager. This feature improves distributed transaction efficiency because it reduces the number of two-phase commit processes. Two XA connections to the same database server are created. Each connection creates its own XA resource, regular JDBC connection, and statement. Before the second XA resource starts a transaction branch, it checks to see if it uses the same resource manager as the first XA resource uses. If this is case, as in this example, it joins the first branch created on the first XA connection instead of creating a new branch. Later, the transaction branch can be prepared and committed using either XA resource.

xaDS = getDataSource();

xaCon1 = xaDS.getXAConnection("jdbc_user", "jdbc_password");
xaRes1 = xaCon1.getXAResource();
con1 = xaCon1.getConnection();
stmt1 = con1.createStatement();

xid1 = new MyXid(100, new byte[]{0x01}, new byte[]{0x02});
xaRes1.start(xid1, XAResource.TMNOFLAGS);
stmt1.executeUpdate("insert into test_table1 values (100)");
xaRes1.end(xid, XAResource.TMSUCCESS);

xaCon2 = xaDS.getXAConnection("jdbc_user", "jdbc_password");
xaRes2 = xaCon1.getXAResource();
con2 = xaCon1.getConnection();
stmt2 = con1.createStatement();

if (xaRes2.isSameRM(xaRes1)) {
    xaRes2.start(xid1, XAResource.TMJOIN);
    stmt2.executeUpdate("insert into test_table2 values (100)");
    xaRes2.end(xid1, XAResource.TMSUCCESS);
}
else {
    xid2 = new MyXid(100, new byte[]{0x01}, new byte[]{0x03});
    xaRes2.start(xid2, XAResource.TMNOFLAGS);
    stmt2.executeUpdate("insert into test_table2 values (100)");
    xaRes2.end(xid2, XAResource.TMSUCCESS);
    ret = xaRes2.prepare(xid2);
    if (ret == XAResource.XA_OK) {
        xaRes2.commit(xid2, false);
    }
}

ret = xaRes1.prepare(xid1);
if (ret == XAResource.XA_OK) {
    xaRes1.commit(xid1, false);
}
Example 6—This example shows how to recover prepared or heuristically completed transaction branches during failure recovery. It first tries to rollback each branch; if it fails, it tries to tell resource manager to discard knowledge about the transaction.

MyXid[] xids;

xids = xaRes.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN);
for (int i=0; xids!=null && i<xids.length; i++) {
    try {
        xaRes.rollback(xids[i]);
    }
    catch (XAException ex) {
        try {
            xaRes.forget(xids[i]);
        }
        catch (XAException ex1) {
            System.out.println("rollback/forget failed: " + ex1.errorCode);
            }
     }
}

Wednesday, June 8, 2011

Inserting Image into DB Using Prepared Statement


File file = new File("myimage.gif");
FileInputStream fis = new FileInputStream(file);
PreparedStatement ps =
conn.prepareStatement("insert into images values (?,?)");
ps.setString(1,file.getName());
ps.setBinaryStream(2,fis,(int)file.length());
ps.executeUpdate();
ps.close();
fis.close();

Thursday, March 3, 2011

JavaScript Multiple Select Code

Struts Select Tag:

<s:select list="assignedMembers" name="assignedTo1" id="assignedTo1"  size="8"  cssClass="inputSelectExtraLarge" value="%{currentRequirement.assignedTo}" multiple="true" onclick="listbox_moveacross('assignedTo1', 'assignedTo')"/>

JavaScript Function For Moving Items:

--> listbox_moveacross('source Id', 'Destination Id')

JavaScript Function Def:


<script type="text/JavaScript">
            function listbox_moveacross(sourceID, destID) {
                var src = document.getElementById(sourceID);
                var dest = document.getElementById(destID);

                for(var count=0; count < src.options.length; count++) {

                    if(src.options[count].selected == true) {
                        var option = src.options[count];

                        var newOption = document.createElement("option");
                        newOption.value = option.value;
                        newOption.text = option.text;
                        newOption.selected = true;
                        try {
                            dest.add(newOption, null); //Standard
                            src.remove(count, null);
                        }catch(error) {
                            dest.add(newOption); // IE only
                            src.remove(count);
                        }
                        count--;

                    }

                }

            }

            function listbox_selectall(listID, isSelect) {

                var listbox = document.getElementById(listID);
                for(var count=0; count < listbox.options.length; count++) {

                    listbox.options[count].selected = isSelect;

                }
            }


        </script>

Generating List  :

 if(currentRequirement.getAssignedTo()!=null){
                        assignedList=new ArrayList();
                        String names[]=currentRequirement.getAssignedTo().split(",");
                        for(int i=0;i<names.length;i++){
                            assignedList.add(names[i]);
                        }
                    }

Getter and Setter method for assainList has to be added.
private List assainList;

Thursday, February 10, 2011

Creating Queue manager using Command Prompt.

****************************************
* Command: crtmqm  -q Apple
****************************************
WebSphere MQ queue manager created.
Creating or replacing default objects for Apple.
Default objects statistics : 43 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.
exitvalue = 0
****************************************
* Command: amqmdain qmgr start Apple
****************************************
WebSphere MQ queue manager 'Apple' starting.
5 log records accessed on queue manager 'Apple' during the log replay phase.
Log replay for queue manager 'Apple' complete.
Transaction manager state recovered for queue manager 'Apple'.
WebSphere MQ queue manager 'Apple' started.
exitvalue = 0
****************************************
* Command: runmqsc Apple
* Input: DEFINE LISTENER('LISTENER.TCP') TRPTYPE(TCP) PORT(3414) CONTROL(QMGR)
****************************************
5724-H72 (C) Copyright IBM Corp. 1994, 2004.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager Apple.


     1 : DEFINE LISTENER('LISTENER.TCP') TRPTYPE(TCP) PORT(3414) CONTROL(QMGR)
AMQ8626: WebSphere MQ listener created.
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
exitvalue = 0
****************************************
* Command: runmqsc Apple
* Input: START LISTENER('LISTENER.TCP')
****************************************
5724-H72 (C) Copyright IBM Corp. 1994, 2004.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager Apple.


     1 : START LISTENER('LISTENER.TCP')
AMQ8021: Request to start WebSphere MQ Listener accepted.
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
exitvalue = 0
****************************************
* Command: amqmdain auto Apple
****************************************
5724-H72 (C) Copyright IBM Corp. 1994, 2004.  ALL RIGHTS RESERVED.
Queue Manager 'Apple' successfully set to 'Automatic' mode
exitvalue = 0

Tuesday, February 8, 2011

Emails Seperator from Text File


<!-- TWO STEPS TO INSTALL EXTRACT EMAIL ADDRESSES:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the last code into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Ronnie T. Moore, Editor -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function findEmailAddresses(StrObj) {
var separateEmailsBy = ", ";
var email = "<none>"; // if no match, use this
var emailsArray = StrObj.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
if (emailsArray) {
email = "";
for (var i = 0; i < emailsArray.length; i++) {
if (i != 0) email += separateEmailsBy;
email += emailsArray[i];
      }
   }
return email;
}
//  End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<center>
<form>
<textarea name=comments rows=10 cols=50 onBlur="this.form.email.value=findEmailAddresses(this.value);"></textarea>
<br>
Email:  <input type=text name=email>
</form>
</center>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

Monday, February 7, 2011

Persistence Through Mb Sample Code

Hi All:
CREATE COMPUTE MODULE selectDatabase_Compute
    CREATE FUNCTION Main() RETURNS BOOLEAN
    BEGIN
        -- CALL CopyMessageHeaders();
        -- CALL CopyEntireMessage();
        DECLARE a INTEGER;
        DECLARE Sname CHARACTER;
       
    --    SET a=InputRoot.XMLNSC.message.a;
        --SET Sname =
        SET OutputRoot.XMLNSC.message.
Result[]=PASSTHRU('SELECT SNAME,SNO FROM STUDENT   WHERE SNO= ? WITH UR',InputRoot.XMLNSC.message.a);
        SET Environment.Sname=OutputRoot.XMLNSC.message.Result[1].SNAME;
        SET OutputRoot.XMLNSC=null;
        SET OutputRoot.XMLNSC.Result=Environment.Sname;
        RETURN TRUE;
    END;
// the code above coloured is Mb generated code.





For insertion into the database:


CREATE COMPUTE MODULE selectDatabase_Compute
    CREATE FUNCTION Main() RETURNS BOOLEAN
    BEGIN
        -- CALL CopyMessageHeaders();
        -- CALL CopyEntireMessage();
       
    PASSTHRU('INSERT INTO STUDENT(SNO,SNAME) VALUES(?,?) ',InputRoot.XMLNSC.message.a,InputRoot.XMLNSC.message.b);
    RETURN TRUE;
    END;