Search This Blog

Thursday, September 16, 2010

Procedure for uploading file to blob field in oracle database

Sample Table
CREATE TABLE SV_EMP_PHOTO
(
ID NUMBER(3) NOT NULL,
PHOTO_NAME VARCHAR2(40),
PHOTO_RAW BLOB,
EMP_NAME VARCHAR2(80)
)
Create a directory where the photos will be stored.
Create directory SV_PHOTO_DIR as 'E:\photo'
Procedure to read file and save to database
CREATE OR REPLACE PROCEDURE sv_load_image
(
p_id NUMBER ,
p_emp_name IN VARCHAR2 ,
p_photo_name IN VARCHAR2
) IS
l_source BFILE;
l_dest BLOB;
l_length BINARY_INTEGER;
BEGIN
l_source := BFILENAME ('SV_PHOTO_DIR', p_photo_name);
INSERT INTO sv_emp_photo(ID, photo_name, emp_name, photo_raw)
VALUES(p_id,p_photo_name,p_emp_name,EMPTY_BLOB ())
RETURNING photo_raw INTO l_dest;
-- lock record
SELECT photo_raw INTO l_dest FROM sv_emp_photo
WHERE ID = p_id AND photo_name = p_photo_name FOR
UPDATE;
-- open the file
DBMS_LOB.fileopen (l_source, DBMS_LOB.file_readonly);
-- get length
l_length := DBMS_LOB.getlength (l_source);
-- read the file and store in the destination
DBMS_LOB.loadfromfile (l_dest, l_source, l_length);
-- update the blob field with destination
UPDATE sv_emp_photo SET photo_raw = l_dest WHERE ID = p_id
AND photo_name = p_photo_name;
-- close file
DBMS_LOB.fileclose (l_source);
END;
GRANT ALL ON DIRECTORY SV_PHOTO_DIR TO PUBLIC

Friday, March 12, 2010

Windows XP Tips

1. systeminfo :- The computer will produce a lot of useful info, including the uptime. If you want to keep these, type ’systeminfo > info.txt’.
2. lock your XP workstation with two clicks of the mouse. Create a new shortcut on your desktop using a right mouse click, and enter ‘rundll32.exe user32.dll,LockWorkStation’ in the location field. Give the shortcut a name you like. That’s it just double click on it and your computer will be locked. And if that’s not easy enough, Windows key + L will do the same.
3.eventcreate’ and ‘eventtriggers’ for creating and watching system events, ‘typeperf’ for monitoring performance of various subsystems, and ’schtasks’ for handling scheduled tasks. As usual, typing the command name followed by /? will give a list of options they’re all far too baroque to go into here.
4. get rid of tasks on the computer from the command line by using ‘taskkill /pid’ and the task number, or just ‘tskill’ and the process number.
5. XP will treat Zip files like folders, which is nice if you’ve got a fast machine. On slower machines, you can make XP leave zip files well alone by typing ‘regsvr32 /u zipfldr.dll’ at the command line. If you change your mind later, you can put things back as they were by typing ‘regsvr32 zipfldr.dll’.
6. You can run a program as a different user without logging out and back in again. Right click the icon, select Run As… and enter the user name and password you want to use. This only applies for that run. The trick is particularly useful if you need to have administrative permissions to install a program, which many require. Note that you can have some fun by running programs multiple times on the same system as different users, but this can have unforeseen effects.
7. You can start up without needing to enter a user name or password. Select Run… from the start menu and type ‘control userpasswords2′, which will open the user accounts application. On the Users tab, clear the box for Users Must Enter A User Name And Password To Use This Computer, and click on OK. An Automatically Log On dialog box will appear; enter the user name and password for the account you want to use.

Thursday, March 11, 2010

Speed Up Windows Vista

Windows vista
has lot more to offer when it comes to new features with enhanced user friendliness and other accessibility features being talked about in comparison with other previous versions of windows like windows 2000
and windows xp.Unlike previous Microsoft operating systems, Windows Vista is streamlined specifically according the needs of various types of users.
But when we talk about the resource consumption and their utilization it always need a lot of cpu and other memory to carry out even the simple operations like copying a file ,playing a video as compared to windows xp( Which according to me is the most stable and fast operating system by microsoft ever).

Follow the steps below to make your windows vista faster…
1. Disable the Aero Theme
Aero theme which is wonderful but a slow theme as the graphic effects consume a lot of memory which in turn makes other applications to run slower in vista.How To disable Aero Theme:
a. Right click on the desktop > Personalize
b. Select one of the available theme i prefer windows vista classic but if you find it worse go for windows vista basic.
2. Increase the File Copy Speed in windows vista
One of the solutions to make file copying operations faster is to disable and remove the Remote Differential Compression feature in Vista.
How To disable Remote Differential Compression:
a. Open Control Panel and in the Programs node
b. In the Uninstall or Change a Program window, click on the Turn Windows Features On or Off link.
google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);
3. Disable TCP Autotuning Feature in windows vista
a. Click Start and type CMD.b. Press CTRL+SHIFT+ENTER to open the command Prompt with Administrative rights.c. At the prompt in the Administrator: Command Prompt window, type the following command,(with out double quotes).d. “netsh interface tcp set global autotuninglevel=disabled”e. and then press ENTER:
4. Disable Indexing in windows Vista
Disable unnecessary indexing of files or folders
a. Open Indexing Options from the Control Panel.
b. Next, in the Indexing Options window, click Modify.
c. Now uncheck all the checkboxes you see, and leave just the start menu.
5. Turn Windows Features on or off
Some programs and features that are included with Windows, such as Internet Information Services, must be turned on before you can use them. Certain other features are turned on by default, but you can turn them off if you don’t use them. Disable Unneeded Features :
a. Open the Control Panel, click Programs,
b. click Turn Windows features on or off in the Programs and Features section

How To Increase Your Internet Speed By 20%

If you use Windows XP Professional then it is possible to squeeze an extra 20% out of your internet connection. By default Windows XP Pro
holds back 20% of your Internet speed for various services like windows update and spyware checks.
If you want to tap into this locked speed then make the following changes:
1. Go to Start-> Run-> and type gpedit.msc
2. Expand the Administrative Templates branch
3. Expand the Network tab
4. Highlight QoS Packet Scheduler
5. Click on Limit Reservable Bandwidth and check the enabled box
6. Then Change the Bandwidth limit % to 0 %

Once you have done this click apply and restart your PC
. After rebooting you should see a noticeable improvement in your net speed.

Monday, March 8, 2010

ADF:- ActionListener

FacesContext context = FacesContext.getCurrentInstance();
ELContext elContext = context .getELContext();
MethodExpression actionListenerExpression = context.getApplication().getExpressionFactory().createMethodExpression(elContext,"#{myHandler.myActionListenerMethod}",null,new Class[] {ActionEvent.class});
MethodExpressionActionListener methodExpressionActionListener = new MethodExpressionActionListener(actionListenerExpression);

ADF:- ActionListener

try
{
Class[] parameterList = { Class.forName("javax.faces.event.ActionEvent") }; MethodBinding actionListenerBinding = FacesContext.getCurrentInstance().getApplication().createMethodBinding( "#{myHandler.myListener}",parameterList); myComponent.setActionListener(actionListenerBinding );
}
catch (Exception e)
{
log.error("error setting ActionListener");
}

ADF:- MethodExpression

FacesContext context = FacesContext.getCurrentInstance();MethodExpression methodEx = context.getApplication().getExpressionFactory().createMethodExpression(context.getELContext(), "#{myHandler.action}", String.class, new Class[] {});
myComponent.setActionExpression(methodEx );

ADF:- MethodBinding

MethodBinding methodBinding = FacesContext.getCurrentInstance().getApplication().createMethodBinding( "#{myHandler.action}",null);
myComponent.setAction( methodBinding );

ADF:- ValueExpression

FacesContext context = FacesContext.getCurrentInstance();
ValueExpression vex = context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(), "#{myBean.myProperty}", String.class);
myComponent.setValueExpression("value", vex);ValueExpression rex = context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(), "#{myBean.myProperty}", Boolean.class);myComponent.setValueExpression("rendered", rex);

ADF:- ValueBinding

ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding( "#{myBean.myProperty}");
myComponent.setValueBinding("value", vb);