Friday, April 30, 2010

Value restricions

Some primitive value besides a conrete data-type may have a predefined set of values. And the value can be set only to one of that variants, like enumerations. XML schema allows us to restrict the value of a given type by a set of enumerated values. From the other hand we can restrict some value by defining its min/max bounds:

http://www.w3.org/2001/XMLSchema">




























source: java-tips.org

Wednesday, April 28, 2010

DataBase Links

A database link is a pointer in the local database that allows you to access the data on a remote database.
For example: If we want to access the database of a different server other than the one we are working on. we cannot access that database directly if we don’t have access.In such cases we use Database links to access the remote database.
There is no special syntax fort using these Dblinks.we should just add that link after the table name as shown below.

Select * from emp where emp_id=’1111111’;

This is the actual query.using this query we should access the remote database to which we don’t have access.In this case you can access that remote database if it has a DBlink available to connect to our database.

For Example if GOAT is the Dblink used to access the database of Goat,then the above query should be given in this way

Select * from emp@GOAT where emp_id=’1111111’

In this way by using DBlinks we can access remote databases.

Monday, April 26, 2010

Tired of including configuration files in your scripts

I am often tired of including configuration files in my scripts. Even if it is a single file it becomes important to include that file in our scripts otherwise we wont get the necessary variables set. Once when I started searching for a workaround for it, I found that we can configure it right in one place and say PHP take care of this headache.
Yes, We can do it.

1.Place all your configuration files in one folder in the server. Say "DOCUMENT_ROOT/config/lib"
2. Create a new file with a name preinclude.php
3. Declare or include (again include ) all your common variables, config files in this file.
4.In the DOCUMENT_ROOT folder create a .htaccess file
5. Write the following code in this:

# Code starts here
php_value auto_prepend_file "path to include directory/preinclude.php"
# Code ends here

We can include whichever file which we feel should be executed before each and every file execution here.

Saturday, April 24, 2010

Advantage of SYNC Class

The SYNCHRONIZED clause is sometimes used with USAGE IS COMP or USAGE IS INDEX items. It is used to optimize speed of processing but it does so at the expense of increased storage requirements.
The word SYNC can be used instead of SYNCHRONIZED.
The SYNCHRONIZED clause is used to explicitly align COMP and INDEX items along their natural word boundaries. Without the SYNCHRONIZED clause, data-items are aligned on byte boundaries.
Example: 01 TWO-BYTE PIC S9(4) COMP SYNC.

Thursday, April 22, 2010

Optimize SOAP Messages

As we all know SOAP content is nothing but a XML.Though XML is descriptive, sometimes it might be typically larger due to the volume of tags. So given the case,if you have any performance problems in using SOAP XML's, consider using Message Transmission Optimization Mechanism (MTOM), which builds on XML-binary Optimized Packaging (XOP). XOP provides a more efficient serialization of XML by using MIME encoding. MTOM uses XOP to encode portions of SOAP messages,while still presenting an XML Infoset to the SOAP application.

Another, more recent alternative is to use XFire. XFire is an open source,standards-compliant SOAP framework that uses the latest technologies, including a StAX parser, to boost SOA messaging performance. As i spoke about StAX,i will give a brief intro about that here…

StAX:Streaming API for XML:
StAX
is a parser API that falls between the tree-navigation DOM and push event-based SAX interfaces. It works serially on an XML document as SAX does, but it allows tokens to be pulled by the application.
Again, unless your performance is unacceptable, you should be fine with regular XML SOAP messages. However, if you are providing services to a large community of clients, you may need to boost your performance using one of the above mentioned alternatives.

Tuesday, April 20, 2010

Show data with JTable

This Java Swing tip illustrates a method of showing data in database in a JTable. JTable act as a output for the database. The developer may use this to display a part of data (for example data generated form a query) to the user in a table. The table gives user an impression of database.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class DatabaseTest extends JFrame {
JTextField hostField;
JTextField queryField;
QueryTableModel qtm;

public DatabaseTest() {
super("Database Test Frame");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(350, 200);
qtm = new QueryTableModel();
JTable table = new JTable(qtm);
JScrollPane scrollpane = new JScrollPane(table);
JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(3, 2));
p1.add(new JLabel("Enter the Host URL: "));
p1.add(hostField = new JTextField());
p1.add(new JLabel("Enter your query: "));
p1.add(queryField = new JTextField());
p1.add(new JLabel("Click here to send: "));
JButton jb = new JButton("Search");

jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
qtm.setHostURL(hostField.getText().trim());
qtm.setQuery(queryField.getText().trim());
}
} );

p1.add(jb);
getContentPane().add(p1, BorderLayout.NORTH);
getContentPane().add(scrollpane, BorderLayout.CENTER);
}
public static void main(String args[]) {
DatabaseTest tt = new DatabaseTest();
tt.setVisible(true);
}
}

Source: java-tips.org

Sunday, April 18, 2010

Creating a Confirm Dialog Box

The easiest way to create a Yes/No/Cancel dialog box is to use showConfirmDialog(Component, Object) method of JOptionPane class.
The following example uses a confirm dialog box with a text message and stores response in the response variable:
int response;
response = JOptionPane.showConfirmDialog(null, "Should i delete all files?");


source: java-tips.org

Friday, April 16, 2010

Restarting Windows Without Restarting Your PC

A modern PC with Vista Home Edition takes about one and a half minutes to boot. An older machine with XP is about the same. That’s 30 seconds for the PC itself (the BIOS) to boot up, plus a minute for the Windows operating system to boot. Sometimes, you need to reboot Windows (e.g. when installing new software), but there is no need to restart BIOS, too. However, the default is to reboot both. (That’s called doing a “cold boot,” rather than a “warm boot.”) There’s a trick that works on both XP and Vista to get it to do a warm boot instead, thus saving you 30 seconds per cycle.
The trick is to hold down the SHIFT key when invoking the restart.
Select Start. Select “Shut Down…”. Change the drop-down combo box under “What do you want the computer to do?” to “Restart”. Hold down the SHIFT key while clicking on the “OK” button.

Source: www.masternewmedia.org

Wednesday, April 14, 2010

Lotus notes: Change your password

In my previous article about lotus notes, we have seen how to configure an email account in Lotus notes.Today we will look into the topic, how to change the password of your Lotus notes account.
Open the Lotus notes client,1. Go to File-> Security-> User Security2. In the 'User Security' window, go to 'Your Login and Password Settings' section3. Click on the 'Change Password' button4. Change Password Pop up window is displayed 5. Type the new password, then reenter the new password and click OK6. A popup message box is dispayed "Your Password Change succeeded".
Now you can access your email with your new password.

Monday, April 12, 2010

AS/400 Tips 17

Retaining Customization
It is often required or desirable to customize certain system attributes from how they are set out of the box. For example, you may want to change certain command defaults from the IBM-shipped defaults.
When you do an O/S upgrade however, you'll find that your changes were erased. Unless you kept very good documentation, you'll be hard pressed to remember which changes you made.
A good workaround to this is to create a CL source member that contains all the commands you've customized your system with. Keep the source member up to date and include thorough comments.Compile this member into a program, and simply run the program whenever you've done an upgrade.

Source: http://midwareservices.com/tipstricks/windows.htm

Saturday, April 10, 2010

AS/400 Tips 18

POP UP COMMNAD LINES
It's pretty common to be several programs deep in an application when you suddenly have the need for a command line. There's any easy way to allow this without having to back out or switch to a different session.
Program QUSCMDLN is the IBM supplied API to call a command line. No parameters are required. You may want to add a function key to your application programs (perhaps F21) to call this program.
If you don't want to go through this much work, simply change your user profile (CHGUSRPRF) and set QUSCMDLN as your attention key handling program.

Source: http://midwareservices.com/tipstricks/command_lines.htm

Thursday, April 08, 2010

Turn off Indexing to speed up XP

Windows XP keeps a record of all files on the hard disk so when you do a search on the hard drive it is faster. There is a downside to this and because the computer has to index all files, it will slow down normal file commands like open, close, etc. If you do not do a whole lot of searches on your hard drive then I suggest turnning this feature off:
1. Control Panel
2. Administrative Tools
3. Services
4. Disable Indexing Services

Source: www.tweakxp.com

Tuesday, April 06, 2010

Unload .dll’s to Free Memory

Windows Explorer caches DLLs (Dynamic-Link Libraries) in memory for a period of time after the application using them has been closed. This can be an inefficient use of memory.

1. Find the key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer].

2. Create a new sub-key named 'AlwaysUnloadDLL' and set the default value to equal '1' to disable Windows caching the DLL in memory.

3. Restart Windows for the change to take effect.
I tried this after running a intense program, then watched the task manager; memory recovered it self.

Source: www.tweakxp.com

Sunday, April 04, 2010

Input Dialog Box

An input dialog box asks a question and uses a text field to store the response.
The easiest way to create an input dialog in Java is to use showInputDialog(Component, Object, String, int) method of JOptionPane class.

The following example uses this method to create an input dialog box:

String response = JOptionPane.showInputDialog(null, "What is your name?", "Enter your name", JOptionPane.QUESTION_MESSAGE);

Source: java-tips.org

Friday, April 02, 2010

Message Dialog Box

A message dialog box is a simple window that displays information. A message dialog box can be created with a call to the showMessageDialog(Component, Object) method of JOptionPane class.

The following statement creates a message box:
JOptionPane.showMessageDialog(null, "I am happy.");

Source: java-tips.org

Thursday, April 01, 2010

MVS SYSTEM CODES -SB37

An error occurred during end-of-volume processing of a data set. The system was unable to fulfill a request for more space.

1. A program loop caused too many records to be written to the output data set.
2. Insufficient space was allocated to this data set in the JCL.
3. There was no more room available to receive any more output on the output volume, and another volume could not be mounted.

1. Verify that there are no program loops or logic errors.
2. Increase the primary and/or secondary allocations for the data set.
3. Change the JCL to request that the data set be created on a volume with more space.

Ref: http://www.ibmmainframes.com/
Computers Add to Technorati Favorites Programming Blogs - BlogCatalog Blog Directory