Seeking Oracle out of the matrix

Google
 
Web aboutoracle.blogspot.com
Oracle New Articles
Oracle Critical Patches
Oracle jDeveloper News
Oracle Blogs of interest


This blog records my personal experience.
Latest news from the front
               

Thoughts about oracle Author's note : Thank you all for your supporting letters. You have been a motivation to this web spot's posting. I wish you all the very best for you and your families for the new year.
Interested to know about a next post? You can suscribe to my RSS feed
HOW TO:

Honey, you missed a spot
Sunday, December 24, 2006
Just a humourous mood here... something that catched my attention ;-)



The above, was retrieved from the help file of jDeveloper 10g R2. This error was corrected on jDeveloper 10.1.3 as you can see below:

A funny little break; now get back to work.

posted by Admin @ 5:10 AM   11 comments
add to del.icio.us Digg it! Furl this! add to reddit! add to dzone!
TIP: Use exp.exe to export specific rows from a table, with command-line SQL
Saturday, December 09, 2006
If you ever need to export specific records from your table to a .dmp file using exp.exe here is an example :

Suppose we have a table Orders and we want to export that table to a dmp file - not the whole table but today's orders.

from the prompt you write :

exp.exe 'sys/mypass@mydb as sysdba' file=c:\orders.dmp log=c:\orders.log tables=(ORDERS) QUERY=\" WHERE ORDER_DATE = '11/08/2006'\"


Remember :
query=\" \" or else you get an error !

posted by Admin @ 9:04 PM   2 comments
add to del.icio.us Digg it! Furl this! add to reddit! add to dzone!
INFO : Aggregator for Oracle jDeveloper
There is an an aggregator for all Oracle JDeveloper related blogs. Visit http://thepeninsulasedge.com/adfblog/ . This blog has every recent post found on blogs about Oracle JDeveloper issues.
You can find a related link in the [Oracle Blogs of Interest] in this blog as well :-)

posted by Admin @ 4:14 PM   1 comments
add to del.icio.us Digg it! Furl this! add to reddit! add to dzone!
TIP: Upload a file using struts (includes jdeveloper 10g complete example)
Wednesday, December 06, 2006
Struts simplify the file uploading process really easy.
You dont need third party stuff; just a few lines of code and a couple of tricks
will do the job :)

I have included a sample project for you to download and experiment with.

Key parts are :

1. Your form that will include the <html:file> tag, must be configured to handle multipart/form-data and to POST the data to the server, eg :

<html:form enctype="multipart/form-data" method="POST" action="upload.do">


2. The form bean that will handle the uploading, must have a property for the file been uploaded set like this :

<form-property name="filename" type="org.apache.struts.upload.FormFile">


After that, coding is really simple. I have included a complete project for uploads at the end of this post.
Here follows the java source part for the upload file process:



package fileuploader.view;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import java.text.DecimalFormat;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.upload.FormFile;

public class UploadAction extends Action
{
/**
* This is the main action called from the Struts framework.
* @param mapping The ActionMapping used to select this instance.
* @param form The optional ActionForm bean for this request.
* @param request The HTTP Request we are processing.
* @param response The HTTP Response we are processing.
* @throws javax.servlet.ServletException
* @throws java.io.IOException
* @return
*/

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, Exception
{
String toPage = "";
DynaActionForm df = null;
FormFile webFile = null;
FileOutputStream ServerFileStream = null;
File SaveToFile = null;
int FILE_SIZE_LIMIT = 5000000;
double filesize = 0 ;

try
{
//convert to a DynaActionForm
df = (DynaActionForm) form;
//class cast to a struts type FormFile filename
webFile = (FormFile) df.get("filename");

//get the size of the file that user wants to upload
filesize = webFile.getFileSize();

//i have included a file size limitation in this version
if (filesize > FILE_SIZE_LIMIT )
{
//format the size of the file to return two decimals
String pattern = "####.##";
DecimalFormat dblFormat = new DecimalFormat(pattern);
//file size returned to megabytes
String strFileSize = dblFormat.format((filesize / 1024) / 1024);

//redirect to the page that informs the user that there is a
//file size limitation
toPage = "filesizepage";
request.setAttribute("fsize", strFileSize);
return mapping.findForward(toPage);
}
//get the real path of the project
String strFilePath = getServlet().getServletContext().getRealPath("/");
//we want to upload to UploadedFiles directory
strFilePath = strFilePath + "UploadedFiles";

//initialize a file to write to
SaveToFile = new File(strFilePath, webFile.getFileName());


//in this version, if the file to upload already exists on the server
//i delete the server-side one and reupload it
if(SaveToFile.exists())
{
//delete the file
SaveToFile.delete();
}
//save the file to server
ServerFileStream = new FileOutputStream(SaveToFile);
ServerFileStream.write(webFile.getFileData());
ServerFileStream.flush();
ServerFileStream.close();
ServerFileStream = null;

toPage="success";
}
catch(Exception e)
{
//just print the trace
e.printStackTrace();
//and redirect to an error page
toPage = "error";
}
finally
{
//release resources
df = null;
webFile = null;
ServerFileStream = null;
SaveToFile = null;
}

return mapping.findForward(toPage);

}
}



Download the full jdeveloper sample project
(right-click and select "save target as")

just remember to rename it to .rar

posted by Admin @ 10:42 PM   5 comments
add to del.icio.us Digg it! Furl this! add to reddit! add to dzone!
TIP: Grant select on all user tables to another user
Monday, December 04, 2006
This is one of the number one issues for a DBA. Well, the good news is that it has become really easy to do this.

My methodology is to create public synonyms for the user tables and grant access to the user tables underlying those synonyms.

Example:
User : Tom
Table : Products, PriceList
Purpose : Grant access to user Bob

Here is how to do it:

Create public synonyms for tables Products, PriceList
Normally User Tom sees them as Products and PriceList. Even if you grant access to those tables to user Bob, he still gonna access them as Tom.Products and Tom.PriceList
To allow user Bob to access those tables as Products and PriceList, you must create public synonyms. Public synonyms can be created under SYS so log in to your SQL Worksheet as SYS and type the following:


SET SERVEROUTPUT ON
begin
dbms_output.enable(1000000);
for x in ( select table_name from DBA_ALL_TABLES where owner='TOM' )
loop
dbms_output.put_line('CREATE OR REPLACE PUBLIC SYNONYM ' x.table_name ' FOR Tom.' x.table_name);
EXECUTE IMMEDIATE ('CREATE OR REPLACE PUBLIC SYNONYM ' x.table_name ' FOR Tom.' x.table_name);
end loop;
end;


You will find this piece of source code really useful when you will apply it in a production system with hundreds or thousands of tables.
What it does is apply for every table belonging to user Tom a public synonym which is the name of the table (but ommiting the Tom. part).

Now what you must do is grant access to user Bob on those tables

In the following piece of code i will grant select on a role. It's better to work with roles because they can be easily implemented to a user and then you can customize user rights independently

Here is the source :


SET SERVEROUTPUT ON
begin
dbms_output.enable(1000000);
for x in ( select table_name from DBA_ALL_TABLES where owner='Tom' )
loop
dbms_output.put_line('grant select on ' x.table_name ' to myrole');
execute immediate 'grant select on ' x.table_name ' to myrole';
end loop;
end;


After that, you will assign the role to your user(s) and that's it.

You have granted access to those tables to your second user with a few lines of code.

posted by Admin @ 6:47 PM   1 comments
add to del.icio.us Digg it! Furl this! add to reddit! add to dzone!
About Me

Name: John Galanopoulos
Home: The NeverLands
About Me: A source code wonderer since the early 80s with my first ZX81 by Sinclair, home computer.
See my complete profile
Previous Post
Archives
Links
ΣΚΛΗΡΥΝΣΗ ΚΑΤΑ ΠΛΑΚΑΣ - ΕΓΚΕΦΑΛΟΣ - ΕΓΚΕΦΑΛΟΓΡΑΦΗΜΑ - ΑΝΟΙΑ - ΝΕΥΡΟΛΟΓΟΣ - ΨΥΧΙΑΤΡΟΣ - ΛΟΙΜΩΔΗΣ ΜΟΝΟΠΥΡΗΝΩΣΗ - ΠΑΡΚΙΝΣΟΝ - ΑΓΧΟΣ - ΚΑΤΑΘΛΙΨΗ - ALZHEIMER - EPSTEIN BARR Eurolife
Email notification

Enter your email address and get notified whenever there is a new post:

Delivered by FeedBurner

This website abides by a strict policy : no spam, just posts; and that's a promise.

Powered by

Free Blogger Templates

BLOGGER


Register for a skinnyscore at www.blogskinny.com and increase traffic
Software Blogs -  Blog Catalog Blog Directory

© 2005 Seeking Oracle out of the matrix Template by Isnaini Dot Com