Friday, February 27, 2009

Advantages of SQL server 2005 over SQL server 2000/ SQL server 7.0

  • SQL server 2005 is exclusively designed for dot net developers. Whatever the function or procedure that we write in dot net environment those function or procedure that we directly execute in sql server environment. This is the new feature in SQL Server 2005.
  • SQL Server 2005 has reduced application downtime, increased scalability and performance, and tight yet flexible security controls.
  • SQL Server 2005 makes it simpler and easier to deploy, manage, and optimize enterprise data and analytical applications.
  • It enables you to monitor, manage, and tune all of the databases in the effective way.
  • Failure of the primary system, applications can immediately reconnect to the database on the secondary server using Database Mirroring.
  • SQL Server 2005 provides a new capability for the partitioning of tables across file groups in a database.
  • Has Features of XML, Multidimensional Expressions (MDX), and XML for Analysis (XMLA). Integration with the Visual Studio development environment provides more efficient development and debugging of line-of-business and business intelligence (BI) applications.

Wednesday, February 25, 2009

Making a file read only through Java

This sample code makes a file read only.

import java.io.File;
public class ReadOnlyExp {
public static void main(String[] args) {
File file=new File("c:\\MyFile");
file.setReadOnly();
}
}

source: java-tips.org

Sunday, February 22, 2009

Java on Mainframe OS

User from the Web can initiate a transaction that might communicate with a mainframe database (DB2®, Information Management System (IMS), and so forth), or even with a Virtual Storage Access Method (VSAM) file. As a result, the mainframe then returns the data in a well-formatted Web page. The Web user can also initiate an update on the mainframe database as well.

On one side, you have the highly robust and scalable mainframe. On the other, you have the flexibility of Java and the Web world. As noted above, a typical Web application would initiate a transaction that would do a one-off database access.

The Java solution to submit the batch jobs from a Z/OS mainframe.

package fileTransferProtocol;
import org.apache.commons.net.ftp.*;
import java.io.*;
public class FileTransferProtocol {
public static void main (String [ ] args) {
String serverName ="my.zos.mainframe" ;
String userName ="userid" ;
String password ="********" ;
FTPClient ftp = new FTPClient() ;
//Connect to the server
try {
ftp.connect (serverName) ;
String replyText =ftp.getReplyString() ;
System.out.println (replyText) ;
}
catch (Exception e) {
e.printStackTrace () ;
}
//Login to the server
try {
ftp.login (userName, password) ;
String replyText =
ftp.getReplyString() ;
System.out.println (replyText);
} catch (Exception e) {
e.printStackTrace();
}
//Tell server that the file will have JCL records
try {
ftp.site ("filetype=jes") ;
String replyText =
ftp.getReplyString() ;
System.out.println (replyText) ;
}
catch (Exception e) {
e.printStackTrace() ;
}
//Submit the job from the text file.Use \\ to avoid using escape notation
try {
FileInputStream inputStream = new FileInputStream ("C:\\job.txt") ;
ftp.storeFile (serverName,inputStream) ;
String replyText =
ftp.getReplyString() ;
System.out.println (replyText) ;
}
catch (Exception e) {
e.printStackTrace() ;
}
//Quit the server
try {
ftp.quit();
}
catch (Exception e) {
e.printStackTrace() ;
}
}
}

Thursday, February 19, 2009

Queued sequential access method

In IBM mainframe operating systems, a queued sequential access method (QSAM) is one of the access methods for files, or more properly data sets. QSAM files are unkeyed, with the records placed one after another, according to entry order. A program can process these files only sequentially, retrieving (with the READ statement or GET macro instruction) records in the same order as they are in the file. Each record is placed after the preceding record.

QSAM files can be on tape, direct access storage devices (DASDs), unit-record devices, and terminals. QSAM processing is best for tables and intermediate storage.To process QSAM files in a program, a programmer could use COBOL language statements that:
1. Identify and describe the QSAM files in the ENVIRONMENT DIVISION and the DATA DIVISION.
2.Process the records in these files in the PROCEDURE DIVISION.

After a record is created, its length or its position in the file cannot be changed, and it cannot be deleted. QSAM files can, however, be updated on DASD (using REWRITE).The record definitions that are coded in COBOL program and the length of the variables read into and written from determines the amount of data transferred.

Ref:wikipedia

Monday, February 16, 2009

Listing all drives on a file system

You can list the drives of the system by using the listRoots() method of the File class:

File[] roots = File.listRoots();for(int i=0;i
System.out.println("Root["+i+"]:" + roots[i]);

source: java-tips.org

Friday, February 13, 2009

Comparison of Oracle, DB2 and SQL SERVER

SQL SERVER runs only under windows operating system.

In contrast, Oracle, DB2 runs in most of operating systems.

DB2 was originally designed to run on IBM mainframe systems and continues to be the premier database for those systems. It also dominates in hybrid environments where IBM mainframes and newer servers must coexist. Although it has a reputation for being expensive, it is also has a reputation for being reliable and easy to use.

Oracle has a huge installed base of customers and continues to dominate the marketplace, especially for Unix operating system. It is highly reliable, it is expensive and difficult to use.

SQL SERVER is widely used for small to medium sized departmental systems. It is inexpensive and easy to use, but it is also unreliable and for not scaling well for systems with a large number of users.

Wednesday, February 11, 2009

Advantage of ReadOnly over Constant variables in dotnet

Constant variables are compile time constants whereas ReadOnly variables are runtime constants. Compile-time constants are slightly faster, but far less flexible, than runtime constants. Reserve the compile-time constants for when performance is critical and the value of the constant will never change over time.

EXAMPLE:
// Compile time constant:public const int _Millennium = 2000;
// Runtime constant:public static readonly int _ThisYear = 2004;

Also, you can use readonly values for instance constants, storing different values for each instance of a class type. Compile-time constants are, by definition, static constants.

Sunday, February 08, 2009

CONVERTING FAT32 to NTFS in Windows XP:

1. Open Command Prompt. Click Start, point to All Programs, point to Accessories, and then click Command Prompt.
2. Else Press WIN+R key in the keyboard
3. In the command prompt window, type: convert drive_letter: /fs:ntfs

For example, typing convert D: /fs:ntfs would format drive D: with the ntfs format. You can convert FAT or FAT32 volumes to NTFS with this command.

Important Once you convert a drive or partition to NTFS, you cannot simply convert it back to FAT or FAT32. You will need to reformat the drive or partition which will erase all data, including programs and personal files, on the partition.

Thursday, February 05, 2009

Opening the same file for reading and writing

You can open the same file for reading as well as reading in Java using RandomAccessFile class. RandomAccessFile class supports simultanous reading and writing from/to the same file if you open the file in "rw" mode:
RandomAccessFile raf = new RandomAccessFile("filename.txt", "rw");

source : java-tips.org

Tuesday, February 03, 2009

Why toString() is used in Java

We have toString() method since Java 1.0

It has at least two different meanings:
Displaying: How the object should appear to the user, in the GUI, on a web page, etc. Inspection: How the object should appear in debug output, logs, debugger tools etc. Both are in some way “a string representation of the object”. The default implementation in java.lang.Object suggests inspection, e.g. “java.lang.Object@c37f31”, but many APIs, like AWT/Swing, use it for displaying the object to the user.

Problems: It’s hard to tell which usage is intended when reading the code. Debuggers will use toString(), which can cause confusing side-effects. Since every object has a toString(), the IDE’s usage search becomes unusable. It’s hard to tell if a toString() method is dead code or not. We can’t do much about java.lang.Object, but we still have options.

Suggestion: Use toString() only for logging and debug output.

If the method has a more specific meaning, communicate that instead, e.g. title() or name().

If the value to display has a specific format you can communicate that instead, e.g. toHTML() or asLeetSpeak().

If the value to display is nothing other than a string, still avoid toString(). Call it something like displayString(), or maybe even asString() to avoid problems.

Reference: http://java.sun.com/
Computers Add to Technorati Favorites Programming Blogs - BlogCatalog Blog Directory