Monday, July 27, 2009

Windows Server Hacks: Remotely Enable Remote Desktop

Remote Desktop is a cool feature of Windows Server 2003 that lets you remotely log on to and work at a machine as if you were seated at the local console (in Windows 2000 Advanced Server, this feature was called Terminal Services in Remote Administration Mode). Remote Desktop can be a lifesaver for fixing problems on servers at remote sites, but what if you forgot to enable the feature before you shipped the server out to Kalamazoo? Enabling Remote Desktop is easy if the server is in front of you: just log on as an administrator, open System in Control Panel, select the Remote tab, and under Remote Desktop select the checkbox labeled "Allow users to connect remotely to this computer." Unfortunately, you can't use the System utility to enable Remote Desktop on a remote machine, though you can access some properties pages of System using Computer Management by first connecting the console to a remote computer, then right-clicking on the root node and selecting Properties. Unfortunately, as you can see in Figure 1 below, the Remote tab is not available when you access System properties this way on a remote machine (here named SRV220).



Figure 1. System properties for a remote machine does not have Remote tab.

Fortunately, there's a workaround. Sit down at your desk and log on to your Windows XP workstation using your administrator credentials and start Registry Editor by Start --> Run --> regedit --> OK. Then select the Connect Network Registry option under the File menu (Figure 2).



Figure 2. Connecting to the Registry on a remote machine.

This opens the Select Computer search box. Either browse Active Directory to locate the remote server, or type its name in the textbox (Figure 3).


Figure 3. Connecting to the Registry on a remote server named SRV220.

Click OK and a node will be displayed in Registry Editor for the remote machine (Figure 4).



Figure 4. HKLM and HKU hives on SRV220.

Now browse HKLM on SRV to find the following Registry key (Figure 5).

HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server


Figure 5. Registry key for Terminal Server on remote machine.

Under the Terminal Server key, you'll find a REG_DWORD value named fDenyTSConnection. Double-click on that value to open the Edit DWORD Value box and change the value data from 1 (Remote Desktop disabled) to 0 (Remote Desktop enabled), as in Figure 6 below.


Figure 6. Set fDenyTSConnections to 0 to enable Remote Desktop on SRV220.

The remote machine needs to be rebooted for the change to take effect, so open a command prompt and type the following command:

shutdown -m \\srv220 -r
After the remote machine reboots, Remote Desktop should be enabled on it. To test this from your workstation, open Start --> All Programs --> Accessories --> Communications --> Remote Desktop Connection, enter the name of the remote server in the Remote Desktop Connection logon box, supply your administrator password when prompted, and you're in.

Mitch Tulloch is the author of Windows 2000 Administration in a Nutshell, Windows Server 2003 in a Nutshell, and Windows Server Hacks.


--------------------------------------------------------------------------------

Return to WindowsDevCenter.com.




Have you had problems with Remote Desktop? Any solutions? Let us know.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 52 of 52.

Windows Server 2003 Admin Pasword disabled
2009-07-09 09:13:37 Le Censeur [Reply | View]


I disabled admin password on my home server and created another admin account. But the new account cannot enabled back my admin account. What should I do? How can I gat that admin account back without reinstalling.
Thanks,
Le Censeur
Remote Desktop and viewing programs
2008-07-16 13:37:30 ludovici [Reply | View]


I normally use remote desktop to administer a stack of servers, and I've noted with much frustration there are some applications, services and whatnot that I simply cannot see when I run them through remote desktop, and it seems arbitrary. I use NOD32 for example, on all my servers, yet there are some that I see the icon in the system tray and can open it up, and there are others where I can verify it's running through task manager but cannot see it in the systray or open it up. What's the secret here? Is there some special settings that will allow viewing of everything?

Thanks in advance....
Remote Desktop and viewing programs
2008-09-02 17:03:03 Grasfairy3 [Reply | View]


The issue is most likely that you are not RDPing into the "console" session (technically session 0). If you add use something like the /console switch(or /admin if you have the new version of RDP, I think it would be RDP version 6) you should then be able to see all of your icons. If you want the full command, I tend to use: mstsc /v:x.x.x.x /console (for new RDP it would be the same but again, replace the /console with /admin. The console session does not really technically exist anymore in Server 2008). This should allow you to now see all of your icons! (I had this same issue in the past :)~ )
terminal conncection for more than 3 users
2008-04-16 22:09:36 p_R_a_S_u [Reply | View]


Hi How I hav a win3k system with remote desktop enabled. But not ably to logon morethan 3 users at a time. Is there any solution? Kindly let me know.
terminal conncection for more than 3 users
2008-10-08 10:08:01 pashu [Reply | View]


i have to cerate terminal server with number of connection . can u help me about this topic
Re-establish a prior connection
2008-04-03 09:41:19 zcountezza [Reply | View]


Yesterday, I remotely logged into my Windows 2003 server. I mapped and opened a network drive, then set up and started some eclipse servers. This morning, I logged into this same server from my computer, but I couldn't get the same session. I log into a session where the network drive is disconnected and I can't see any of my command prompts for the running eclipse servers (I know these are still running because I can hit them from my browser). Any suggestions?
A tool that does this
2008-01-25 06:18:06 spastech [Reply | View]


There's a tool called VENM Console that has done this for years. There's info about it at http://www.vncscan.com/terminal_server/Enabling_Remote_Desktop.htm

tracking remote desktop users
2007-04-13 09:57:40 mrahe@datacomspecialists.com [Reply | View]


Is there a way to track remote desktop users? I'd like to see who logged in/out, when, and perhaps from what IP.
tracking remote desktop users
2007-04-24 10:43:27 g_socrates [Reply | View]


You can use tsadmin.exe which will provide the users that are logged in and whether they are are idle, active, or disconnected. 2003 servers do not populate in the list of servers on the network and need to be added manaully for whatever reason. This does not log historical information only active information.
HTH

cannot logon through Terminal Services
2007-03-19 09:28:26 kskate2 [Reply | View]


I just installed Terminal Services on a W2K3 member server. I am receiving the following error: To log on to this computer, you must be granted the Allow log on through Terminal Services right. By default, members of the Remote Desktop Users group have this right. If you are not a member of the Remote Desktop Users group or another group that has this right, or if the Remote Desktop User group does not have this right, you must be granted this right manually. I have granted a user access to logon on locally and be a member of the local remote desktop users group. Has anyone else has encountered this problem? Any assistance would be greatly appreciated.
Thanks in advance,
Kelli


cannot logon through Terminal Services
2008-04-29 07:21:25 Configss [Reply | View]


I was having the same problems and even after allowing permissions in the group policy it didn't work. What finally worked for me was found in the Terminal Services Configuration. There is a connections folder with an RDP-tcp connection in it. Add the permissions here and it should take care of the problem for you.
cannot logon through Terminal Services
2007-03-21 21:24:55 BaYaBasMan [Reply | View]


By default To be able to login to Terminal Service you need to be a member of "Remote Desktop Users" or the "Administrators" group. If you already are try to check the permissions in the terminal services settings. Open Tscc.msc and open the RDP properties under the connections folder. Add your account or group that you want to give access to RDP. Hope this Helps. puking ina mo...
cannot logon through Terminal Services
2008-02-21 05:09:09 Maganti [Reply | View]


even i tried the same by adding group into rdp properties, but no use. help me
Thanks!
2007-03-05 15:19:09 mgustavson [Reply | View]


This worked flawlessly - saved a long trip! Thank you!
Remote Desktop access denied
2007-02-15 07:34:55 Redgeck0 [Reply | View]


On a windows 2003 server, I've tried the remote registry hack and the fDenyTSConnection is already set to 0. I still get "You must be allowed log on through Terminal Services right." This server was built and set for RDC and the admin was placed in the RDC group. Everyone was removed from Deny log on to TS in the group policy.

Any other ideas?

Thanks

Linda
Remote Desktop access denied
2008-01-01 04:18:11 sri_sms [Reply | View]


On a windows 2003 server, I've tried the remote registry hack and the fDenyTSConnection is already set to 0. I still get "You must be allowed log on through Terminal Services right." This server was built and set for RDC and the admin was placed in the RDC group. Everyone was removed from Deny log on to TS in the group policy.



Remote Desktop access denied
2008-02-23 22:32:01 Caryb [Reply | View]


HELLO EVERYONE.. I HAVE THE ANSWER!!! After further review (and a lot of trial/error).. In Control panel/Windows Firewall: Exception tab: Enable Remote Desktop. In Advanced: Enable Local area connection, then select 'Settings'. Enable Remote Desktop, and also, enable HTTP. (Http will allow you to web interface a remote desktop, but must be enabled elsewhere if you wish to use this feature.. neat!) Drop me an e-mail if you want to use web remote desktop. WORKS GREAT!! cbudach@yahoo.com
Remote Desktop access denied
2009-06-25 11:33:46 cogtruth [Reply | View]


I would like to use this feature. Where do I enable it?
Remote Desktop - Remote user Links??
2008-09-30 14:14:37 CarolCampbell [Reply | View]


Subject probably well out of date but only just found this site and need HELP!! I am a remote desktop user which links to a server in the North of England. No problems until recently. Now it allows the connection when I enter my user name and password, BUT then the links will not work - a 'hand' overs over the icon, but the normal mouse click will not activate it. It has been tested by the host site and works fine, so problem must be with settings on my computer. Can anyone offer not too technical walk through of settings I should check/change? (Have managed to lose system restore points, so can't do anything involving that!) THANK YOU....
Remote Desktop access denied
2008-02-23 22:27:28 Caryb [Reply | View]


HELLO EVERYONE.. I HAVE THE ANSWER!!!
Remote Desktop access denied
2008-02-23 22:27:27 Caryb [Reply | View]


HELLO EVERYONE.. I HAVE THE ANSWER!!!
Remote Desktop access denied
2007-02-28 13:29:39 Alexjaya [Reply | View]


Do you have permission to logon locally. Try adding yourself to the local admini group and see if it works. if it works then you do not have sufficient privileges. you should be granted permission to logon locally in the local policy and also be granted permission to RDp-TCP in Terminal Services Configuration.

thanks.
key problem with Remote Desktop Connection
2006-12-05 12:02:41 LifeOfReilly [Reply | View]


After successfully making a remote desktop connection (using XP) I sometimes find that the Shift and Ctrl keys no longer work. If I goof around a bit with the Ctrl key on another screen the use of the Shift and Ctrl keys returns. Then after a while they stop working again. This happens quite often and really becomes a nuisance. Any thoughts?
Thanks
key problem with Remote Desktop Connection
2007-03-14 09:27:48 ernestdcook [Reply | View]


Thank you for your post. I am experiancing a simular issue but I am using Vista to connect to to SBS network over remote desktop. ACK, I can't get anything done this way since even an e-mail needs the shift key to get the @...

Anybody that knows of a fix for this, please help!
easy fix
2006-11-26 14:34:34 everynameistaken888 [Reply | View]


this tool does it for you and its free. http://www.arconi.com/RDPenable.html
Remote computer ending connection
2006-11-07 00:49:16 JonnyBoyo [Reply | View]


I have a Windows XP Pro laptop and desktop wirelessly networked. I can remote desktop from the desktop to the laptop but not the other way around. In fact on the desktop the option isn't even available for enabling. I tried changing the fDenyTSConnection terminal server key from 1 to 0 and now I don't get the unable to connect error but "The remote computer has ended the connection" comes up immediately. Please can anyone help? Thank you
windows server no desktop
2006-08-02 03:51:16 zack786 [Reply | View]


great info about remote desktop.appreciate any help with my problem too. got windows server 2003 and after running a clean up utility the server doesnt boot to a desktop- blank screen, but users can still access the files.also says at least one service failed to start. any ideas how i can try to fix remotely?
thanks
Try this program - its free and does it all for you
2006-06-02 04:13:01 empois [Reply | View]


Program to remotely enable or disable remote desktop on a remote computer running Windows XP.

http://www.lancs.ac.uk/staff/morganpj/Remote_Desktop_Enable.htm
Try this program - its free and does it all for you
2007-04-27 12:19:26 captain817 [Reply | View]


I'd like to try the remote desktop enable program
Use PSTools..
2006-05-25 10:02:09 paul.laudeman [Reply | View]


If you are using PSTools from SysInternals.com you can also execute the following command:

psexec \\computername/ipip reg add "hklm\system\currentcontrolset\control\terminal server" /f /v fDenyTSConnections /t REG_DWORD /d 0
RDP - Get rid of lock screen...?
2006-05-16 09:28:21 wolfsden3 [Reply | View]


Anyone here know how to not lock the screen on a RDP session...? I'd like to get into the USERS desktop!!! More like a VNC session where they can interact with me on the remote session. Currently, if you RDP to their desktop, it logs them off. Any ideas...?

Thanks,



Raf Daddy
RDP - Get rid of lock screen...?
2006-08-18 09:37:49 mdirish [Reply | View]


You're best bet is to use Remote Assistance from the Tools menu on the Help & Support area in XP. You will have to allow remote assistance on the user's machine and you will also have to have the proper permissions to use it but it works well. Remote Assistance is better for several reasons but most importantly you won't need to know the user's password to gain access. They will have to grant you access from their side.

But, if you don't want to use remote assistance, you can gain access to the user's session of the remote client by using the /console switch in Remote Desktop. The best way to do that is to run a command from the cli.
Example.

C:\mstsc.exe /V:COMPUTERNAME /CONSOLE
Custom Error Messages in RDP
2006-04-24 01:54:16 AlanP [Reply | View]


I'm looking for some advice on creating custom error messages to return to RDP clients.

Remote users accessing Windows XP virtual desktops (running inside VMware virtual machines).

If there is a problem with the connection - for example no empty virtual machines available to host their session on - we would like to return a more helpful error message rather than the "timeout" error that gets returned by default.

Can anyone help, or suggest other places to look for help?


Thanks
Software
2006-04-11 07:35:13 SiliconHacker [Reply | View]


Are there any softwares that decode programs?
easier way
2005-12-07 15:37:52 cking2 [Reply | View]


wmic /node:"Computer Name (FQDN)" RDTOGGLE WHERE ServerName="Computer Name" CALL SetAllowTSConnections 1

This was added in W2k3 SP1 and works against XP machines but has to be run from a W2k3 SP1 machine. I have not figured out how to add this ability to my XP workstation.
easier way
2006-05-25 18:14:45 dwarfsoft [Reply | View]


For WMIC calls from Windows XP you need the /locale: switch. Windows 2003 defaults /locale to whatever you have installed with (default ms_409).

I haven't tried toggling this from Windows XP though, and I know there are some commands that will not work from a Windows XP machine, though these have so far been due to restrictions of login details. Using /user: and /password: does not necessarily grant enough permission to shutdown a machine while logged on with low privelages.
easier way
2006-04-24 11:46:11 gwojan [Reply | View]


From Windows XP SP2 try:

/node:"HOSTNAME" path win32_terminalservicesetting where servername="HOSTNAME" call SetAllowTSConnections 1

--Greg
BSOD when I connect to machine
2005-10-07 09:38:50 Bond007s [Reply | View]


I recieved a Blue Screen of Death (BSOD) every time I logged in as the Domain Administrator on that machine. The Remotely connected machine (machine using remote Desktop to connect) appears to connect then appears as though the remoted machine was pulled from the Network as the BSOD hits the screen of the remoted machine. I have only modified the one regestry Setting although the BSOD says that there is a Regestry Invalid Error. Can Anyone help me with this problem. I work as a technician for a school district and find Remote Desktop very useful...
Remotely Enable Remote Desktop
2005-04-21 08:42:42 SatKDOT [Reply | View]


Here is a batch file that does the same thing.
Also works for XP. Save the following as: remoteon.cmd or, whatever you like.

@echo off
setlocal
if {%1}=={} goto syntax
:loop
if {%1}=={} goto finish
set remote="\\%1\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server"
shift
reg.exe ADD %remote% /v fDenyTSConnections /t REG_DWORD /d 0 /f>nul 2>&1
if NOT %ERRORLEVEL% EQU 0 @echo %remote% NOT found.
goto loop
:syntax
@echo Syntax: RemoteDesktop Computer1 [Computer2 .... Computern]
goto loop
:finish
endlocal

Go to a command prompt and type remoteon computername
Remotely Enable Remote Desktop
2006-03-08 15:47:02 thomas9406 [Reply | View]


This worked great! I used PS Tools to execute the batch file remotely.
Remotely Enable Remote Desktop
2006-03-29 05:51:03 w1nstrel [Reply | View]


Yeah, PSEXEC.EXE is great... In this case, you shouldn't need it, since REG.EXE can write to a remote registry on it's own. The batch script that SatKDOT wrote includes the ability to do it like this: remoteon.cmd
I was able to do this on one machine, but now I get this error.
2005-02-10 16:44:23 zxfiles [Reply | View]


"Make sure that this computer is on the network, has remote administration enabled, and that both computers are running the remote registry service."

Why would this stop? All machines are Windows XP Pro running on a Windows Server 2003 domain controller. The computers are on the network. As far as the other two settings go, how would I verify this? Would it matter than some of these machines used to run Windows 2000 and were upgraded at one time?

Thanks.
I was able to do this on one machine, but now I get this error.
2005-02-10 16:53:34 zxfiles [Reply | View]


Update:

I just verified on one machine that the remote registry service is started. But it would not let me connect. Same error message. However, I can already remote desktop into the machine. I was just testing this feature. Any ideas? Something to do with service pack 2's firewall maybe?
I was able to do this on one machine, but now I get this error.
2005-02-10 16:56:36 zxfiles [Reply | View]


Well crap! :) I should comment more often as it helps me fix the problem. Hehe. Apparently File and Print Sharing has to be turned on in the Exceptions for the SP2 firewall. It should have already been turned on I guess for the network, but anyway. I just did it on this test machine and the remote registry connected fine.

I hope this helps others.
I was able to do this on one machine, but now I get this error.
2006-02-02 04:52:49 mbusor [Reply | View]


i had the same problem the workaround
-make the user(e.g XP machine) as part of administrators on the remote machine
it worked for me hope it also does for you.
good luck
Why not make it easier by doing this!!!
2005-01-27 06:22:16 matty_g [Reply | View]


Use the above info to create a custom adm file, that way it can easily controlled by group policy while doing that though you might as well also include the regkey hack that will allow you to remotely control a machine that has offline files enabled!!!

Matt
Why not make it easier by doing this!!!
2006-03-29 05:46:15 w1nstrel [Reply | View]


You shouldn't need to make a custom ADM... the stuff to enable RDP per-machine is already in the default ADM templates. ;)
Why not make it easier by doing this!!!
2006-01-25 14:41:46 Phoenix_7 [Reply | View]


Matty_g or Anyone else know where can I find this hack?

"regkey hack that will allow you to remotely control a machine that has offline files enabled!!!"

This problem is beginning to pop up on my network more and more everyday.
Re: Remotely Enable Remote Desktop
2004-08-17 04:37:41 EBO [Reply | View]


I get an error : Cannot Open HKEY_LOCAL_MACHINE: errro while opening key

How can i resolve dat?
Re: Remotely Enable Remote Desktop
2006-11-07 21:11:48 serverguy63 [Reply | View]


Just try getting to it by using the run command and typing "\\systemname\c$" if you cant access it then it's permissions. There's a utility here "http://www.arconi.com/RDPenable.html" that might help you.
Re: Remotely Enable Remote Desktop
2005-03-17 09:26:19 navyjax2 [Reply | View]


This is likely a permissions issue on that key. You need to have admin privileges on the computer you are accessing. As long as you do, you can go and right-click on HKEY_LOCAL_MACHINE, hit Permissions and add the right permissions to your user name (Full Control should do it), go through the Advanced button, go to the Owner tab, take ownership of it, go through the Effective Permissions tab, hit Select and then type in your user name, it should show you your permissions. On the Permissions tab, select your user name and Edit and you can select all the permissions there. You can then hit Apply and OK, then mark the Replace permission entries on all child objects with entries shown here that apply to child objects checkbox and uncheck the Inherit from parent...blah blah blah, so that it will replace those permissions with what you are selecting and not draw them from anything higher. All of that is in no particular order, I just do it until I get it to accept it all. If you can't get it to give you these permissions with all of this, you may not have admin rights or the registry could have some permission corruption.

Sunday, July 26, 2009

HTML Tags / Codes / Web Page Design

For detailsvisit this site:
http://www।web-source.net/html_codes_chart.htm

Saturday, June 13, 2009

JDBC Architecture

JDBC is an API specification developed by Sun Microsystems that defines a uniform interface for accessing various relational databases. JDBC is a core part of the Java platform and is included in the standard JDK distribution.

The primary function of the JDBC API is to provide a means for the developer to issue SQL statements and process the results in a consistent, database-independent manner. JDBC provides rich, object-oriented access to databases by defining classes and interfaces that represent objects such as:

1. Database connections
2. SQL statements
3. Result Set
4. Database metadata
5. Prepared statements
6. Binary Large Objects (BLOBs)
7. Character Large Objects (CLOBs)
8. Callable statements
9. Database drivers
10. Driver manager

The JDBC API uses a Driver Manager and database-specific drivers to provide transparent connectivity to heterogeneous databases. The JDBC driver manager ensures that the correct driver is used to access each data source. The Driver Manager is capable of supporting multiple concurrent drivers connected to multiple heterogeneous databases. The location of the driver manager with respect to the JDBC drivers and the servlet is shown in Figure 1.

Layers of the JDBC Architecture



A JDBC driver translates standard JDBC calls into a network or database protocol or into a database library API call that facilitates communication with the database. This translation layer provides JDBC applications with database independence. If the back-end database changes, only the JDBC driver need be replaced with few code modifications required. There are four distinct types of JDBC drivers.

Type 1 JDBC-ODBC Bridge. Type 1 drivers act as a "bridge" between JDBC and another database connectivity mechanism such as ODBC. The JDBC- ODBC bridge provides JDBC access using most standard ODBC drivers. This driver is included in the Java 2 SDK within the sun.jdbc.odbc package. In this driver the java statements are converted to a jdbc statements. JDBC statements calls the ODBC by using the JDBC-ODBC Bridge. And finally the query is executed by the database. This driver has serious limitation for many applications. (See Figure 2.)

Type 1 JDBC Architecture



Type 2 Java to Native API. Type 2 drivers use the Java Native Interface (JNI) to make calls to a local database library API. This driver converts the JDBC calls into a database specific call for databases such as SQL, ORACLE etc. This driver communicates directly with the database server. It requires some native code to connect to the database. Type 2 drivers are usually faster than Type 1 drivers. Like Type 1 drivers, Type 2 drivers require native database client libraries to be installed and configured on the client machine. (See Figure 3.)

Type 2 JDBC Architecture



Type 3 Java to Network Protocol Or All- Java Driver. Type 3 drivers are pure Java drivers that use a proprietary network protocol to communicate with JDBC middleware on the server. The middleware then translates the network protocol to database-specific function calls. Type 3 drivers are the most flexible JDBC solution because they do not require native database libraries on the client and can connect to many different databases on the back end. Type 3 drivers can be deployed over the Internet without client installation. (See Figure 4.)
Java-------> JDBC statements------> SQL statements ------> databases.

Type 3 JDBC Architecture



Type 4 Java to Database Protocol. Type 4 drivers are pure Java drivers that implement a proprietary database protocol (like Oracle's SQL*Net) to communicate directly with the database. Like Type 3 drivers, they do not require native database libraries and can be deployed over the Internet without client installation. One drawback to Type 4 drivers is that they are database specific. Unlike Type 3 drivers, if your back-end database changes, you may save to purchase and deploy a new Type 4 driver (some Type 4 drivers are available free of charge from the database manufacturer). However, because Type drivers communicate directly with the database engine rather than through middleware or a native library, they are usually the fastest JDBC drivers available. This driver directly converts the java statements to SQL statements.

(See Figure 5.)

Type 4 JDBC Architecture



So, you may be asking yourself, "Which is the right type of driver for your application?" Well, that depends on the requirements of your particular project. If you do not have the opportunity or inclination to install and configure software on each client, you can rule out Type 1 and Type 2 drivers.

However, if the cost of Type 3 or Type 4 drivers is prohibitive, Type 1 and type 2 drivers may become more attractive because they are usually available free of charge. Price aside, the debate will often boil down to whether to use Type 3 or Type 4 driver for a particular application. In this case, you may need to weigh the benefits of flexibility and interoperability against performance. Type 3 drivers offer your application the ability to transparently access different types of databases, while Type 4 drivers usually exhibit better performance and, like Type 1 and Type 2 drivers, may be available free if charge from the database manufacturer.

JDBC Driver and Its Types

JDBC Driver Manager

The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver. DriverManager has traditionally been the backbone of the JDBC architecture. It is quite small and simple.

This is a very important class. Its main purpose is to provide a means of managing the different types of JDBC database driver. On running an application, it is the DriverManager's responsibility to load all the drivers found in the system property jdbc. drivers. For example, this is where the driver for the Oracle database may be defined. This is not to say that a new driver cannot be explicitly stated in a program at runtime which is not included in jdbc.drivers. When opening a connection to a database it is the DriverManager' s role to choose the most appropriate driver from the previously loaded drivers.

The JDBC API defines the Java interfaces and classes that programmers use to connect to databases and send queries. A JDBC driver implements these interfaces and classes for a particular DBMS vendor.

A Java program that uses the JDBC API loads the specified driver for a particular DBMS before it actually connects to a database. The JDBC DriverManager class then sends all JDBC API calls to the loaded driver.

JDBC Driver

This topic defines the Java(TM) Database Connectivity (JDBC) driver types. Driver types are used to categorize the technology used to connect to the database. A JDBC driver vendor uses these types to describe how their product operates. Some JDBC driver types are better suited for some applications than others.

Types of JDBC drivers

This topic defines the Java(TM) Database Connectivity (JDBC) driver types. Driver types are used to categorize the technology used to connect to the database. A JDBC driver vendor uses these types to describe how their product operates. Some JDBC driver types are better suited for some applications than others.

There are four types of JDBC drivers known as:

* JDBC-ODBC bridge plus ODBC driver, also called Type 1.
* Native-API, partly Java driver, also called Type 2.
* JDBC-Net, pure Java driver, also called Type 3.
* Native-protocol, pure Java driver, also called Type 4.

Type 1 Driver- the JDBC-ODBC bridge

The JDBC type 1 driver, also known as the JDBC-ODBC bridge is a database driver implementation that employs the ODBC driver to connect to the database. The driver converts JDBC method calls into ODBC function calls. The bridge is usually used when there is no pure-Java driver available for a particular database.

The driver is implemented in the sun.jdbc.odbc.JdbcOdbcDriver class and comes with the Java 2 SDK, Standard Edition. The driver is platform-dependent as it makes use of ODBC which in turn depends on native libraries of the operating system. Also, using this driver has got other dependencies such as ODBC must be installed on the computer having the driver and the database which is being connected to must support an ODBC driver. Hence the use of this driver is discouraged if the alternative of a pure-Java driver is available.

Type 1 is the simplest of all but platform specific i.e only to Microsoft platform.

A JDBC-ODBC bridge provides JDBC API access via one or more ODBC drivers. Note that some ODBC native code and in many cases native database client code must be loaded on each client machine that uses this type of driver. Hence, this kind of driver is generally most appropriate when automatic installation and downloading of a Java technology application is not important. For information on the JDBC-ODBC bridge driver provided by Sun, see JDBC-ODBC Bridge Driver.

Type 1 drivers are "bridge" drivers. They use another technology such as Open Database Connectivity (ODBC) to communicate with a database. This is an advantage because ODBC drivers exist for many Relational Database Management System (RDBMS) platforms. The Java Native Interface (JNI) is used to call ODBC functions from the JDBC driver.

A Type 1 driver needs to have the bridge driver installed and configured before JDBC can be used with it. This can be a serious drawback for a production application. Type 1 drivers cannot be used in an applet since applets cannot load native code.

Functions:

1. Translates query obtained by JDBC into corresponding ODBC query, which is then handled by the ODBC driver.
2. Sun provides a JDBC-ODBC Bridge driver. sun.jdbc.odbc.JdbcOdbcDriver. This driver is native code and not Java, and is closed
source.
3. Client -> JDBC Driver -> ODBC Driver -> Database
4. There is some overhead associated with the translation work to go from JDBC to ODBC.

Advantages:

Almost any database for which ODBC driver is installed, can be accessed.

Disadvantages:

1. Performance overhead since the calls have to go through the JDBC overhead bridge to the ODBC driver, then to the native database connectivity interface.
2. The ODBC driver needs to be installed on the client machine.
3. Considering the client-side software needed, this might not be suitable for applets.

Type 2 Driver - the Native-API Driver

The JDBC type 2 driver, also known as the Native-API driver is a database driver implementation that uses the client-side libraries of the database. The driver converts JDBC method calls into native calls of the database API.

The type 2 driver is not written entirely in Java as it interfaces with non-Java code that makes the final database calls.
The driver is compiled for use with the particular operating system. For platform interoperability, the Type 4 driver, being
a full-Java implementation, is preferred over this driver.

A native-API partly Java technology-enabled driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, DB2, or other DBMS. Note that, like the bridge driver, this style of driver requires that some binary code be loaded on each client machine.

However the type 2 driver provides more functionality and performance than the type 1 driver as it does not have the overhead of the additional ODBC function calls.

Type 2 drivers use a native API to communicate with a database system. Java native methods are used to invoke the API functions that perform database operations. Type 2 drivers are generally faster than Type 1 drivers.

Type 2 drivers need native binary code installed and configured to work. A Type 2 driver also uses the JNI. You cannot use a Type 2 driver in an applet since applets cannot load native code. A Type 2 JDBC driver may require some Database Management System (DBMS) networking software to be installed.

The Developer Kit for Java JDBC driver is a Type 2 JDBC driver.

Functions:

1. This type of driver converts JDBC calls into calls to the client API for that database.
2. Client -> JDBC Driver -> Vendor Client DB Library -> Database

Advantage

Better performance than Type 1 since no jdbc to odbc translation is needed.

Disadvantages

1. The vendor client library needs to be installed on the client machine.
2. Cannot be used in internet due the client side software needed.
3. Not all databases give the client side library.

Type 3 driver - the Network-Protocol Driver

The JDBC type 3 driver, also known as the network-protocol driver is a database driver implementation which makes use of a middle-tier between the calling program and the database. The middle-tier (application server) converts JDBC calls directly or indirectly into the vendor-specific database protocol.

This differs from the type 4 driver in that the protocol conversion logic resides not at the client, but in the middle-tier. However, like type 4 drivers, the type 3 driver is written entirely in Java.

The same driver can be used for multiple databases. It depends on the number of databases the middleware has been configured to support. The type 3 driver is platform-independent as the platform-related differences are taken care by the middleware. Also, making use of the middleware provides additional advantages of security and firewall access.

A net-protocol fully Java technology-enabled driver translates JDBC API calls into a DBMS-independent net protocol which is then translated to a DBMS protocol by a server. This net server middleware is able to connect all of its Java technology-based clients to many different databases. The specific protocol used depends on the vendor. In general, this is the most flexible JDBC API alternative. It is likely that all vendors of this solution will provide products suitable for Intranet use. In order for these products to also support Internet access they must handle the additional requirements for security, access through firewalls, etc., that the Web imposes. Several vendors are adding JDBC technology-based drivers to their existing database middleware products.

These drivers use a networking protocol and middleware to communicate with a server. The server then translates the protocol to DBMS function calls specific to DBMS.

Type 3 JDBC drivers are the most flexible JDBC solution because they do not require any native binary code on the client. A Type 3 driver does not need any client installation.

Functions:

1. Follows a three tier communication approach.
2. Can interface to multiple databases - Not vendor specific.
3. The JDBC Client driver written in java, communicates with a middleware-net-server using a database independent protocol, and then this net server translates this request into database commands for that database.
4. Thus the client driver to middleware communication is database independent.
5. Client -> JDBC Driver -> Middleware-Net Server -> Any Database

Advantages

1. Since the communication between client and the middleware server is database independent, there is no need for the vendor db library on the client machine. Also the client to middleware need'nt be changed for a new database.
2. The Middleware Server (Can be a full fledged J2EE Application server) can provide typical middleware services like caching (connections, query results, and so on), load balancing, logging, auditing etc..
3. eg. for the above include jdbc driver features in Weblogic.
4. Can be used in internet since there is no client side software needed.
5. At client side a single driver can handle any database.(It works provided the middlware supports that database!!)

Disadvantages

1. Requires database-specific coding to be done in the middle tier.
2. An extra layer added may result in a time-bottleneck. But typically this is overcome by providing efficient middleware
services described above.

Type 4 - the Native-Protocol Driver

The JDBC type 4 driver, also known as the native-protocol driver is a database driver implementation that converts JDBC calls directly into the vendor-specific database protocol.

The type 4 driver is written completely in Java and is hence platform independent. It is installed inside the Java Virtual Machine of the client. It provides better performance over the type 1 and 2 drivers as it does not have the overhead of conversion of calls into ODBC or database API calls. Unlike the type 1 and 2 drivers, it does not need associated software to work.

A native-protocol fully Java technology-enabled driver converts JDBC technology calls into the network protocol used by DBMSs directly. This allows a direct call from the client machine to the DBMS server and is a practical solution for Intranet access. Since many of these protocols are proprietary the database vendors themselves will be the primary source for this style of driver. Several database vendors have these in progress.

As the database protocol is vendor-specific, separate drivers, usually vendor-supplied, need to be used to connect to the database.

A Type 4 driver uses Java to implement a DBMS vendor networking protocol. Since the protocols are usually proprietary, DBMS vendors are generally the only companies providing a Type 4 JDBC driver.

Type 4 drivers are all Java drivers. This means that there is no client installation or configuration. However, a Type 4 driver may not be suitable for some applications if the underlying protocol does not handle issues such as security and network connectivity well.

The IBM Toolbox for Java JDBC driver is a Type 4 JDBC driver, indicating that the API is a pure Java networking protocol driver.

Functions

1. Type 4 drivers are entirely written in Java that communicate directly with a vendor's database through socket connections. No translation or middleware layers, are required, improving performance.
2. The driver converts JDBC calls into the vendor-specific database protocol so that client applications can communicate directly with the database server.
3. Completely implemented in Java to achieve platform independence.
4. e.g include the widely used Oracle thin driver - oracle.jdbc.driver. OracleDriver which connect to jdbc:oracle:thin URL format.
5. Client Machine -> Native protocol JDBC Driver -> Database server

Advantages

These drivers don't translate the requests into db request to ODBC or pass it to client api for the db, nor do they need a middleware layer for request indirection. Thus the performance is considerably improved.

Disadvantage

At client side, a separate driver is needed for each database.

Friday, April 24, 2009

Print web page as PDF in VB.NET

I use ABCpdf .NET to print web page as pdf:

[]. reference ABCpdf.dll
[].Render web page in pdf in landscape or portrait format
[].Write pdf to browser or save to disk
[].Save HTML as pdf or save the whole web page as pdf by given URL


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="PrintToPDF._Default" %>





































Imports WebSupergoo.ABCpdf6

Imports System.Text

Imports System.IO


Partial Public Class _Default

Inherits System.Web.UI.Page


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


End Sub


Private Function GenerateQuoteInHTML() As String


Dim sb As StringBuilder = New StringBuilder

Dim sw As StringWriter = New StringWriter(sb)

Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)


Dim litTop As New Literal

Dim litTopText As New StringBuilder()

'the width on div makes the table readable in landscape format

litTopText.AppendLine("
Title

")

litTop.Text = litTopText.ToString()


Dim litBottom As New Literal

Dim litBottomText As New StringBuilder()

litBottomText.AppendFormat("
")

litBottom.Text = litBottomText.ToString()


litTop.RenderControl(hw)

litBottom.RenderControl(hw)

Return sb.ToString


End Function


Private Sub GeneratePDF(ByVal source As String, ByVal exportType As ExportType, ByVal sourceType As SourceType)


'set properties

Dim theDoc As New Doc

theDoc.HtmlOptions.PageCacheEnabled = False

theDoc.HtmlOptions.BrowserWidth = 0

theDoc.HtmlOptions.ImageQuality = 101

theDoc.MediaBox.Width = 1000

theDoc.Rect.Width = 1000


Dim theID As Integer

If sourceType = PrintToPDF.SourceType.HTML Then

'Renders a web page specified as HTML.

theID = theDoc.AddImageHtml(source)

ElseIf sourceType = PrintToPDF.SourceType.URL Then

'Renders a web page specified by URL.

theID = theDoc.AddImageUrl(source)

End If


'paging

'http://www.websupergoo.com/helppdf5/default.html?page=source%2F4-examples%2F08-landscape.htm

Do While True

theDoc.FrameRect()

If (theDoc.Chainable(theID) = False) Then

Exit Do

End If


theDoc.Page = theDoc.AddPage()

theID = theDoc.AddImageToChain(theID)

Loop

theDoc.HtmlOptions.LinkPages()

For x As Integer = 1 To theDoc.PageCount

theDoc.PageNumber = x

theDoc.Flatten()

Next


If exportType = PrintToPDF.ExportType.Browser Then

'write to browser

Dim theData As Byte() = theDoc.GetData()

Response.Expires = -1000

Response.ContentType = "application/pdf"

Response.AddHeader("content-length", theData.Length.ToString())

Dim timestamp As String = String.Format("{0}_{1}_{2}_{3}_{4}_{5}", Date.Now.Year.ToString, Date.Now.Month.ToString, Date.Now.Day.ToString, Date.Now.Hour.ToString, Date.Now.Minute.ToString, Date.Now.Second.ToString)

Response.AddHeader("content-disposition", "attachment; filename=MyPDF" + timestamp + ".PDF")

Response.BinaryWrite(theData)

theDoc.Clear()

ElseIf exportType = PrintToPDF.ExportType.Disk Then

'write to disk

Dim file As String = Path.Combine(Server.MapPath("CSVUploaded"), "test.pdf")

theDoc.Save(file)

End If


End Sub


Private Sub btnWriteToBrowserByHTML_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnWriteToBrowserByHTML.Click

Dim strHTML As String = GenerateQuoteInHTML()

GeneratePDF(strHTML, ExportType.Browser, SourceType.HTML)

End Sub


Private Sub btnWriteToBrowserByURL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnWriteToBrowserByURL.Click

GeneratePDF("http://www.google.com.au", ExportType.Browser, SourceType.URL)

End Sub


Private Sub btnWriteToDiskByHTML_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnWriteToDiskByHTML.Click

Dim strHTML As String = GenerateQuoteInHTML()

GeneratePDF(strHTML, ExportType.Disk, SourceType.HTML)

End Sub


Private Sub btnWriteToDiskByURL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnWriteToDiskByURL.Click

GeneratePDF("http://www.google.com.au", ExportType.Disk, SourceType.URL)

End Sub

End Class


Enum SourceType


URL

HTML


End Enum


Enum ExportType


Browser

Disk


End Enum

Reference:

ABCpdf PDF Component for ASP & VB

ASP.NET 2.0 Caching Substitution Control

Up to now ASP.NET provided three kinds of caching1. output-caching to cache a whole page2. fragment caching to cache a part of a page 3. Data cachingThe last post we talked about output caching. In this post, we will talk about one of the application on fragment caching: the Substitution Control.
.cf { font-family: Courier New; font-size: 9pt; color: black; background: white; }.cl { margin: 0px; }.cb1 { color: #a31515; }.cb2 { color: blue; }
<%@ Page Language="VB" %>
<%@ OutputCache Duration="60" VaryByParam="none" %>



Post Cache Substitution




This page uses post cache substitution to insert a dynamic value into a cached page.



Time:
<%= DateTime.Now.ToString() %>



Real Time:






Cached regions execute only once and are replayed from the cache until the cache expires. Dynamic regions (Substitution control places) execute each time the page is requested.

AdRotator Control in ASP.NET 2.0

The AdRotator is a special control in ASP.NET that is used to display flashing banner ads. The control is capable of displaying ads randomly or sequentially as set by the user. Each time the page is refreshed or reloaded a new ad can be displayed to the user. Also, we can assign priorities in such a way that certain ads are displayed frequently than others. The class hierarchy for this control is as follows:Object Control WebControl AdRotator
Notable properties of the AdRotator control are as follows:AdvertisementFile KeywordFilter Target
AdvertisementFile
The AdvertisementFile property specifies the path to an Advertisement File. The Advertisement file is a well-formed XML document that contains information for the image that needs to be displayed and the page to which the user should be redirected when he clicks the ad. The syntax for the Advertisement file is as follows:
xml version="1.0" encoding="utf-8" ?>URL of the image to be displayedURL of the page to which the user should be takenText to be displyed as tooltip<Keyword
>Keyword used to filterWeight of the ad
The different elements of the Advertisement File:
ImageUrl: Specifies the image URL that presents the image for the advertisement NavigateUrl: Specifies the URL of the page to which the user should be taken to when he clicks on the image AlternateText: An optional parameter that specifies the text when the user moves his mouse pointer over the image Keyword: Optional parameter that specifies the keyword (category) like books, programming, etc Impressions: Optional parameter that provides a number that indicates the weight of the ad in the order of rotation with respect to other ads in the file
KeywordFilter
The KeywordFilter property specifies a keyword to filter for specific types of advertisements in the XML advertisement file. Each advertisement in the XML advertisement file can be assigned a category keyword. The KeywordFilter property filters the advertisements for the specified keyword. Only advertisements containing the keyword will be selected for the AdRotator control and it is not possible to specify more than one keyword in the KeywordFilter property, nor it is possible to declare multiple keywords in the advertisement file.
Target
The Target property specifies the name of the browser window or frame that displays the contents of the Web page linked to when the AdRotator control is clicked. This property can also take the following HTML frame-related keywords.
_blank: displays the linked content in a new window without frames_parent: displays the linked content in the parent window of the window that contains the link_self: displays the linked content in the same window_top: displays the linked content in the topmost window

Monday, April 20, 2009

Convert DateTime Problem in ASP.NET With C#

DateTime.Parse
DateTime.ToString


System.Globalization.CultureInfo american = new System.Globalization.CultureInfo("en-US");
System.Globalization.CultureInfo german = new System.Globalization.CultureInfo("de-DE");
System.Globalization.CultureInfo french = new System.Globalization.CultureInfo("fr-FR");
System.Globalization.CultureInfo mexican = new System.Globalization.CultureInfo("es-MX");

string americanOutput = DateTime.Now.ToString(american);
string germanOutput = DateTime.Now.ToString(german);
string frenchOutput = DateTime.Now.ToString(french);
string mexicanOutput = DateTime.Now.ToString(mexican);

DateTime americanDate = DateTime.Parse(americanOutput, american);
DateTime germanDate = DateTime.Parse(germanOutput, german);
DateTime frenchDate = DateTime.Parse(frenchOutput, french);
DateTime mexicanDate = DateTime.Parse(mexicanOutput, mexican);


output:

americanOutput: 11/1/2006 11:49:00 PM
germanOutput: 01.11.2006 23:49:00
frenchOutput: 01/11/2006 23:49:00
mexicanOutput: 01/11/2006 11:49:00 p.m.

americanDate: november 1 2006
germanDate: november 1 2006
frenchDate: november 1 2006
mexicanDate: november 1 2006



so (like I said the first time, and as) you see when you specify the correct culture info, your "to string" and "parse" will do the right thing.

not using it implicitly uses whatever the system is configured for (or set to in your user settings).

Sunday, April 12, 2009

Exception Handling

Introduction
Like in other .NET-applications, exception-handling is also available in ASP.NET-applications. There are a few extensions and special features for exception-handling in ASP.NET that will be explained in this article: Predefined error-handlers, custom error-pages and IHttpModules.
Normal exception-handling
Of course your can use the known try/catch/finally-cascade of exception handling in your code:
try
{
File.OpenRead( path );
}
catch( System.IO.FileNotFoundException ex )
{
// handle error
}
finally
{
// cleanup
}
But in ASP.NET-applications you have got some extended kinds of error-handling-techniques at hand:
Error handlers
You can use predined error-handlers in your aspx-Page or in Global.asax-file. Here you can catch errors that occur in special scopes of your web-application. To get the Exception that occurred, you can use the method GetLastError() of the Server-property.
// Define it in your aspx-page
private void Page_Error(object sender, System.EventArgs e)
{
Exception ex = Server.GetLastError();
}
// Define it in Global.asax
protected void Application_Error(Object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
}
This is very useful, cause in a lot of cases, your don't want to implement exception-handling for every block in your code where it could occur. An often used scenario is catching your exeption in Application_Error and redirect to a special page, to offer a user-friendly error-page. Therefore you can use the technique above and redirect manually via code, or you can use the ASP.NET-feature explained in the next paragraph.
Custom Error Pages
The redirection to a custom error-page can be coded but it is more handy to do it by configuration. Here is how you can configure it in your web.config:

If an unhandled exception occurs, the user will be redirected to Error.htm, a page that you can define and design as you like. But you can use more detailled configuration for this. On known errors you can navigate to special error pages. An example for this is, when a page the user navigates to does not exist. Then the error 404 occurs and this is how you can tell ASP.NET to go to a special error-page for that:



Nice feature, isn't it? If you don't want to declare your error-page globally, you can also define it in the Page-directive of your aspx-file:
<%@ Page language="c#" Codebehind="Errors.aspx.cs"
AutoEventWireup="false"
Inherits="TestExceptions.Errors"
errorPage="MyErrPage.aspx" %>
Now the user is redirected to the page defined here, but only if an error in this special page occurs.
Error-handling in IHttpModule
Another possiblity to handle errors is in an own IHttpModule. To define it, you have to implement the interface IHttpModule and bind your error-handler in this class:
public class MyErrorModule : IHttpModule
{
public MyErrorModule()
{
}
#region IHttpModule Members
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.Error += new EventHandler(context_Error);
}
void context_Error(object sender, EventArgs e)
{
Exception e = HttpContext.Current.Server.GetLastError();
// handle exception
// Clear the error so that it doesn't occur again in
// the Application_Error-handler
HttpContext.Current.Server.ClearError();
HttpContext.Current.Response.Redirect("ErrorPage.htm");
}
#endregion
}
You also need to configure this HttpModule in your web.config-File:



So what is the benefit of using an own HttpModule. Well, the name already says it: You have a modularization for your error-handling. You can change your implementation at one place without touching your application-logic and you can change the errorhandling of your appliation by defining another HttpModule and configuring it in your web.app.

Saturday, April 11, 2009

$$$ ~~~~~~~~Robotics Must ---Be~C~~~~~~~$$$$$$$$

Bheem Sen Singh
Software Developer [ASP.NET & C#.NET & VB.NET] ,
Bhopal MP, India


$$ .,.,. Robots .,.,. $$

Robotic systems continue to evolve, slowly penetrating many areas of our lives, from manufacturing, medicine and remote exploration to entertainment, security and personal assistance. Developers in Japan are currently building robots to assist the elderly, while NASA develops the next generation of space explorers, and artists are exploring new avenues of entertainment. Collected here are a handful of images of our recent robotic past, and perhaps a glimpse into the near future.

Twendy-One demonstrates its ability to hold delicate objects by manipulating a drinking straw between its fingers at the Department of Mechanical Engineering laboratory in Waseda University in Tokyo, Japan, Wednesday, Jan. 14, 2009. The sophisticated robot has been developed by the university's team, led by Dr. Shigeki Sugano, in hope of supporting people in aging societies. (AP Photo/Shizuo Kambayashi)


NASA's Limbed Excursion Mechanical Utility Robot (LEMUR) is being designed as an inspection/maintena nce robot for equipment in space. A scaled-up version of Lemur IIa, could help build large structures in space. The Lemur IIa pictured here is shown on a scale model of a segmented telescope. (NASA/Planetary Robotics Laboratory)
Surgeons use a robot named da Vinci to aid a hernia operation, at the University Hospital Geneva, in Geneva, Switzerland, Thursday, Nov. 13, 2008. The University Hospitals of Geneva opened the department for robotic surgery in 2008, where between 50 and 80 surgeons from around the world will have the possibility to train with da Vinci each year. (AP Photo/Keystone, Salvatore Di Nolfi)

Humanoid robots Wakamaru, produced by Japan's Mitsubishi Heavy Industry, named Momoko (R) and Takeo (L) in the performace, take part in a drama for the world's first robot and human experimental theatre, written and directed by Japanese playwright Oriza Hirata, at Japan's Osaka University in Osaka, western Japan on November 25, 2008. (YOSHIKAZU TSUNO/AFP/Getty Images)An Explosive Ordinance Disposal robot places an explosive device next to a suspicious package during a demonstration conducted by members of the Special Operations Command Central Command Explosive Ordinance Disposal Unit for participants of the Joint Civilian Orientation Conference 72, at Camp Lemonier, Djibouti, Oct. 21, 2006. (Defense Dept. photo by Cherie A. Thurlby)

German Chancellor Angela Merkel poses with a robot called "Bruno" at the stand of the Darmstadt University of Technology during the third national IT summit in Darmstadt November 20, 2008. (REUTERS/Alex Grimm)Tokyo Fire Department's rescue robot transfers a mock victim onto itself during an anti-terrorism exercise in the response to a radiological dispersal device in Tokyo, on November 7, 2008. Tokyo Metropolitan government conducted the exercise with eleven organisations including Metropolitan Police Department. (TOSHIFUMI KITAMURA/AFP/ Getty Images)


A biomimetic underwater robot, named "RoboLobster" , designed by Professor Joseph Ayers, is seen, Aug. 17, 2007, in Nahant, Massachusetts. RoboLobster is intended to be used to recognize changes in seawater and to locate and destroy underwater mines. (Robert Spencer)

Toyota Motor Corporation partner robots play instruments at the company's showroom in Tokyo on May 4, 2008. (REUTERS/Toru Hanai)


Japan's Health Minister Yoichi Masuzoe sits with an assistive robot called "My Spoon" during a demonstration of health care robots in Tokyo on November 10, 2008. "My Spoon", developed by Japan's Secom is designed to help disabled people eat meals with joystick for controls using one's jaw, hand and feet. (AFP PHOTO/JIJI PRESS)


Milton Hospital urologist Dr. Clifford Gluck at the controls of the da Vinci surgical system on April 23, 2008 in Milton, Massachusetts (Boston Globe/Milton Hospital)

A Toyota Motor Corporation robot is pictured at a showroom in Tokyo December 11, 2008. (REUTERS/Michael Caronna)

Two All-Terrain Hex-Legged Extra-Terrestrial Explorer (ATHLETE) rovers traverse the desert terrain adjacent to Dumont Dunes, CA. The ATHLETE rovers are being built to be capable of rolling over Apollo-like undulating terrain and "walking" over extremely rough or steep terrain for future lunar missions. (NASA)
A Royal Marine poses for photographers with the Unmanned Vehicle Robot, Testudo, at the launch of the Defence Technology Plan in London February 26, 2009. (REUTERS/Luke MacGregor)
Fair visitors look at the humanoid robotic system "Rollin' Justin" preparing a tea on March 2, 2009 at the world's biggest high-tech fair CeBIT in Hanover, central Germany. (RONNY HARTMANN/AFP/ Getty Images)

NASA's K-10 Rover "Red", an experimental survey and exploration robot, uses its 3-D scanning systems during field tests in the "frost rubble zone" of Earth near Moses Lake, WA in June of 2008. (NASA/Ames Research Center)
A man shakes hands with robot 'Berti' at the Science Museum in London, Tuesday, Feb. 17, 2009. The robot, a life size humanoid robot, is built to mimic human gesturing, and is on show at London's Science Museum from Feb. 17 to 19. (AP Photo/Kirsty Wigglesworth)

The MSI produced robot named "Rich" demonstrates giving a tour walking down a garden trail in the Grand Hills apartment showroom of the Far Glory property company in Linkou, Taipei County, Taiwan on October 18, 2008.. (REUTERS/Nicky Loh (TAIWAN)
Robots work on an Iranian made Samand car at the Iran Khodro auto plant, west of Tehran, on September 30, 2008. (BEHROUZ MEHRI/AFP/Getty Images)
A Navy Talon 3B robot approaches a claymore land mine on a sand dune during a training exercise at a training range in Djibouti, Africa, on April 14, 2005. Navy Explosive Ordnance Disposal technicians from Mobile Unit 4 operate the robot from safe locations through the use of monitors and video equipment attached to the robot. (DoD photo by Petty Officer 1st Class Robert R. McRill, U.S. Navy)
A student of the Tokyo Institute of Technology displays a prototype security robot "bino3" during a demonstration at a security show in Tokyo on March 3, 2009. The bino3 has four "eyes", which are two wide-angle stereo camera lenses and two tele-photo stereo camera lenses which can follow an subject or intruder smoothly. (AFP PHOTO / Yoshikazu TSUNO)
Clara Vu, a software architect with Harvest Automation, tests "Mr. Incredible", a second generation robot prototype, in the firm's Groton, MA office August 29, 2008. Mr. Incredible is a container handling system for greenhouses, automatically moving potted plants into a widening grid as they grow and need more space. (Ellen Harasimowicz for The Boston Globe)

Farmer Wu Yulu drives his rickshaw pulled by a his self-made walking robot near his home in a village at the outskirts of Beijing January 8, 2009. This robot is the latest and largest development of hobby inventor Wu, who started to build robots in 1986, made of wire, metal, screws and nails found in rubbish sites. (REUTERS/Reinhard Krause)
NASA's Mars Science Laboratory rover in the course of its assembly, before additions of its arm, mast, laboratory instruments and other equipment, seen in August of 2008. Its six wheels are half a meter (20 inches) in diameter. The deck is 1.1 meter (3.6 feet) above the ground. The MSL rover is being assembled and tested for launch in 2011. (NASA/JPL-Caltech)

ImageConsumer

Interface java.awt.image.ImageConsumer


public interface ImageConsumer
extends Object
The interface for objects expressing interest in image data through the ImageProducer interfaces. When a consumer is added to an image producer, the producer will deliver all of the data about the image using the method calls defined in this interface

Variables Index :-
COMPLETESCANLINES
The pixels will be delivered in (multiples of) complete scanlines at a time.
 o IMAGEABORTED
The image creation process was deliberately aborted.
 o IMAGEERROR
An error was encountered while producing the image.
 o RANDOMPIXELORDER
The pixels will be delivered in a random order.
 o SINGLEFRAME
The image contain a single static image.
 o SINGLEFRAMEDONE
One frame of the image is complete but there are more frames to be delivered.
 o SINGLEPASS
The pixels will be delivered in a single pass.
 o STATICIMAGEDONE
The image is complete and there are no more pixels or frames to be delivered.
 o TOPDOWNLEFTRIGHT
The pixels will be delivered in top-down, left-to-right order.

Method :-

 o imageComplete(int)
The imageComplete method is called when the ImageProducer is finished delivering all of the pixels that the source image contains, or when a single frame of a multi-frame animation has been completed, or when an error in loading or producing the image has occured.
 o setColorModel(ColorModel)
The ColorModel object which will be used for the majority of the pixels that will be reported using the setPixels method calls.
 o setDimensions(int, int)
The dimensions of the source image are reported using the setDimensions method call.
 o setHints(int)
The ImageProducer can deliver the pixels in any order, but the ImageConsumer may be able to scale or convert the pixels to the destination ColorModel more efficiently or with higher quality if it knows some information about how the pixels will be delivered up front.
 o setPixels(int, int, int, int, ColorModel, byte[], int, int)
The pixels of the image are delivered using one or more calls to the setPixels method.
 o setPixels(int, int, int, int, ColorModel, int[], int, int)
The pixels of the image are delivered using one or more calls to the setPixels method.
 o setProperties(Hashtable)
The extensible list of properties associated with this image.

Variables -

 o RANDOMPIXELORDER
  public final static int RANDOMPIXELORDER
The pixels will be delivered in a random order. This tells the ImageConsumer not to use any optimizations that depend on the order of pixel delivery, which should be the default assumption in the absence of any call to the setHints method.
See Also:
setHints
 o TOPDOWNLEFTRIGHT
  public final static int TOPDOWNLEFTRIGHT
The pixels will be delivered in top-down, left-to-right order.
See Also:
setHints
 o COMPLETESCANLINES
  public final static int COMPLETESCANLINES
The pixels will be delivered in (multiples of) complete scanlines at a time.
See Also:
setHints
 o SINGLEPASS
  public final static int SINGLEPASS
The pixels will be delivered in a single pass. Each pixel will appear in only one call to any of the setPixels methods. An example of an image format which does not meet this criteria is a progressive JPEG image which defines pixels in multiple passes, each more refined than the previous.
See Also:
setHints
 o SINGLEFRAME
  public final static int SINGLEFRAME
The image contain a single static image. The pixels will be defined in calls to the setPixels methods and then the imageComplete method will be called with the STATICIMAGEDONE flag after which no more image data will be delivered. An example of an image type which would not meet this criteria would be the output of a video feed, or the representation of a 3D rendering which is being manipulated by the user. The end of each frame in those types of images will be indicated by calling imageComplete with the SINGLEFRAMEDONE flag.
See Also:
setHints, imageComplete
 o IMAGEERROR
  public final static int IMAGEERROR
An error was encountered while producing the image.
See Also:
imageComplete
 o SINGLEFRAMEDONE
  public final static int SINGLEFRAMEDONE
One frame of the image is complete but there are more frames to be delivered.
See Also:
imageComplete
 o STATICIMAGEDONE
  public final static int STATICIMAGEDONE
The image is complete and there are no more pixels or frames to be delivered.
See Also:
imageComplete
 o IMAGEABORTED
  public final static int IMAGEABORTED
The image creation process was deliberately aborted.
See Also:
imageComplete
Method :-

 o setDimensions
  public abstract void setDimensions(int width,
int height)
The dimensions of the source image are reported using the setDimensions method call.
 o setProperties
  public abstract void setProperties(Hashtable props)
The extensible list of properties associated with this image.
 o setColorModel
  public abstract void setColorModel(ColorModel model)
The ColorModel object which will be used for the majority of the pixels that will be reported using the setPixels method calls. Note that each set of pixels delivered using setPixels contains its own ColorModel object, so no assumption should be made that this model will be the only one used in delivering pixel values. A notable case where multiple ColorModel objects may be seen is when looking at a filtered image when the filter determines for each set of pixels that it filters whether the pixels can be sent on untouched, using the original ColorModel, or whether the pixels should be modified (filtered) and passed on using a ColorModel more convenient for the filtering process.
See Also:
ColorModel
 o setHints
  public abstract void setHints(int hintflags)
The ImageProducer can deliver the pixels in any order, but the ImageConsumer may be able to scale or convert the pixels to the destination ColorModel more efficiently or with higher quality if it knows some information about how the pixels will be delivered up front. The setHints method should be called before any calls to any of the setPixels methods with a bit mask of hints about the manner in which the pixels will be delivered. If the ImageProducer does not follow the guidelines for the indicated hint, then the results are undefined.
 o setPixels
  public abstract void setPixels(int x,
int y,
int w,
int h,
ColorModel model,
byte pixels[],
int off,
int scansize)
The pixels of the image are delivered using one or more calls to the setPixels method. Each call specifies the location and size of the rectangle of source pixels that are contained in the array of pixels. The specified ColorModel object should be used to convert the pixels into their corresponding color and alpha components. Pixel (m,n) is stored in the pixels array at index (n * scansize + m + off). The pixels delivered using this method are all stored as bytes.
See Also:
ColorModel
 o setPixels
  public abstract void setPixels(int x,
int y,
int w,
int h,
ColorModel model,
int pixels[],
int off,
int scansize)
The pixels of the image are delivered using one or more calls to the setPixels method. Each call specifies the location and size of the rectangle of source pixels that are contained in the array of pixels. The specified ColorModel object should be used to convert the pixels into their corresponding color and alpha components. Pixel (m,n) is stored in the pixels array at index (n * scansize + m + off). The pixels delivered using this method are all stored as ints.
See Also:
ColorModel
 o imageComplete
  public abstract void imageComplete(int status)
The imageComplete method is called when the ImageProducer is finished delivering all of the pixels that the source image contains, or when a single frame of a multi-frame animation has been completed, or when an error in loading or producing the image has occured. The ImageConsumer should remove itself from the list of consumers registered with the ImageProducer at this time, unless it is interested in succeeding frames.