17 June 2008

THE HACKER'S DICTIONAIRY

Click HERE to download "The Hacker's Dictionairy". Rare Ebook. Visit Me Again for more collections like this.

12 June 2008

Set up Gmail to work with Thunderbird (IMAP)

Thunderbird 2.0

Note: if you're using an older version of Thunderbird, we highly recommend upgrading to version 2.0.
To set up your Thunderbird client to work with Gmail:
1. Enable IMAP in Gmail.
2. Open Thunderbird, and select Tools > Account Settings.
3. Click Add Account.
4. Select the Email account radio button and click Next. The Identity screen appears.
5. Enter your full name in the Your Name field. Enter your full Gmail email address (username@gmail.com) in the Email Address field, and click Next.
6. Select IMAP as the type of incoming server you are using. Enter imap.gmail.com in the Incoming Server field.
7. Set the Outgoing Server to smtp.gmail.com, and click Next.


8. Enter your Gmail username (including @gmail.com) in the Incoming User Name and Outgoing User Name fields, and click Next





9. Enter a name for your email account in the Account Name field, and click Next.
10. Verify your account information in the dialog box, and click Finish.
11. Select Server Settings from the folder list below your new account.
12. Update the Port value to 993.
13. In the Security Settings section, select SSL from the Use secure connection options.
14. Select Check for messages at startup and Automatically download new messages
15. Click Outgoing Server (SMTP) in the folder list



16. Select the smtp.gmail.com (Default) entry from the list and click Edit. The SMTP Server page appears.
17. Enter smtp.gmail.com as the Server Name and set the Port to 587.
18. Select User name and password and enter your Gmail username (including @gmail.com) in the User Name field.
19. Select TLS from the Use secure connection radio buttons and click OK.
20. Click OK to save your changes and exit the Account Settings dialog.




adjust your client's settings as needed.
* Did you click 'Save Changes' after enabling IMAP in Gmail? To ensure that Gmail can communicate with your mail client, be sure to click Save Changes on the Forwarding and POP/IMAP settings tab.

IMPLMENTING QUIRKS

Implementation Of Quirks

Function X doesn't seem to work on Perl for Win32. Why not?

There are several functions that are unimplemented in the Perl for Win32 system. Primary among these are alarm() and fork(), which are used in quite a lot of modules developed for UNIX. Because they're missing in Perl for Win32, you can't use those modules.

Other unimplemented functions include System V IPC functions, UNIX system calls, Berkeley sockets functions that aren't WinSock functions, and some other weird ones. Here's a list, as extracted from unsupported.ntt, the perl script that tests unimplemented functions to make sure they stay that way and don't spontaneously implement themselves:

    alarm(), chroot(), fork(), getpgrp(), getppid(), getpriority(),
getpwnam(), getgrnam(), getpwuid(), getgrgid(), getpwent(),
getgrent(), setpwent(), setgrent(), endpwent(), endgrent(), kill(),
link(), msgctl(), msgget(), msgrcv(), msgsnd(), semctl(), semget(),
semop(), setpgrp(), setpriority(), shmctl(), shmget(), shmread(),
shmwrite(), symlink(), syscall(), times(), wait(), waitpid(),
getnetbyname(), getnetbyaddr(), getnetent(), getprotoent(),
getservent(), sethostent(), setnetent(), setprotoent(), setservent(),
endhostent(), endnetent(), endprotoent(), endservent(), socketpair()

Many other functions act in unexpected ways or are poorly implemented. Here is a (definitely non-exhaustive) list:

[Others? -ESP]

Function Y doesn't seem to work under PerlIS. Why not?

Besides not being a UNIX program, PerlIS has the second disadvantage of sharing a process space with the Web server and any number of other ISAPI extensions. Because of this, there are further restrictions on what a Perl script run by PerlIS can and cannot do. Some are built in, and some are just "bad" things to do.

According to the PerlIS info page, there are two things you can not/should not do in a Perl script run from PerlIS:

What's the difference between Perl for Win32 and the standard distribution?

Oh, a whole lot. The standard distribution was developed and is maintained in a UNIX-centric world, and there are a lot of OS dependencies built in. Here's a short list of the differences:

Finally, there's a difference in culture. perl is developed and maintained by the people who use it, and there's a collaborative nature to the progress of that product. Conversely, Perl for Win32 is de facto owned by ActiveWare, which has neither the participatory nature of a loose-knit user-developer community nor the responsiveness of a commercial software company.

What's the difference between running Perl for Win32 on Windows NT versus running it on Windows 95?

Although Perl for Win32 originally did not run on Windows 95, there should now be little difference between the two operating systems. You should watch for the following, though:

[Other differences? -ESP]

If you're worried about using a feature from one or the other, check the result of the function Win32::IsWinNT() to see what OS you're running on.

Why don't my examples from the Camel book work?

The Camel book (aka _Programming_Perl_, Wall et.al., O'Reilly & Associates 1996) was written by UNIX people for, in general, UNIX people.

Some of the examples in the Camel book will work. Some will not. If they fail, it's because either the functions used are not available, the external tools used are not available, or the modules used are not available. Usually, for small scripts, it's not to hard to fiddle with them until they come out correct (

Camel and Llama books are good learning tools. However, one of the things you learn as a Perl for Win32 programmer is how to port UNIX-targeted scripts and modules to Perl for Win32. So, get used to it.

The Perl motto is "There's More Than One Way To Do It." The Perl for Win32 motto could be "It's A Good Thing That There's More Than One Way To Do It, Because Most Of The Ways Don't Work."

5.6. Why doesn't standard library module Z work?

Many of the standard library modules don't work for the same reason that other Perl code doesn't work: the functions aren't implemented, the external tools aren't present, or modules they depend on aren't available.

Many of the "standard library" modules that come with the perl 5.00x standard distribution aren't distributed with the Perl for Win32 distribution because they weren't around for perl 5.001m. So, use'ing those modules may not even be possible.

How do I make a UNIX-based script work?

First, make extra-super sure that you are using the script or module in the way it was intended. Many of us are quick to blame the module, the operating system, or the interpreter when, in reality, it is our own code that isn't working right.

If you're sure that it's not a problem in your code, the best way to make a UNIX-based script work is to desk-check it before running it. Look for some of the following things:

  • Calls to functions unimplemented in Perl for Win32.
  • Calls to standard library modules or CPAN modules that aren't available on Perl for Win32, or that don't work.
  • system() or backtick (``) calls to system tools that aren't available on Perl for Win32.
  • Reading and writing files that may be binary.
  • File-system dependent path names and path name parsing. Watch for "/" rather than "\\", and hard-coded UNIX paths like "/usr/lib".
  • Version require's, like "require 5.003;" or "require Sockets 1.03;". Check to see if the script or module really requires the new version.

Of course, it should go without saying that for everything you take out you'll have to put in a work-around.

Once you've worked around UNIX dependencies in the script or module, try running it through the debugger to see if what you did helps. If the script or module comes with a ".t" test file, try using that to test your changed version.

If you _do_ make a change to a UNIX-based script or module, please let the author know. They will sometimes be gracious enough to make changes that will let the program run on Perl for Win32. If the author won't change the program, ask if you can make the altered version available to other users.

How does the chmod function work on Win32 platforms?

chmod() will execute as expected in Perl for Win32. However, it may not have the results you want. [Can someone tell me what works and what doesn't? -ESP]

UNIX-style security for files is not applicable to files on Win32 systems. Win32 systems inherit from DOS four possible "file attributes": archived (A), read-only (R), hidden (H), and system (S). These can be checked and set with the Win32::File::Get/SetAttributes().

Windows NT systems using NTFS can also have more specific permissions granted on individual files to users and groups. In build 110, you can retrieve and set these by running the CACLS program (type HELP CACLS at the command line for details). For builds 300 and above, you can use the Win32::FileSecurity module to maintain file permissions.

PERL FOR ISAPI

PerlIS

What is ISAPI?

ISAPI ("Internet Server API") is an API for writing extensions to Web servers. It complements or replaces the Common Gateway Interface (CGI), the standard interprocess protocol for writing extensions to Web servers.

ISAPI's main advantage over CGI is that it uses dynamic-link library (DLL) function calls to communicate with extension components, rather than environment variables and standard I/O, as CGI does. There's a lot of overhead in running new processes on Win32 platforms, and DLL calls obviate the need for new processes.

Although it was originally developed for Microsoft Internet Information Server, many Windows NT-hosted Web servers now support ISAPI. See question 6.1 for the names of a few. If your server isn't there, check its documentation.

What is PerlIS?

PerlIS, also known as "Perl for ISAPI", is an ISAPI extension that runs Perl scripts on Win32 platforms.

PerlIS is mainly used for creating dynamic content on World Wide Web sites. Writing Perl scripts that run under PerlIS is not much different than writing scripts for the Common Gateway Interface (CGI).

PerlIS doesn't have much general purpose use. For general purpose programming, stick with the perl interpreter (perl.exe).

Where can I get PerlIS?

PerlIS is distributed with the binary Perl for Win32 distributions (XXX-i86.zip, XXX-Alp.zip, XXX-Ppc.zip). It is *not* included in the source distribution (XXX-src.zip).

When you run install.bat, PERLIS.dll will be copied to your perl directory's bin subdirectory.

Why should I use PerlIS rather than Perl for Win32 (perl.exe)?

The short answer is: it's faster. The long answer gets kind of technical, but it goes kind of like this:

The main advantage of PerlIS over perl.exe is that PerlIS runs as a DLL in the Web server's "process space". Because Win32 platforms set up a protected "memory space" for each process that is started, there's a lot of overhead in starting a new process or program. Passing scripts to an interpreter, such as perl.exe, requires starting a new process for every script, which gets expensive in terms of system resources.

DLLs, on the other hand, don't need their own process space; they use the space of the process that calls them. They don't require nearly as much overhead to start, and once loaded they stay loaded until the calling process ends. PerlIS therefore runs Perl scripts with a lot lower turn-around time than perl.exe.

Where's the source code for PerlIS?

That's a good question. Although a layman's interpretation of the GNU General Public License or the Artistic License (the two possible licenses available for the original perl standard distribution) seems to indicate that source code for any perl-derived programs should be made publicly available, there doesn't seem to be copy of the PerlIS code available for download from ActiveWare.

PERL AVAILABILITY AND INSTALLATION

1.1. What is Perl, and where can I get a ton of information about it?

Perl is a scripting language widely used for system administration and programming on the World Wide Web. It originated in the UNIX community and has a strong UNIX slant, but is still very useful for Win32 platforms. perl (small 'p') is the program used to interpret the Perl language.

There are several good books about Perl; consult your local technical bookstore. Two in particular to consider are _Programming_Perl_, 2nd Edition, by Larry Wall, Tom Christiansen and Randal L. Schwartz (O'Reilly & Associates, 1996) and _Learning_Perl_, by Randal L. Schwartz (O'Reilly & Associates, 1993). These are referred to by Perl enthusiasts as "the Camel book" and "the Llama book", respectively. The nicknames come from the pictures on the front covers.

If you are new to Perl, and there are any terms mentioned in this FAQ that you don't get, try one of the above resources.


1.2. What Perl interpreters are available for the Win32 platform?

The main Perl interpreter available for the Win32 platform is Perl for Win32. It was developed by ActiveWare, Inc. (originally Hip Communications) for Microsoft Corporation for inclusion in the Windows NT Resource Kit. It has since taken on a life of its own. When people talk about "Perl for Win32", it is this package that they mean.

The Perl for Win32 package includes perl, PerlIS, and several Win32-specific modules developed by ActiveWare.

A beta version of Perl for Win32, which is at the perl 5.003 level, is also available.

Another implementation is the perl port in the MKS Toolkit from Mortice Kerns Systems, Inc. (http://www.mks.com/). This is a package that includes numerous other UNIX-originated tools.

Another version is available compiled for OpenNT for Microsoft Windows NT (http://www.softway.com/OpenNT/). OpenNT is a replacement for the POSIX subsystem of Windows NT, and is produced by Softway Systems, Inc. You'll have to have OpenNT to run this version.

[Any other implementations that should be mentioned here? - ESP]


1.3. Can I build perl myself from the standard distribution source code?

The standard perl distribution is mainly geared for UNIX systems. The configuration scripts are in UNIX shell language. It is therefore not a simple task to build perl from the standard distribution.

However, it has been done. Karl Martin Syring has built perl with the GNU-Win32 development system. His port is available at:

http://www.edv.agrar.tu-muenchen.de/~syring/gnu-win32/perl.zip

To build this, you'll need GNU-Win32, which is available from Cygnus Support (http://www.cygnus.com/misc/gnu-win32).

Gary Ng has ported perl to be compiled with Microsoft Visual C++. His port is available at this address:

http://www.endcontsw.com/pub/perl_win32.zip

To build it, unzip the distribution file into a win32 subdirectory of your perl directory (from the standard distribution -- like the os2 subdirectory).


1.4. Where is the Perl for Win32 interpreter available?

The Perl for Win32 package is available as a ZIP archive by anonymous FTP from ActiveWare and from CPAN, the Comprehensive Perl Archive Network.

To download, click the download button on the toolbar above.


1.5. How do I unzip the Perl for Win32 package?

Because the Perl for Win32 package contains long file names (LFNs), normal zip file handlers like PKZip will not open them correctly. [Does the newest version of PKZip handle LFNs correctly? -ESP] You need to get a zip file opener that can work with LFNs, such as:

To extract the archive, make a new directory on your hard drive that will become your new perl directory ("C:\Program Files\perl5" and "C:\perl5" are good candidates). Extract the archive to that directory, making sure that directory names are expanded from the archive (this is crucial!). See the documentation for your unzipper for details.


1.6. How do I build Perl for Win32 from the source code package?

The source code package includes make files for Visual C++ versions 2.x and 4.x. The following instructions are for Visual C++ 4.x. [Does anyone have instructions for VC++ 2.x? How about other Win32 C++ compilers? -ESP]

The source distribution only includes Intel targets. If you're building for another platform, like DEC Alpha, you may have to fiddle with the build settings to get them to work. [Anyone done this? -ESP]

First, make sure you unzipped the archive correctly into the destination directory. Then, open the perl100.mdp project file in the dll-src subdirectory of your perl directory with Microsoft Developers Studio.

Build the "perl100 - Win32 Perl Intel DLL Release" target (Go have some lunch -- this will take a while). You'll end up with a perl100.dll file in your ntt subdirectory of your perl directory.

Now, open the perl.mdp project file in the exe-src subdirectory of your perl directory. Build the "perl - Win32 Perl Intel Release" target. You also have to build the "perl - Win32 PerlGlob Intel Release" target. These will produce perl.exe and perlglob.exe, respectively, in your ntt directory.

Optionally, you can build the extension files that come with the source distribution. These include:

  • Fcntl: Fcntl.mak in the dll-src\Ext\Fcntl directory.
  • SDBM_File: sdbm_file.mdp in the dll-src\Ext\SDBM_File directory.
  • Win32 extensions: Win32.mdp in the dll-src\Ext\Win32 directory. Consider doing a batch build of these, to save yourself some headaches.
  • Win32::NetResource: NetResource.mak in the dll-src\Ext\Win32\NetResource\ directory. For some reason, this one isn't included with all the other Win32 modules.

Note that the extensions look for perl100.lib in the dll-src\Release directory, which by default doesn't exist. You can either create the directory and copy the lib file there, or go through the build settings for the extensions and set them to point to the proper directory, dll-src\LibRel.

Building the extensions will put the extension binaries (.pll files) in the proper place in the Lib subdirectory.


1.7. OK, I've got it downloaded, unzipped, and optionally built. Now what?

The last step is running install.bat, a perl program masquerading as a batch file found in your perl directory. Running install.bat will register the perl program and PerlIS with your system, as well as copy the binary files from the ntt subdirectory to the bin subdirectory.

If you installed in a directory with long file names (like "C:\Program Files\perl5"), you may want to change directory to the DOS version of your directory (like "cd C:\PROGRA~1\perl5") before running install.bat. This ensures that you get only readable paths in your registry, and could avoid some annoying errors.


1.8. What does installing do to my registry?

Installing Perl for Win32 adds the following keys to your registry, if they don't already exist:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Resource Kit\PERL5: main registry key
  • BIN: path to the perl binaries
  • PRIVLIB: path to the library files
  • HTML-DOCS: path to the HTML documentation

The BIN and PRIVLIB values are probably used in the perl interpreter to find files for loading. The purpose of the HTML-DOCS value is unclear.

Installing also adds your perl binary path to the PATH variable for your system, as well as "." (current directory), for historical reasons.

Also, if you have Microsoft Internet Information Server (IIS) installed, install.bat will associate an extension of your choosing (.pl is the default) with PerlIS in the IIS script mapping registry key, HKEY_LOCAL_MACHINE\System\Services\W3SVC\Parameters\Script Map. See IIS documentation for more info on the script map.


1.9. How do I uninstall Perl for Win32?

You are not able to uninstall Perl for Win32 from the Add/Remove Programs section of the Control Panel (if you have such a section).

In your original perl directory, there is a file called uninstall.bat. Use this to clear out the registry settings created by install.bat.

uninstall.bat does not delete your Perl for Win32 files for you. You can do this manually with Explorer, File Manager, or "del [perl directory]\*.* /S /Q", where [perl directory] is your perl directory.


1.10. What is ActiveScripting?

Active Scripting is a new technology put out by Microsoft Corporation to allow code embedded in HTML pages to run on WWW clients or servers. It is designed to be language neutral, so that you can write Active Scripts in Visual Basic, JavaScript, Python, or, theoretically, Perl.


1.11. Is there an ActiveScripting version of Perl available?

Yes. On December 4, 1996, ActiveWare released a beta version of PerlScript, an ActiveScripting engine for the Perl language.

Download by clicking the button on the toolbar above.

You'll also need to download either the Perl for Win32 5.003 binary or source format package in the same directory.

There's no documentation to speak of, but there are several examples. ActiveScripting works a lot like OLE Automation, so if you review that documentation, plus the ActiveScripting documentation, you should be able to get along.


1.12. What other scripting languages are available for Win32 platforms?

Although it's possible to program in batch language or with QBASIC (a 16-bit BASIC interpreter that comes with Windows 95 and Windows NT), serious programmers will probably prefer one of the following other options:

Awk and UNIX shell languages are available from in several UNIX-to-NT packages. [Any others? -ESP]


1.13. Where's Perl for Win32 5.003?

On December 4, 1996, ActiveWare released a beta version of Perl for Win32 at the 5.003 level. It corrects many of the flaws of the 110 build at the 5.001m level. It's available at

ftp://ftp.activeware.com/Perl-Win32/beta/

or on CPAN at

http://www.perl.com/CPAN/ports/win32/Perl5/beta/

There are four beta packages:

  • Pw32i302.exe, the Intel x86 binary
  • Pw32302s.exe, the source distribution
  • PlSEi302.exe, the ActiveScripting PerlScript engine.
  • PlISi302.exe, the Perl for ISAPI distribution

Neither PerlIS or any of the RISC processor distributions can be found here.

Many of the answers in this FAQ do not apply to the beta version.


1.14. When I double-click on the "perl.exe" icon in Explorer, I get an empty DOS window with a blinking cursor. What gives?

Perl for Win32 is a Win32 command-line program. It expects to be run from the command line, not from Explorer.

If you want to run a Perl script, write the script out using a text editor like Notepad. A good starter program is:

    print "Hello, World!\n";
 

Save the program to a file on your hard disk (such as "C:\temp\hello.pl"). Now, start a command prompt window (sometimes erroneously called a "DOS window"), and type the following line at the command prompt:

    C:\> perl c:\temp\hello.pl
 

This should print out the words "Hello, World!" on the screen. You may have to do some fiddling with the PATH environment variable, or specify the full path name to perl.exe, in order for this to work.

perl.exe has a lot of nifty command-line arguments that can make your work a lot easier. See the perlrun documentation page for details.

To answer the original question about what's happening when you start perl from an Explorer window rather than a command-line window: starting from Explorer is roughly the same as starting perl without any command line arguments. When perl is started without a script file specified on the command line, it expects to receive a Perl program as standard input, i.e., from the keyboard.

The blinking cursor means perl is waiting for your input. You can actually type in a Perl program from the keyboard, and then let perl know to execute it by typing the Ctrl-Z key, which is the end-of-file marker on Windows systems.


1.15. When I install Perl for Win32, it says I don't have Internet Information Server, and asks if it should still install PerlIS.dll.

When I say yes, it says there was an error.  Why?

PerlIS.dll is a special interpreter for Perl. Because setting PerlIS up for Microsoft Internet Information Server (IIS) is such a pain in the keister, install.bat will do it for you automagically.

However, if you don't use IIS on the machine you're installing Perl for Win32 on, you should answer "no" when you're asked. A lot of people confuse "PerlIS.dll" that the message asks about with Perl for Win32 in general. Thus the problem.

If you get this error, ignore it. Perl programs should run just fine. If you're the kind of chucklehead who won't sleep knowing that there was an error during the installation, just run uninstall.bat, then run install.bat again, and answer "no" instead of "yes". Feel better?

If you want to use PerlIS.dll with another ISAPI-enabled Web browser, you'll have to set that up by hand. install.bat won't do it for you.

PERL AD MANAGEMENT

1) Banner Rotation
Banner Rotation is a simple and easy to use banner rotation script that can be used to rotate banners of your advertisers on your website easily and can manage them effectively.

2) AdvertPRO
AdvertPRO is a professional advertising delivery and management application capable of serving and tracking all of your online advertising endeavors

3) HTML Rotate
HTML rotate is a simple solution to randomly rotating almost anything on your web pages.

4) Easy Banner Rotating
Web based administration, unlimited advertisers, full stats - keep tracking of exposures, click-throughs and the ratio. Requires Server Side Includes (SSI).

5) Advertisement Rotation Manager
An Internet advertisement management tool including a forms based management utility. Also includes banners per page statistics.

6) ad-counter.pl
This script helps to record any hit by incrementing a counter file, then returning a hyperlinked image tag. This is useful for especially for multiple rotating ads. This cgi can be used by a file using Server Side Includes (SSI).

7) Bannermatic
This script will operate a rotating banner ad system on your website. Bannermatic comes in 3 flavors: Server-Side-Includes based, HTTP-Cookie-Powered and IP Address based. Also a banner manager script includes

8) Banner Creator
Banner Creator is an effective ad management utility which permits your web site visitors to create banners online with the required color and font for the text, speed of the animation etc.,

9) World Wide Banner Rotator
This is a very simple and easy to use banner rotation script .It is very easy to install and takes very little time and effort to install. It also allows you to add and delete banners. It requires SSI.

10) AdSpaceSeller
This is an online advertisement software that allows you to sell any space on your website for advertisers or sponsors thereby you can earn additional revenues by fixing your own price.

11) Banner Engine
This is a simple and easy to use script available online which can be used to rotate ad banners in multiple websites. It contains a web based admin interface which takes care of managing the banners on your website.

12) Ad Rotator
This script uses JavaScript to insert banners into the html and rotates any number of banners on the webpage at any spot. The script also keeps statistics on displays and clicks for each banner and provides for admin pages for listing, adding, and removing banners.

13) High Speed's Ultimate Ad Tracker
High Speed's Ultimate Ad Tracker is a simple and effective online ad tracking software written in perl. You can track ad hits through different URL's from password protected admin area.

14) ProAnalyzer Ad Tracking System
ProAnalyzer is a powerful, yet easy to use ad tracker, that can be run from your website. Capable of tracking unique hits, sales and other actions, it comes with free upgrades for life and unlimited tech support. Includes an automated set-up wizard. It is built with a split run tester.

15) AdTracker Pro
This is a complete ad tracking system that can be used for maintaining a set of rotating ad banners on your website. It keeps track of exposures and each click-thru per banner.

16) Ad Carousel
Carousel is a random ad banner script written in perl. This script allows you to use either ready-to-paste HTML code supplied by affiliates, or you can use image locations and link URL's.The HTML for each banner is written to a flatfile database and retrieved at random for display.

17) SunnyScript's AdvertisingSuite
SunnyScript's AdvertisingSuite is a top-featured advertising banner management system.

18) Ad Banners
Ad Banners is a banner management software that can be used to manage the banners and to rotate them on your website. You can view the online demo on the website.

19) Banners Pro
The professional Banner delivery system-Banners Pro is ready to help the webmasters in controlling advertisements in any websites. Banner Rotation is the main part controlled through this Banners Pro.

20) DAD
DAD is a comprehensive Web Ad Management System. DAD was originally developed for internal use at Student.Net Publishing and was released under GPL as a submission to Perl Conference 2.0 in July 1998.

21) Ad Click-Through Redirection CGI
This CGI is designed for use with ad banners. In order for you to properly calculate compensation for banners, you need to know who is clicking through them.

22) Power Ad
This is a script that helps you to setup and manage an advertisement program on your site. Along with keeping track of the number of times a particular banner has been displayed and clicked on the site, it maintains statistics about the payment schedules either daily , weekly or monthly as required.

23) Ad Master
Ad Master is a banner advertisement package. Helps you to optimize your banners

24) AdCycle
AdCycle is ad management software powered by mySQL. This script is written in perl.

25) Ad Smart
This program allows the webmasters to display their website with advertisements and earn revenue online as per cost per click(CPC) or by cost of impressions(CPM).

26) Netads
This script allows setting up of an advertisement program. In addition to keeping track of the number of times a banner is displayed, it also allows you to add, view, edit, delete, reset each banner's data easily and edit configuration file. This is an easy to install and use script.

27) LedAds
This is the second generation of Ledscripts.com's perl-based banner program. Using this one can manage the banners (add, delete, modify) and also can view the statistics of clicks on banners. You can use standard ad banners or use your own rich-media adcode.

28) Adwertise With Pleasure, AWP
This is a banner advertisement package that is easy to use and will simplify your banner campaign. It features easy installation, intuitive user/admin interfaces, no SSI required, stats, web based graphics upload, multiple expiry options, advertiser accounts, anti-caching features, templates & more.

29) Perl N' JavaScript Banners
This set of scripts allows you to run an ad banner rotation on your site. What's nice, is the rotation is done with JavaScript, which means your server doesn't have to waste cpu power on generating random banners

30) CosmicBannerRotator
Free banner rotation software to script for rotating advertisments for web pages.

31) BannerPlus Gold
BannerPlus Gold is fine ad manager software with multi-lingual interface, easy setup, free supports. The software offers many enhanced features. BannerPlus Gold is available in French, Spanish, German, Italian and Portuguese.

32) Blazing Fast Banner Rotator
Blazing Fast Banner Rotator is a program with which webmasters can display and manage ad banners on their existing websites. This program is based on PERL.

33) IntraLinks RotateAds
IntraLinks RotateAds is a simple and easy to use script that is available online to manage and rotate ad banners on your website easily. An online demo is provided on the website.

34) Ace Banner Rotator
banner rotater is packed with features, any thing you could want is here, the script can rotate HTML, groups/zones, weighting banners and loads more.

35) SimpleCycle
SimpleCycle is a simple banner management software that can be used to customize the banners to place them in each of your domains thereby increasing the traffic to your website.

36) Advertise With Pleasure! (AWP)
This is a banner advertisement package. Some of its salient features are easy installation, intuitive user and admin interfaces, no requirement of SSI, customizable output, support for many banner formats, multi-banner support, text ads exchange and many more.

37) Clicktimizer
Clicktimizer is a popup window management service. Provides a wizard driven configuration interface to provide a variety of functions.Creates popup windows on the fly,create and manage upto 5000 popup windows.

38) jbBanner
jbBanner is an Ad management system that is capable of maintaining a set of rotating banner ads on your website. It contains an advanced and secured admin interface that manages the banner ads effectively.

39) MojoBanner
MojoBanner is a feature rich banner and image management system that can be used to create, manage and publish banners and image rotations on a website. It uses MySQL as database backend.

40) BannerFusion
BannerFusion is a modular, full-featured, ad management system, design specifically for sites which demand a reliable, high-performance, easily customizable, scalable solution, at an extremely low cost

41) Banner Rotation
This is easy to setup cgi script allows to display unlimited numbers of banners on your site. Banners can be displayed randomly from a banners list.

42) CsBanner
This system allows maintenance of a set of rotating banner ads on your site. It allows creation of multiple groups and allows easy organization of the banners for rotations. You can place unlimited number of banner ads within each group.

43) Banner Serve
Banner Serve is an ad banner management script that is available in Perl for the purpose of placing your banners on remote sites. An online demo can be viewed on the website.

44) BanEx
. BanEx has been created for the average webmaster and webmistress to allow him and her to have random banners appear with links. It could be used to have have advertisers on your website, or for many other reasons...

45) vgBanners
Complete banner rotation and administration tool.

46) Stuffed Tracker
Stuffed Tracker is an useful tool for small and medium sized websites that helps them to track the return on investment for every ad banner they have placed online.

47) Amiex - text advertisement exchange script
This is a script for managing a text advertisement exchange on your website. It comes with numerous features for users as well as for the administrators.

48) InverseFlow Advertising Server
This CGI application is designed for easy integration and on-site customization of ad placements. With a set of PERL scripts using MySQL database, the application helps in displaying and tacking on unlimited sites for unlimited advertisers.

49) Linktrakker DUO
Linktrakker DUO is a perl script to manage banner campaigns.It has a user and admin interface, Add the html code into any webpage and start viewing the stats for each campaign. Easy to use.

50) Qbanner
Qbanner is a Perl+Mysql Ad-Server with support of GIP, JPG and PNG files. Provides Graphical representation of statistics.

11 June 2008

NTFS and SHARED LEVEL PERMISSIONS IN WINDOWS OPERATING SYSTEMS

Usually people assume by themselves NTFS permission has a higher priority. But infact when NTFS & SHARED LEVEL both applied to a folder or drive, SHARED LEVEL permission always take a higher precedence. So when you provide Full Permission in Shared Level and provide Deny in NTFS it does not have effect on it.

This might be asked when you go for the windows administrator interview. So make sure that you answer perfectly in single line.

SHARED LEVEL PERMISSION takes higher PRECEDENCE than NTFS LEVEL PERMISSION IN WINDOWS OPERATING SYSTEMS

FLASH CACHE Integrated in Intel's & Windows Vista

FLASH CACHE will be used by Windows Vista to store frequently accessed data from the hard drive, a technique Microsoft calls ReadyDrive. Using Flash memory means the data can be retrieved not only more quickly than it can from a hard drive, but also at a lower energy cost, boosting battery life. In Dell machines this FLASH CACHE is enabled by default if you choose the machine with Windows Vista pre installed. If you want to install XP on this pre installed Vista machine, you will have to disable the FLASH CACHE. Otherwise it will not allow you to change the SATA operation method of AHC1 to ATA.

This is Intel's pitch. Hard drive vendors are pushing HDDs with integrated Flash memory, again to be used as a fast-access cache by Vista.

Platform Specific Issues

Platform Specific Issues
I get an OutOfMemoryException when I redeploy on Tomcat!
Can I use Hibernate with JDK 1.3?
Hibernate doesn't work with MySQL!
Hibernate expects my JDBC driver to support JDBC2 but it doesn't!
My JDBC driver supports batch updates. How come Hibernate doesn't enable them by default?
Hibernate doesn't work with my MS SQL 2000 JDBC driver?
Are there known issues with Interbase / Firebird?
I'm having problems with Weblogic Server!
After a while, Oracle throws this exception: too many open cursors
MySQL throws an exception: Cannot disable AUTO_COMMIT
Tomcat throws java.lang.UnsupportedOperationException when fetching a JDBC connection
JBoss AS complains about unclosed connections?

I get an OutOfMemoryException when I redeploy on Tomcat!
This is common and not the fault of Hibernate or anything Hibernate does. Hibernate has no leaking ThreadLocal variables, no classloader magic, nothing else that has ever been identified as causing this and could be somehow fixed in Hibernate. Tomcat's reloading of the web contexts doesn't work reliably with other libraries (such as Struts, etc), the reasons are often found in Tomcat, Classloaders, or JVM bugs. Please don't post any questions about this on the Hibernate forums, or on the Hibernate developer list. Ask on the Tomcat users list. If you need hot redployment to work immediately, use Tomcat inside JBoss application server.
Can I use Hibernate with JDK 1.3?
Yes, but the distributed binaries are compiled for JDK 1.4 and newer. You will have to recompile Hibernate from source (type 'ant' in the distribution directory). This probably fails, as some of the dependencies of Hibernate have been compiled or are only available for JDK 1.4 and newer. However, users reported success after they found replacements for these dependencies.
Hibernate doesn't work with MySQL!
The MySQL Server 4.1.12 RPM delivered with Mandriva Linux 2006 breaks prepared statements. This can be solved by either adding "useServerPrepStmts=false" to the MySQL connection string in the Hibernate configuration file or by using an unbroken original MySQL Server package. http://bugs.mysql.com/bug.php?id=14910
Hibernate expects my JDBC driver to support JDBC2 but it doesn't!
Set hibernate.jdbc.batch_size=0
hibernate.jdbc.use_scrollable_resultsets=false
or upgrade your driver to the latest version. Hibernate chooses sensible default values for these properties, based upon your SQL dialect.
My JDBC driver supports batch updates. How come Hibernate doesn't enable them by default?
Batch updates seem to be cause problems for some JDBC drivers that claim to support them. We found that batch updates should be disabled for DB2 and Sybase.
Hibernate doesn't work with my MS SQL 2000 JDBC driver?
(Glen Stampoultzis)
If you're using Hibernate with the Microsoft SQL Server 2000 JDBC driver chances are you'll run into this problem:java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]
Can't start a cloned connection while in manual transaction mode.
Simply add SelectMethod=Cursor; to your connection string. There's a MS knowledge base article with more information. The Microsoft SQL Server 2005 JDBC driver has been certified by JBoss Inc.
Are there known issues with Interbase / Firebird?
(Michael Jakl)
Yes. Due to some limitations in Interbase / Firebird we must use some workarounds:
Always set the size of your statement cache to zero (hibernate.statement_cache.size or hibernate.c3p0.max_statements)
If you are altering tables you should be in single user mode. This can be achieved by running gfix -shut. It's also sufficient to have only one database connection open (eg. immediately after starting the application). If more than one connection is open, you will see errors like "table is in use". To restart your database use gfix -online.
I'm having problems with Weblogic Server!
If you get CharScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlToken - Hibernate 3.x includes a new query parser that doesn't run on Weblogic - the reason is a packaging error of ANTLR in Weblogic's boot classpath. Read the section in the Hibernate3 Migration Guide.
If you have a = javax.naming.NoInitialContextException=, this seems to solve it for Weblogic 8.1, in your Hibernate configuration:t3://localhost:7001
weblogic.jndi.WLInitialContextFactory
The JNDI implementation in WebLogic Server does not appear to support the Referenceable interface, and exhibits some rather strange behaviour when binding Serializable objects. Please direct complaints to BEA. This might affect only older versions of Weblogic.
Workarounds include using a different JNDI implementation (eg. Sun's FSContext) or using some other means of obtaining a SessionFactory.
See also Mathias' Blog!
The forum users believe there's some problem if you do it the regular way like most app server. Therefore, try the following (which works for me). Use a WLS Startup class to bind Hibernate Session Factory object in WLS JNDI. Here's an excerpt of a possible code:public class WLSStartup implements T3StartupDef
{
public static final String SESSION_FACTORY_JNDI = "hibernate";
public static final String URL = "t3://localhost:7001";
/**
* Called by WebLogic server upon startup. This is where everything should
* be initialzed.
*
* @param name the JNDI name of this class
* @param args any input parameters
*
* @return the status.
*
* @throws Exception in case of any error
*/
public String startup( String name, Hashtable args ) throws Exception
{
String METHOD_NAME = "startup ";
// Bind the various Hibernate Object to the Weblogic JNDI
try
{
log ( METHOD_NAME + " Going to bind Hibernate object. " );
doBind( );
log ( METHOD_NAME + " Bound Hibernate object!" );
}
catch ( Exception exception )
{
log ( METHOD_NAME + " Exception while binding Hibernate Object to Weblogic JNDI" );
exception.printStackTrace ( );
}
return "WLS Startup completed successfully";
}
/**
* Performs Hibernate objects to Weblogic JNDI Namespace bindings.
* It gets the initial context and binds the Hibernate objects to it.
*
* @param None
* @throws Exception in case of any errors
*/
private static void doBind( ) throws Exception
{
Properties environment = null;
InitialContext context = null;
try
{
//Properties for storing JNDI configuration information
environment = new Properties( );
//Add initial context factory
environment.put( Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
environment.put( Context.PROVIDER_URL, URL );
log( "Constructing an Initial Directory Context object" );
context = new InitialContext( environment );
Datastore ds = Hibernate.createDatastore();
SessionFactory factory = ds.buildSessionFactory();
if (factory == null)
throw new Exception("SessionFactory cannot be built?!");

try
{
if( context.lookup(SESSION_FACTORY_JNDI ) != null )
context.rebind(SESSION_FACTORY_JNDI, factory );
else
context.bind(SESSION_FACTORY_JNDI, factory );
}
catch ( NamingException nameEx )
{
context.bind(SESSION_FACTORY_JNDI, factory );
}
}
catch ( NamingException nameExp )
{
throw new Exception( "NamingException: " + nameExp.getMessage( ));
}
catch( Exception excp )
{
throw excp;
}
finally
{
if( context != null )
{
try
{
context.close( );
context = null;
}
catch ( NamingException nameExp )
{
throw new Exception( "NamingException for context close: " nameExp.getMessage( ));
}
}
environment = null;
}
}
Jar up the relevant Hibernate jar files and configure this Startup class under WLS console.
Then at your JNDI client (Servlet or EJBs for example) you can have a code similar to this excerpt below: -Object objref;
Context context;
Hibernate.configure();
//The usual WLS JNDI context
context = getInitialContext();
objref = context.lookup(WLSStartup.SESSION_FACTORY_JNDI);
sessionFac = (SessionFactory) PortableRemoteObject.narrow(objref, SessionFactory.class);
if sessionFac == null)
throw new Exception("Null SessionFactory found?!");
Works great with Struts 1.1 on WLS 6.X and 7.X. I've tested by writing some subclass relationship data into Oracle 8i!
Any questions can be directed to simon@see-consulting.com.
After a while, Oracle throws this exception: too many open cursors
The Oracle JDBC driver doesn't much like to have its prepared statements cached. Disable PreparedStatement caching for the connection pool.
MySQL throws an exception: Cannot disable AUTO_COMMIT
Download the latest MySQL driver.
Tomcat throws java.lang.UnsupportedOperationException when fetching a JDBC connection
In Tomcat (maybe other situations) if you are using the built-in DBCP to as a JNDI datasource, be sure that you do not specify hibernate.connection.username or hibernate.connection.password in either hibernate.cfg.xml or hibernate.properties. DBCP does not implement the version of Datasource.getConnection() that takes a username and password.
JBoss AS complains about unclosed connections?
If you get the message "[org.jboss.resource.connectionmanager.CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection" you are missing a configuration setting, hibernate.connection.release_mode - set it to auto or read the reference documentation about it.

NEW COMMENT
After a while, Oracle throws this exception: too many open...
30 Dec 2003, 17:06
dominikroblek
We are successfully using Hibernate with Oracle JDBC driver with
prepared statement cache enabled. We had to raise open cursor limit in
Oracle database as each cached prepared statement keeps one open cursor
on the database. Ask you DBA for assistance.

I need more Info about issues with Interbase / Firebird?
11 May 2005, 11:13
erick_77
Hi,
I am new using Hibernate. I tested the auctions example of Hibernate
using PostgresSQL as database, and it ran witout any trouble. But now I
need to test it with firebird, when I run the build.bat It creates the
tables but at the moment that it starts to alter table it displays
errors that tables are in use. Example:
[java] 16:31:22,869 DEBUG SchemaExport:162 - alter table
AuctionItem add constraint FK522A9BD61107FE9B foreig
key (seller) references AuctionUser
[java] 16:31:22,929 ERROR SchemaExport:168 - Unsuccessful: alter
table AuctionItem add constraint FK522A9BD61
07FE9B foreign key (seller) references AuctionUser
[java] 16:31:22,929 ERROR SchemaExport:169 - Resource Exception.
unsuccessful metadata update
[java] object AUCTIONUSER is in use
[java] Reason: unsuccessful metadata update
[java] object AUCTIONUSER is in use
I read in this page something about this issue. And the solution is that
I need to execute the firebird's gfix command. I would like to get more
information about this issue, please be more specific with your answer
or if you have another alternative way to solve it.
Thanks.

Incorrect link for JSQL
23 Sep 2005, 07:22
geofft
The link provided for JSQL is http://www.j-netdirect.com when in fact
it should be http://www.jnetdirect.com

Re: After a while, Oracle throws this exception: too many open..
20 Apr 2006, 08:10
bworwood
POST QUESTIONS ON THE FORUM! COMMENTS HERE SHOULD ADD VALUE TO THE
PAGE!On 30 Dec 2003 17:06, dominikroblek wrote:
>We are successfully using Hibernate with Oracle JDBC driver with
>prepared statement cache enabled. We had to raise open cursor limit in
>Oracle database as each cached prepared statement keeps one open
cursor
>on the database. Ask you DBA for assistance.
I am having a similar problem - open cursors are not being cleared.
Did you get over your issue?

DB2 ClassCastException when using JDBC batches
08 Sep 2006, 13:08
iamjvn
Be careful when using JDBC batch settings larger than 0.
DB2 driver with a JDBC batch size other than 0 may cause a
ClassCastException.
Caused by: java.lang.ClassCastException: java.lang.Integer
at com.ibm.db2.jcc.a.jb.a(jb.java:1068)
at com.ibm.db2.jcc.a.jb.a(jb.java:792)
at com.ibm.db2.jcc.a.jb.a(jb.java:163)
at com.ibm.db2.jcc.a.tb.a(tb.java:220)
at com.ibm.db2.jcc.b.ad.a(ad.java:1625)
at com.ibm.db2.jcc.b.ad.b(ad.java:2725)
at com.ibm.db2.jcc.b.ad.a(ad.java:2632)
at com.ibm.db2.jcc.b.ad.executeBatch(ad.java:2444)
at com.ibm.db2.jcc.b.ad.executeBatch(ad.java:1329)
at
com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
hibernate.cfg.xml
-----------------
...
0
...

Re: After a while, Oracle throws this exception: too many open..
25 Oct 2006, 20:06
caili314
POST QUESTIONS ON THE FORUM! COMMENTS HERE SHOULD ADD VALUE TO THE
PAGE!On 20 Apr 2006 08:10, bworwood wrote:
>POST QUESTIONS ON THE FORUM! COMMENTS HERE SHOULD ADD VALUE TO THE
>PAGE!On 30 Dec 2003 17:06, dominikroblek wrote:
>>We are successfully using Hibernate with Oracle JDBC driver with
>>prepared statement cache enabled. We had to raise open cursor limit in
>>Oracle database as each cached prepared statement keeps one open
>cursor
>>on the database. Ask you DBA for assistance.
>I am having a similar problem - open cursors are not being cleared.
>Did you get over your issue?
I ran into the same problem when using DBCP connection provider in
Hibernate 2.1.2. Traced into
net.sf.hibernate.connection.DBCPConnectionProvider, I found the
construction of statementPool didn't pass in maxTotal parameter, which
is used by GenericKeyedObjectPoolFactory to determine when to clear the
pool content. So the solutions can be either to pass in this parameter
or to disable statement pool by simply setting statemPool to null. Both
work!

Incorrect FAQ regarding Batch updates against DB2
23 Mar 2007, 00:00
anshuld
This FAQ above (#ABCD6) regarding batch
updates should be disabled against DB2 is incorrect. Batch update works
fine when using IBM DB2 JDBC driver shipped with version 8 and version
9. Batch updates should be enabled because it provides performance
advantages to application using hibernate against DB2.
In another thread (http://www.hibernate.org/120.741.html) it shows a
stack trace with ClassCastException. This only happens if type changes
between batch elements. This can be avoided by setting connection
property deferPrepares to false. This bug was also fixed in the driver
that was shipped in early 2006.

DB2 and Blobs
20 May 2008, 21:59
sgwood
Working with Hibernate + Blobs against DB2 databases, you need to be
careful with the JDBC connection settings.
When reading the blob, you can get:
com.ibm.db2.jcc.b.SqlException: [jcc][10120][11936][3.50.152] Invalid
operation: Lob is closed. ERRORCODE=-4470, SQLSTATE=null
at com.ibm.db2.jcc.b.wc.a(wc.java:55)
at com.ibm.db2.jcc.b.wc.a(wc.java:93)
at com.ibm.db2.jcc.b.rd.d(rd.java:67)
at com.ibm.db2.jcc.b.sd.w(sd.java:202)
at com.ibm.db2.jcc.b.sd.getBinaryStream(sd.java:107)
at
org.hibernate.lob.SerializableBlob.getBinaryStream(SerializableBlob.java:39)
This was with DB2 9.5 and the db2jcc driver.
The solution was to follow the advice of
http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14053553
getting to a JDBC connect string like:
jdbc:db2://localhost:50000/testDB:fullyMaterializeLobData=true;fullyMaterializeInputStreams=true;progressiveStreaming=2;progresssiveLocators=2;

Performance Q&A

Performance Q&A
How does Hibernate perform?
But Hibernate uses so much runtime reflection?
Okay, so what are the advantages of reflection then?
But how does it scale?
Why not implement instance-pooling anyway?
Does Hibernate implement its functionality using a minimal number of database queries?
So why don't you provide an "official" Hibernate benchmark?
Conclusion?
How does Hibernate perform?
We claim that Hibernate performs well, in the sense that its performance is limited by the underlying JDBC driver / relational database combination. Given this, the question boils down to: does Hibernate implement its functionality using a minimal number of database queries and how can it improve performance and scalability on top of JDBC? This page hopefully answers these questions.
But Hibernate uses so much runtime reflection?
Many former C or C++ programmers prefer generated-code solutions to runtime reflection. This is usually justified by reference to the performance red-herring. However, modern JVMs implement reflection extremely efficiently and the overhead is minimal compared to the cost of disk access or IPC. Developers from other traditions (eg. Smalltalk) have always relied upon reflection to do things that C/C++ needs code-generation for.
In the very latest versions of Hibernate, "reflection" is optimised via the CGLIB runtime bytecode generation library. This means that "reflected" property get / set calls no longer carry the overhead of the Java reflection API and are actually just normal method calls. This results in a (very) small performance gain.
Okay, so what are the advantages of reflection then?
A quicker compile-build-test cycle. The advantage of this should not be understated. The philosophy of Hibernate is this: let the developer spend as little time as possible implementing persistence for the 95% of the application which is used 5% of the time. Then, later, if there are performance issues with the remaining 5%, there will be plenty of time left for hand-coding JDBC calls to improve performance of particular bottlenecks. (Most of the time Hibernate very closely approaches the performance of hand-coded JDBC anyway.)
But how does it scale?
Hibernate implements an extremely high-concurrency architecture with no resource-contention issues (apart from the obvious - contention for access to the database). This architecture scales extremely well as concurrency increases in a cluster or on a single machine.
A more difficult question is how efficiently Hibernate utilizes memory under heavy load.
Since there is no sharing of objects between concurrent threads (like EJB 2.x entity beans), and since Hibernate does not automatically do instance-pooling (unlike EJB 2.x entity beans), you might think that memory utilization would be less efficient, and this may be true to an extent. However, our experience with real Java applications is that the benefits of instance-pooling are almost negated by common Java coding style. Very often programmers create a new HashMap in ejbLoad ..... or return a new Integer from a method call .... or do some string manipulations. Furthermore, every time you load and then passivate a bean, every non-primitive field of the bean is garbage, not to mention whatever garbage the JDBC driver leaves behind. All these kinds of operations leave behind as much garbage as we avoided by doing instance-pooling.
Please note that Hibernate is not a competitor to EJB. In fact, Hibernate EntityManager and Annotations implement a persistence service for EJB 3.0 entity beans, on top of the Hibernate Core architecture.
All this leads to Hibernate not needing a locking or synchronization mechanism, in memory, or to a lock table on disk. As stated earlier, Hibernate completely relies on the database management systems ability to deal with concurrent access; the experience of the DBMS vendors in this area should be used.
The other side of scalability is downward scalability. While it wasn't designed with small devices in mind, Hibernate nevertheless has a small footprint and could be used on machines with much less memory than you would need to run an application server. If it can run a JVM and a database, it should be able to run Hibernate.
Why not implement instance-pooling anyway?
Firstly, it would be pointless. There is a lower bound to the amount of garbage Hibernate creates every time it loads or updates and object - the garbage created by getting or setting the object's properties using reflection.
More importantly, the disadvantage of instance-pooling is developers who forget to reinitialize fields each time an instance is reused. We have seen very subtle bugs in EJBs that don't reinitialize all fields in ejbCreate.
On the other hand, if there is a particular application object that is extremely expensive to create, you can easily implement your own instance pool for that class and use the version of Session.load() that takes a class instance. Just remember to return the objects to the pool every time you close the session.
Does Hibernate implement its functionality using a minimal number of database queries?
Good Question. Hibernate can make certain optimizations all the time:
Caching objects. The session is a transaction-level cache of persistent objects. You may also enable a JVM-level/cluster cache to memory and/or local disk.
Executing SQL statements later, when needed. The session never issues an INSERT or UPDATE until it is actually needed. So if an exception occurs and you need to abort the transaction, some statements will never actually be issued. Furthermore, this keeps lock times in the database as short as possible (from the late UPDATE to the transaction end).
Never updating unmodified objects. It is very common in hand-coded JDBC to see the persistent state of an object updated, just in case it changed.....for example, the user pressed the save button but may not have edited any fields. Hibernate always knows if an object's state actually changed, as long as you are inside the same (possibly very long) unit of work.
Efficient Collection Handling. Likewise, Hibernate only ever inserts/updates/deletes collection rows that actually changed.
Rolling two updates into one. As a corollary to (1) and (3), Hibernate can roll two seemingly unrelated updates of the same object into one UPDATE statement.
Updating only the modified columns. Hibernate knows exactly which columns need updating and, if you choose, will update only those columns.
Outer join fetching. Hibernate implements a very efficient outer-join fetching algorithm! In addition, you can use subselect and batch pre-fetch optimizations.
Lazy collection initialization.
Lazy object initialization. Hibernate can use runtime-generated proxies (CGLIB) or interception injected through bytecode instrumentation at build-time.
A few more (optional) features of Hibernate that your handcoded JDBC may or may not currently benefit from
second-level caching of arbitrary query results, from HQL, Criteria, and even native SQL queries
efficient PreparedStatement caching (Hibernate always uses PreparedStatement for calls to the database)
JDBC 2 style batch updates
Pluggable connection pooling
Hopefully you will agree that Hibernate approaches the parsimony of the best hand-coded JDBC object persistence. As a subscript I would add that I have rarely seen JDBC code that approaches the efficiency of the "best possible" code. By contrast it is very easy to write efficient data-access code using Hibernate.
So why don't you provide an "official" Hibernate benchmark?
Many people try to benchmark Hibernate. All public benchmarks we have seen so far had (and most still have) serious flaws.
The first category of benchmarks are trivial micro benchmarks. Hibernate of course will have an overhead in simple scenarios (loading 50.000 objects and doing nothing else is considered trivial) compared to JDBC. See this page for a critique of a trivial benchmark. If you'd like to avoid writing your own trivial and not very conclusive tests, have a look at the perftest target in Hibernate's build file. We use this target to check if a trivial performance bug slipped into the Hibernate code. You can use it to verify the JDBC overhead of Hibernate in trivial situations. But, as should be clear now, these numbers are meaningless for real application performance and scalability.
In a fair benchmark with complex data associations/joins, highly concurrent access, random updates of data in the application, real-world data set size, and utilizing other Hibernate features, you will find Hibernate perform very well. Why is there no such benchmark provided by the Hibernate developers? The first reason is trust. Why would you believe that the numbers shown by the vendor of a product, in a comparative benchmark, are true? The second reason is applicability. Certainly, a fair benchmark would show the benefits of Hibernate in a typical complete application with realistic concurrent access. However, the number of variables in any decent benchmark make it almost impossible to transfer these results into reasonable conclusions about the performance of your own application. Your application is different. (If you came here from a forum thread, think about it: instead of arguing with you about your trivial micro benchmark, we would be arguing why you don't see the same results in your application...) For these reasons we always recommend that you benchmark your application yourself. We encourage you to see performance and load testing as a natural stage in the life of your application - don't go into production with only micro benchmarks. Setting up benchmarks for your application and scenario, and helping you in this stage is in fact one of our usual
Conclusion?
It turns out that Hibernate is very fast if used properly, in highly concurrent multi-user applications with significant data sets

Common Problems

Common Problems
I get a ClassNotFoundException or NoClassDefFoundError
How do I show the bound parameter values in the SQL log?
I get a ObjectNotFoundException: No row with the given identifier exists
I get InvalidObjectException: Could not find a SessionFactory named: null
I get org.hibernate.HibernateException: CGLIB Enhancement failed: ?
I saved / deleted / updated an object / collection but I can't see the changes in the database!
I saved a parent object but its associated objects weren't saved to the database.
I called saveOrUpdate() or update() and got a NonUniqueObjectException!
I'm using a one-to-many association with a NOT NULL constraint on the key column and Hibernate causes constraint violations.
I'm having trouble with a bidirectional association.
I'm still having trouble!
Can't I have a bidirectional association using a List or Map?
I get a log message: Parsing XML: unknown system id
I get a log message: reflection optimizer disabled
Hibernate keeps deleting and recreating my collection!
Hibernate throws a PropertyAccessException or NullPointerException when I load or query an object!
I removed an object from a collection mapped with cascade="fghjkll" but the object was not deleted!
Hibernate updates an object in the database, when I didn't change anything!
How can I get Hibernate to persist an instance variable that does not have property accessors, or simply bypass the property accessors?
Hibernate is nontransparent because it requires me to have a default constructor which breaks the API of my class!
I'm confused about the semantics of saveOrUpdate().
I don't know if I should use save() or persist().
How does inverse="true" affect the semantics of cascade="fghjkll"?
I get a ClassCastException when using a composite identifier
I get a ClassCastException when I specify a collection sort attribute.
I have some other kind of wierd bugs.....
Does Hibernate support database views?
I'm using Hibernate in a CMT session bean or BMP entity bean and I recieve an exception whenever I try to commit() the Transaction or JDBC Connection.
How do I use Hibernate with CMT?
How do a write a query that returns objects based upon a WHERE clause condition applied to their collection elements?
I want to retrieve query results, one page at a time
I see a java.lang.AbstractMethodError: net/sf/hibernate/persister/AbstractEntityPersister.... at startup!
I am getting a PropertyAccessException, and the error trace suggests to turn off the reflection optimizer. Howerver, it doesn't seem that I can set this in hibernate.cfg.xml.
I have a property named like getAFoo() / setAFoo() and Hibernate throws a PropertyNotFoundException at startup.
Hibernate tries to connect to http://hibernate.sourceforge.net at startup!
I've enabled the second-level cache and my queries are not being cached!
Hibernate returns java.sql.Date instead of java.util.Date!
What is the lifecycle of a Hibernate Session?
I'm having trouble configuring association fetching strategies...

I get a ClassNotFoundException or NoClassDefFoundError
You are missing a third-party library Hibernate needs, check lib/README.txt in the Hibernate distribution first. You need all classes that are listed as required for runtime. Another much more exotic reason might be a static initializer block of one of the needed classes (error during load) or a security-related issue (policy doesn't allow loading).
How do I show the bound parameter values in the SQL log?
Hibernate uses commons logging and the org.hibernate.type package to log values bound to prepared statements. If you are using Log4J as the logging provider underneath commons logging, set this category to TRACE level to see the values in the log. Older versions of Log4J only required the DEBUG level (there was no TRACE level). See the bundled log4j.properties in the Hibernate distribution.
I get a ObjectNotFoundException: No row with the given identifier exists
This might occur if you try to load a non-proxied object with session.load() or you load a proxied object and later access the proxy. It may also occur when loading mapped collections which are not eagerly fetched. Another cause are foreign key fields that are not protected with a foreign key constraint, and now contain bogus values. Check the ids you are using for load. Validate your foreign key relationships - the database should already maintain such integrity constraints. Beware of multiple transactions within a single session. Try to stick to "one session, one transaction" rule. Especially do not use sessions after a HibernateException has been thrown.
I get InvalidObjectException: Could not find a SessionFactory named: null
This exception occurs if you try to serialize a disconnected Hibernate Session and deserialize it in a different VM, or, if the classloader has restarted, for example, during hot redeployment in your application server or web container. This is especially visible in Tomcat. In application servers, always use JNDI to store the SessionFactory, as documented. In Tomcat or other web containers, disable HttpSession serialization during context reload. This has side effects, explained in the web container's documentation.
I get org.hibernate.HibernateException: CGLIB Enhancement failed: ?
If you use lazy loading with proxies (default for all classes in Hibernate 3), Hibernate needs to subclass your class at runtime. It can't do this if you have a private no-argument constructor. As per documentation, at least package visibility is required.
I saved / deleted / updated an object / collection but I can't see the changes in the database!
Hibernate will not execute any SQL until you either call Transaction.commit() (if using the Transaction API) or Session.flush() (if you are not) at the end of a session to flush your in-memory changes to the database.
If you are not using the Transaction API, you must then explicitly commit the transaction (by committing the JTA transaction or JDBC Connection).
I saved a parent object but its associated objects weren't saved to the database.
Associated objects must be saved explicitly by calling Session.save() (or Session.persist()) or the association must be mapped with cascade="fghjkll" or cascade="save-update" (or cascade="persist").
I called saveOrUpdate() or update() and got a NonUniqueObjectException!
The session maintains a unique mapping between persistent identity and object instance, in order to help you avoid data aliasing problems. You cannot simultaneously attach two objects with the same class and identifier to the same session.
The best way to avoid any possibility of this exception is to always call saveOrUpdate() at the beginning of the transaction, when the session is empty.
In Hibernate3, you can try using the merge() operation, which does not reattach the passed instance.
I'm using a one-to-many association with a NOT NULL constraint on the key column and Hibernate causes constraint violations.
Use a bidirectional association, mapping the many-valued end with inverse="true".
Or, for a unidirectional association, use in the collection mapping.
I'm having trouble with a bidirectional association.
When you update a bidirectional association you must update both ends.parent.getChildren().add(child);
child.setParent(parent);
It's best to do this in an association management method of your persistent class.
I'm still having trouble!
Read the documentation! There's a detailed section about "Parent/Child Relationships" in chapter 16 of the reference documentation including code examples.
Can't I have a bidirectional association using a List or Map?
In Hibernate3,















column="parent_id" not-null="true"
insert="false" update="false"/>


In this case, the collection-valued end of the association controls updates to the database.
Or, alternatively:















column="child_order" not-null="true"/>
column="parent_id" not-null="true"/>


In this alternative, you must set the value of the childOrder property yourself before making the objects persistent.
I get a log message: Parsing XML: unknown system id
Ignore it. Its quite normal when loading a mapping document as a resource.
I get a log message: reflection optimizer disabled
Thats quite okay. For some classes we can't use CGLIB for property access, so we have to fall back to reflection. This will have a very minor effect upon performance. (CGLIB's MetaClass can't access final properties or nonpublic properties.)
Hibernate keeps deleting and recreating my collection!
Unlike other Hibernate value types, Hibernate tracks actual collection instances using Java identity, ==. Your getter method should return the same collection instance as was assigned by Hibernate to the setter method (unless you don't mind the collection being removed and recreated every time the session is flushed).
This doesn't mean you shouldn't return a different collection if you really are replacing the current collection with a new collection with completely different elements. In certain cases, this behaviour can even be taken advantage of to increase performance.
Hibernate throws a PropertyAccessException or NullPointerException when I load or query an object!
A PropertyAccessException often occurs when the object being passed to the setter method is of the wrong type. Check your type mappings for the offending property. (To see exactly which property was the problem, you might need to disable the CGLIB reflection optimizer.) However, the most common cause of this problem is that Hibernate attempted to assign null to a property of primitive type.
If your object has a primitive-type property mapped to a nullable database column then you will need to use a Hibernate custom type to assign a sensible default (primitive) value for the case of a null column value. A better solution is usually to use a wrapper type for the Java property.
I removed an object from a collection mapped with cascade="fghjkll" but the object was not deleted!
cascade="fghjkll" cascades the delete() operation from parent to child. If this is a one-to-many association, try using cascade="fghjkll,delete-orphan".
Another solution is to model your child objects as composite elements (a kind of value type) rather than entities. Value types are always persisted or removed along with their parent entity. So you would use a mapping for the element class instead of a mapping..
Hibernate updates an object in the database, when I didn't change anything!
This always occurs because you actually did change something! Enable Hibernate's logging to debug level and search for is dirty in the log. That will tell you exactly what property is detected to be dirty.
How can I get Hibernate to persist an instance variable that does not have property accessors, or simply bypass the property accessors?
Use access="field".
Hibernate is nontransparent because it requires me to have a default constructor which breaks the API of my class!
You may declare the constructor private. (Same goes for any property accessors.)
I'm confused about the semantics of saveOrUpdate().
Firstly, so long as you are not trying to use instances from one session in another new session, you should not need to use update() or saveOrUpdate(). Some whole applications will never use either of these methods.
Usually update() or saveOrUpdate() are used in the following scenario:
the application loads an object in the first session
the object is passed up to the UI tier
some modifications are made to the object
the object is passed back down to the business logic tier
the application persists these modifications by calling update() in a second session
saveOrUpdate() does the following:
if the object is already persistent in this session, do nothing
if the object has an identifier property value that indicates that it is transient and no row already exists in the database, save() it
if another object associated with the session has the same identifier, throw an exception
otherwise, update() it
I don't know if I should use save() or persist().
Both methods make a transient instance persistent. However, the persist() method doesn't guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time.
The persist() method also guarantees that it will not execute an INSERT statement if it is called outside of transaction boundaries. This is useful in long-running conversations with an extended Session/persistence context.
The save() method does not guarantee the same, it returns an identifier, and if an INSERT has to be executed to get the identifier (e.g. "identity" generator, not "sequence"), this INSERT happens immediately, no matter if you are inside or outside of a transaction. This is not good in a long-running conversation with an extended Session/persistence context.
How does inverse="true" affect the semantics of cascade="fghjkll"?
It doesn't.
I get a ClassCastException when using a composite identifier
Does the composite identifier class implement Serializable?
I get a ClassCastException when I specify a collection sort attribute.
When you first instantiate a sorted collection, it must be an instance of SortedSet, or SortedMap. Use a TreeSet or TreeMap, for example.
I have some other kind of wierd bugs.....
Carefully check the accessor methods for your persistent properties. Broken get/set pairs are a common source of bugs. Remember Hibernate might call a getter method multiple times during a session.
Also, make sure that a call to an accessor method couldn't do anything wierd ... like initialize a lazy collection or proxy.
For some classes it can be worthwhile to provide two get/set pairs for certain properties - one pair for business code and one for Hibernate.
Does Hibernate support database views?
Of course. From the point of view of Hibernate, a view is just like any other table (except that you might not be able to update or insert to a view). You can easily map a class to a view by specifying table="view_name".
In Hibernate3, you may even map an entity class to a SQL query result set using the mapping element. This is useful if you are unable to define new views in your database.
I'm using Hibernate in a CMT session bean or BMP entity bean and I recieve an exception whenever I try to commit() the Transaction or JDBC Connection.
In a CMT environment, you must let the container take responsibility for transaction management. Application code must still perform all the usual Session management, ie. Session.flush(), Session.close().
How do I use Hibernate with CMT?
See Sessions and transactions.
How do a write a query that returns objects based upon a WHERE clause condition applied to their collection elements?
There are two possibilities:select distinct parent
from Parent parent
join parent.children child
where child.name = :name
from Parent parent where :childId in elements(parent.children)
The first query uses a table join; the second uses a subquery. The first query allows constraints to be applied to element properties; the second does not.
You may not need the distinct keyword in the first query.
I want to retrieve query results, one page at a time
Use Query.setMaxResults() and Query.setFirstResult() for query paging.
Do not use ScrollableResults for this! In an online application, holding a database cursor open across a user interaction is extremely expensive in terms of performane.
I see a java.lang.AbstractMethodError: net/sf/hibernate/persister/AbstractEntityPersister.... at startup!
(Michael Davidovich) The problem is the -classic JVM debug option, which is present in both Jboss and IntelliJ project options, beware!
(Christian Bauer) Recompiling Hibernate with your JDK is the other solution.
I am getting a PropertyAccessException, and the error trace suggests to turn off the reflection optimizer. Howerver, it doesn't seem that I can set this in hibernate.cfg.xml.
Unfortunately, there are two properties which may only be set at the "system" level, ie. in hibernate.properties or using java -D. This is one of them.
I have a property named like getAFoo() / setAFoo() and Hibernate throws a PropertyNotFoundException at startup.
Use name="fghjkFoo" as the property name in your mapping files. Don't report this issue as a bug, we know about it and we can't change it. If you insist on "first letter lowercase" naming of properties, use a custom access="my.PropertyAccessor" setting.
Hibernate tries to connect to http://hibernate.sourceforge.net at startup!
Usually you use the wrong DTD declaration in your XML mapping/configuration files. Or, this means that your XML parser does not support the EntityResolver callback that Hibernate uses to resolve the mapping DTD from inside hibernate3.jar. Either use a different XML parser, such as a recent version of Xerces, or edit your mapping documents to use a SYSTEM id instead of the PUBLIC id that we recommend in the documentation.
I've enabled the second-level cache and my queries are not being cached!
The Hibernate second-level cache is different to the Hibernate query cache. The second level cache applies when objects are retrieved using get(), load() or navigation of associations. It does not apply to query result sets. You must use the query cache to cache HQL, SQL, or criteria query result sets.
Hibernate returns java.sql.Date instead of java.util.Date!
This problem occurs usually because you compare two dates wrong. The right way to compare date and time in Java is to use aDate.getTime().equals( bDate.getTime() ), this works for java.util.Date and java.sql.Timestamp.
Hibernate returns a java.sql.Timestamp when retrieving information from the database, as this type can transport the additional nanosecond information. If you want to cut this off, you can write a custom UserType. This is a transparent converter. See the following thread: http://forum.hibernate.org/viewtopic.php?t=925275
What is the lifecycle of a Hibernate Session?
See Sessions and transactions.
I'm having trouble configuring association fetching strategies...
See A Short Primer On Fetching Strategies.

Site owned by Hariharan | Saravanan