Wednesday, February 28, 2007

DB: Configure a Server to Listen on a Specific TCP Port

How to: Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager)

For Microsoft SQL Server 2005:

To assign a TCP/IP port number to the SQL Server Database Engine 2005:

Open SQL Server Configuration Manager from Start->Programs->Microsoft SQL Server 2005->Configuraiton Tools->Server Configuration Manager.

In SQL Server Configuration Manager, in the console pane, expand SQL Server 2005 Network Configuration, expand Protocols for , and then double-click TCP/IP.

In the TCP/IP Properties dialog box, on the IP Addresses tab, several IP addresses appear, in the format IP1, IP2, up to IPAll. One of these are for the IP address of the loopback adapter, 127.0.0.1. Additional IP addresses appear for each IP Address on the computer. Right-click each address, and then click Properties to identify the IP address that you wish to configure.

If the TCP Dynamic Ports dialog box contains 0, indicating the Database Engine is listening on dynamic ports, delete the 0.

In the IPn Properties area box, in the TCP Port box, type the port number you wish this IP address to listen on, and then click OK.

In the console pane, click SQL Server 2005 Services.

In the details pane, right-click SQL Server () and then click restart, to stop and restart SQL Server.

Source:
http://msdn2.microsoft.com/en-us/library/ms177440.aspx


For Microsoft SQL Server 2000:

To assign a TCP/IP port number to the SQL Server Database Engine 2000:

Open Server Network Utility from Start->Programs->Microsoft SQL Server ->Server NetworkUtily.

In Server Network Utility, in the console pane, select TCP/IP and move it to Enabled protocols box. In Enabled Protocols box select TCP/IP and click Properties button. Now set port number to 1433 or other. Click ok button and restart the server.

Source:
net

Wednesday, February 21, 2007

Java: Byte Streams

Programs use byte streams to perform input and output of 8-bit bytes. All byte stream classes are descended from InputStream and OutputStream.

There are many byte stream classes. Ex: AudioInputStream, ByteArrayInputStream, FilterInputStream, ObjectInputStream, PipedInputStream, SequenceInputStream, StringBufferInputStream

Using file byte streams:

FileInputStream in = new FileInputStream("xanadu.txt");
FileOutputStream out = new FileOutputStream("outagain.txt");


FileInputStream: Constructor summary..
FileInputStream(File file)
Creates a FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system.
FileInputStream(FileDescriptor fdObj)
Creates a FileInputStream by using the file descriptor fdObj, which represents an existing connection to an actual file in the file system.
FileInputStream(String name)
Creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system.

FileInputStream: Methods summary..
int available()
Returns an estimate of the number of remaining bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.
void close()
Closes this file input stream and releases any system resources associated with the stream.
protected void finalize()
Ensures that the close method of this file input stream is called when there are no more references to it.
FileChannel getChannel()
Returns the unique FileChannel object associated with this file input stream.
FileDescriptor getFD()
Returns the FileDescriptor object that represents the connection to the actual file in the file system being used by this FileInputStream.
int read()
Reads a byte of data from this input stream.
int read(byte[] b)
Reads up to b.length bytes of data from this input stream into an array of bytes.
int read(byte[] b, int off, int len)
Reads up to len bytes of data from this input stream into an array of bytes.
long skip(long n)
Skips over and discards n bytes of data from the input stream.


FileOutputStream: Constructor summary..
FileOutputStream(File file)
Creates a file output stream to write to the file represented by the specified File object.
FileOutputStream(File file, boolean append)
Creates a file output stream to write to the file represented by the specified File object.
FileOutputStream(FileDescriptor fdObj)
Creates an output file stream to write to the specified file descriptor, which represents an existing connection to an actual file in the file system.
FileOutputStream(String name)
Creates an output file stream to write to the file with the specified name.
FileOutputStream(String name, boolean append)
Creates an output file stream to write to the file with the specified name.
FileOutputStream: Methods summary.. 
void close()
Closes this file output stream and releases any system resources associated with this stream.
protected void finalize()
Cleans up the connection to the file, and ensures that the close method of this file output stream is called when there are no more references to this stream.
FileChannel getChannel()
Returns the unique FileChannel object associated with this file output stream.
FileDescriptor getFD()
Returns the file descriptor associated with this stream.
void write(byte[] b)
Writes b.length bytes from the specified byte array to this file output stream.
void write(byte[] b, int off, int len)
Writes len bytes from the specified byte array starting at offset off to this file output stream.
void write(int b)
Writes the specified byte to this file output stream.

Source:
http://java.sun.com/docs/books/tutorial/essential/io/bytestreams.html

Ejb: Basic ejb-jar.xml



Java: Polymorphism in java

Ejb: Transaction Attributes and isolation levels

More clear about Transactions attributes:

The Enterprise JavaBeans model supports six different transaction rules:

TX_BEAN_MANAGED. The TX_BEAN_MANAGED setting indicates that the enterprise bean manually manages its own transaction control. EJB supports manual transaction demarcation using the Java Transaction API. This is very tricky and should not be attempted without a really good reason.

TX_NOT_SUPPORTED. The TX_NOT_SUPPORTED setting indicates that the enterprise bean cannot execute within the context of a transaction. If a client (i.e., whatever called the method-either a remote client or another enterprise bean) has a transaction when it calls the enterprise bean, the container suspends the transaction for the duration of the method call.

TX_SUPPORTS. The TX_SUPPORTS setting indicates that the enterprise bean can run with or without a transaction context. If a client has a transaction when it calls the enterprise bean, the method will join the client's transaction context. If the client does not have a transaction, the method will run without a transaction.

TX_REQUIRED. The TX_REQUIRED setting indicates that the enterprise bean must execute within the context of a transaction. If a client has a transaction when it calls the enterprise bean, the method will join the client's transaction context. If the client does not have a transaction, the container automatically starts a new transaction for the method.

TX_REQUIRES_NEW. The TX_REQUIRES_NEW setting indicates that the enterprise bean must execute within the context of a new transaction. The container always starts a new transaction for the method. If the client has a transaction when it calls the enterprise bean, the container suspends the client's transaction for the duration of the method call.

TX_MANDATORY. The TX_MANDATORY setting indicates that the enterprise bean must always execute within the context of the client's transaction. If the client does not have a transaction when it calls the enterprise bean, the container throws the TransactionRequired

Jsp: Output comment and Hidden Comment

OutputComment:
A comment that is sent to the client in the viewable page source.The JSP engine handles an output comment as uninterpreted HTML text, returning the comment in the HTML output sent to the client. You can see the comment by viewing the page source from your Web browser.

HiddenComment:
A comments that documents the JSP page but is not sent to the client. The JSP engine ignores a
hidden comment, and does not process any code within hidden comment tags. A hidden comment is not sent to the client, either in the displayed JSP page or the HTML page source. The hidden comment is useful when you want to hide or "comment out" part of your JSP page.

You can use any characters in the body of the comment except the closing --%> combination. If you need to use --%> in your comment, you can escape it by typing --%\>.

Difference between HashTable and HashMap

Basic difference between Array List and Vector in Java

Thursday, February 15, 2007

How to prevent the caching of visited pages

How to change the order of deployment in jboss

Jsp page and Jsp document

The JSP specification supports two types of JSP pages: regular JSP pages containing any type of text or markup, and JSP Documents, which are well-formed XML documents; i.e., documents with XHTML and JSP elements. To satisfy the well-formed-ness requirements, JSP directives and scripting elements in a JSP Document must be written with a different syntax than a regular JSP page:

more..