Should I do this with Java Code or Stored Procs ? (for best performance)

Hi All,
I need to decide where should I implement my business logic, in Java code or Stored procs.
Here is the requirement :
- One Order has 70 products (Order_Table )
- Can be duplicate products, so I have to do summarize / grouping by product
- For every product, I have to check, if it is entitled for a Bonus product, then I have to Insert one to Bonus_Table.
- This is done when/after the transaction is SAVED (COMMIT)
The question is, which one has better PERFORMANCE :
(1) Create a rowsetIterator on the Order details (70 products) and call a stored procedure to do the logic for every single product (so that the Insert to Bonus_Table done in stored proc). means the stored proc will be called 70 times.
OR
(2) After the transaction is COMMITted, call the stored procs ONCE to do the logic for all the products at once.
OR
(3) I do all the logic with Java Code within ADF
Given the requirement above, which approach is most efficient / best performance ?
Thank you very much,
xtanto

Problem with this is that you ask 100 people and you probably get 100 different answers. ;o)
Many would say that you push as much business logic into the database with your data; others might say you only put data in your database and your business logic is kept on the application server.
In reality your would probably have a mix of both and your decision would probably be influenced by your own background ...
Can't be more precise than that.
Grant

Similar Messages

  • Does running this command helps sql server 2008 r2 for best performance

    Sir,
    1)DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR)
    2)DBCC FREESYSTEMCACHE ('ALL')
    3)DBCC FREESESSIONCACHE
    4)DBCC FREEPROCCACHE
    5)DBCC DROPCLEANBUFFERS
    If not the commands then what will be best idea to make server Retrieve data from Tables.
    And , retrieving data from stored procedures to dashboarr.
    Please , do me a need full.
    Thanks in advance....

    Sir,
    1)DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR)
    2)DBCC FREESYSTEMCACHE ('ALL')
    3)DBCC FREESESSIONCACHE
    4)DBCC FREEPROCCACHE
    5)DBCC DROPCLEANBUFFERS
    If not the commands then what will be best idea to make server Retrieve data from Tables.
    And , retrieving data from stored procedures to dashboarr.
    Above commands are no where related to retreiving data from procedure above commands will clears your waits stats information stored and also will clear cache plans which as Latheesh pointed out can cause performance issue.New plan needs to be created for each
    new query hitting the database.
    Your question seems misterious to me.
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Problem in printing pdf document with java code

    Hi All
    I want to print a pdf document with java code i have used PDFRenderer.jar to compile my code.
    Code:
    File f = new File("C:/Documents and Settings/123/Desktop/1241422767.pdf");
    FileInputStream fis = new FileInputStream(f);
    FileChannel fc = fis.getChannel();
    ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
    PDFFile pdfFile = new PDFFile(bb); // Create PDF Print Page
    PDFPrintPage pages = new PDFPrintPage(pdfFile);
    // Create Print Job
    PrinterJob pjob = PrinterJob.getPrinterJob();
    PageFormat pf = PrinterJob.getPrinterJob().defaultPage();
    pjob.setJobName(f.getName());
    Book book = new Book();
    book.append(pages, pf, pdfFile.getNumPages());
    pjob.setPageable(book);
    // System.out.println(pjob.getPrintService());
    // Send print job to default printer
    pjob.print();
    but when i am running my program i am getting error
    Exception in thread "main" java.awt.print.PrinterException: Invalid name of PrintService.
    Please anybody, knows the solution for this error?
    Thanks In Advance
    Indira

    It seems that either there is no default printer setup or you have too many printers or no printer setup at all. Try running the following code. It should print the list of available print services.
    import java.awt.print.*;
    import javax.print.*;
    public class PrintServiceNames{
         public static void main(String args[]) throws Exception {
              PrintService[] printServices = PrinterJob.lookupPrintServices();
              int i;
              for (i = 0; i < printServices.length; i++) {
                   System.out.println("P: " + printServices);
    }From the list pick one of the print service names and set it explicitly like "printerJob.setPrintService(printServices);" and then try running the program.

  • I have problem in this unzip java codes

    hi all,I have problem in this unzip java codes,I think either the pathway that i put C:.......is wrong or the codes are wrong because when i run it, the zipped folder is not unzipped. So anyone has another set of example or know how to correct it? Thanks!Please post the solution here!
    This is the set of codes that i have:
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    public class Unzip {
    public static final void copyInputStream(InputStream in, OutputStream out)
    throws IOException
    byte[] buffer = new byte[1024];
    int len;
    while((len = in.read(buffer)) >= 0)
    out.write(buffer, 0, len);
    in.close();
    out.close();
    public static final void main(String[] args) {
    Enumeration entries;
    ZipFile zipFile;
    if(args.length != 1) {
    System.err.println("Usage: Unzip zipfile");
    return;
    try {
    zipFile = new ZipFile("C:\\Temp\\FolderZiper.zip");
    entries = zipFile.entries();
    while(entries.hasMoreElements()) {
    ZipEntry entry = (ZipEntry)entries.nextElement();
    if(entry.isDirectory()) {
    // Assume directories are stored parents first then children.
    System.err.println("Extracting directory: " + entry.getName());
    // This is not robust, just for demonstration purposes.
    (new File(entry.getName())).mkdir();
    continue;
    System.err.println("Extracting file: " + entry.getName());
    copyInputStream(zipFile.getInputStream(entry),
    new BufferedOutputStream(new FileOutputStream(entry.getName())));
    zipFile.close();
    } catch (IOException ioe) {
    System.err.println("Unhandled exception:");
    ioe.printStackTrace();
    return;
    }

    What does the program output when it's executed? Can you copy the screen and post it here? More info can help solve the problem.
    What exactly is the program supposed to do?
    Add some more println() to show the program flow and what the values of key variables are. For example what is in entries after the entries() method is executed?
    Some prep work on your part would make it easier for us to help.

  • Do you know how to call RDF with java code?

    Say me a tip!
    Environment:
    Linux, Reports 6i,java beans, jsp
    My mission is to run a report with java code.
    But I don't know how to.
    Basic flow is :
    On web browser, call jsp a program and
    that jsp call a java module,
    and the java module call a reports RDF with parameters
    I don't need reponse message from rwcgi60 or rwrun60.

    hello,
    the easiest way is to use the regular HTTP request to either the servlet or the CGI to run a report request from within a java-class.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                       

  • DAG - Backup failing on 1 DB only with error - The Microsoft Exchange Replication service VSS Writer instance ID failed with error code 80070020 when preparing for a backup of database 'DB012'

    Hi Board,
    i´ve search across the board, technet and symantec sites but did not found a hint about my problem.
    we drive a 2 node DAG (Location1-Ex1-mb1 
    Location2-exc1-mb1), on SP2 RU4 patchlevel with 40 Databases.
    Since some time the backup of one - and only one DB - is failing with these events, logged on the Mailboxserver on which the passive DB is hosted.
    Log Name:      Application
    Source:        MSExchangeRepl
    Date:          28.09.2012 00:37:17
    Event ID:      2112
    Task Category: Exchange VSS Writer
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      Location1-Exc1-MB1
    Description: The Microsoft Exchange Replication service VSS Writer instance 1ab7d204-609a-4aea-b0a7-70afb0db38de failed with error code 80070020 when preparing for a backup of database 'DB012'.
    Followed by
    Log Name:      Application
    Source:        MSExchangeRepl
    Date:         
    01.10.2012 03:33:06
    Event ID:      2024
    Task Category: Exchange VSS Writer
    Level:         Error
    Keywords:      Classic
    User:         
    N/A
    Computer:      Location1-Exc1-MB1
    Description:
    The Microsoft Exchange Replication service VSS Writer (Instance 42916d80-36c1-4f73-86d0-596d30226349) failed with error 80070020 when preparing for a backup.
    The backup Application - Symantec Backup Exec 2010 R3 – states, this error
    Snapshot provider error (0xE000FED1): A failure occurred querying the Writer status.
    Check the Windows Event Viewer for details.
    Writer Name: Exchange Server, Writer ID: {76FE1AC4-15F7-4BCD-987E-8E1ACB462FB7}, Last error: The VSS Writer failed, but the operation can be retried (0x800423f3), State: Stable (1).
    Symatec suggests within http://www.symantec.com/business/support/index?page=content&id=TECH184095
    to restart the MS Exchange Replication Service – BUT the mentioned eventID
    8229 isn´t present on any of the both Mailboxservers.
    The affected Database is active on Location2-Exc1-Mb1 Server and in an overall healthy state. I found during my research, that below Location2-Exc1-Mb1 Server, there are not removed shadow copies present!
    This confuses me, since all Backups are normally taken from the passive copy of a Database.
    So my questions to the board are:
    * Does anyone is facing similar issues?
    * Can someone explain why snapshots are present on the Mailboxserver hosting the Active Database, whilst the errors are logged on the passive one?
    -          * Does someone know the conditions, why shadows copies remain and
    aren´t removed in a proper manner?
    What can cause the circumstance, that only 1 DB is facing such issues?
    Any suggestion is welcome!
    BR
    Markus

    Hi Lenora,
    I´ve encreases VSS / Exchange Backup Log levels to expert, before starting
    those things i´ve all tried now:
    - Backup from passive DB (forced within Symantec Backup Exec)
    - Backup from active DB (forced within Symantec Backup Exec)
    - Backup from passive DB without GRT enabled (forced within Symantec Backup Exec)
    - Backup from active DB without GRT enabled(forced within Symantec Backup Exec)
    All those attempts failed.
    But brought some more details - the backup against the active DB states, that there is still a backup in progress and therefore this backup is cancelled by VSS.
    The Solution was, that i´ve needed to restart the Exchange Replication Service on the Mailbox Server hosting the passive DB.
    Backups are working again on all DBs!
    THX for your replys.
    Best regards
    Markus

  • How do I access "Firefox is NOT compatible with this application. For best performance, please use Internet Explorer 5.0 and above...." web sites; when I try to download any alternate browser, then a warning that alternate is "imcompatable with your opera

    How do I access websites that warn: "Firefox is NOT compatible with this application. For best performance, please use Internet Explorer 5.0 and above...."? When I try to download any alternate browser, all I get is another warning that the alternate is "not compatible with your operating system." Is Firefox preventing this? The site listed below is a job application site. I've had this same problem with other job application sites also.
    == URL of affected sites ==
    https://storefront.kenexa.com/lithia/cc/Home.ss

    There should be a User Agent Switcher menu item under Tools, which gives you the browser names you can impersonate.
    The menu item name changes to the browser UA you are presently using.
    There is also a User Agent Switcher button, you can add it using View -> Toolbars -> Customize, and dragging the button to your toolbar.
    See http://chrispederick.com/work/user-agent-switcher/features/ and http://chrispederick.com/work/user-agent-switcher/help/
    You can just start trying IE versions (or the versions it says on the site) until it lets you in.

  • Can the 128 GB SSD part of a fusion drive be replaced with a 960 GB SSD dive for greater performance and added storage?

    Can the 128 GB SSD part of a fusion drive be replaced with a 960 GB SSD dive for greater performance and added storage in a 2012 mac mini?

    First, I suspect Apple fine tuned its choice of SSD size for the Fusion drive based on the best performance/price ratio. I'd be surprised if a larger SSD provided any improvement that would justify the added price of a larger SSD.
    Second, if I could justify the cost of a 960 SSD drive I wouldn't bother with a Fusion drive!

  • How to display pdf file with java code?

    Hi All,
    i have a jsp pagein that page if i click one icon then my backing bean method will call and that method will create pdf document and write some the content in that file and now i want to display that generated pdf document.
    it should look like you have pressed one icon and it displayed pdf file to you to view.
    java code below:
    FacesContext fc = FacesContext.getCurrentInstance();
    ExternalContext ec = fc.getExternalContext();
    HttpServletResponse resp = (HttpServletResponse) ec.getResponse();
    resp.setHeader("Content-Disposition", "filename=\"" + temppdfFile);
    resp.encodeRedirectURL(temppdfFile.getAbsolutePath());
    resp.setContentType("application/pdf");
    ServletOutputStream out = resp.getOutputStream();
    ServletUtils.returnFile(temppdfFile, out);
    out.flush();
    and above temppdfFile is my generated pdf file.
    when i am executing this code, it was opening dialog box for save and cancel for the file, but the name of the file it was showing me the "jsp file name" with no file extention (in wich jsp file i am calling my backing bean method) and type is "Unknown File type" and from is "local host"
    it was not showing me open option so i am saving that file then that file saved as a pdffile with tha name of my jsp file and there is nothing in that file(i.e. empty file).
    what is the solution for this. there is any wrong in my code.
    Please suggest me.
    Thanks in advance
    Indira

    public Object buildBarCodes() throws Exception
    File bulkBarcodes = null;
    String tempPDFFile = this.makeTempDir();
    File tempDir = new File("BulkPDF_Files_Print");
    if(!tempDir.exists())
    tempDir.mkdir();
    bulkBarcodes = File.createTempFile
    (tempPDFFile, ".pdf", tempDir);
    //bulkBarcodes = new File(tempDir, tempPDFFile+"BulkBarcode"+"."+"pdf");
    if(!bulkBarcodes.exists())
    bulkBarcodes.createNewFile();
    Document document = new Document();
    FileOutputStream combinedOutput = new FileOutputStream(bulkBarcodes);
    PdfWriter.getInstance(document, combinedOutput);
    document.open();
    document.add(new Paragraph("\n"));
    document.add(new Paragraph("\n"));
    Image image = Image.getInstance(bc.generateBarcodeBytes(bc.getBarcode()));
    document.add(image);
    combinedOutput.flush();
    document.close();
    combinedOutput.close();
    FacesContext facesc = FacesContext.getCurrentInstance();
    ExternalContext ec = facesc.getExternalContext();
    HttpServletResponse resp = (HttpServletResponse) ec.getResponse();
    resp.setHeader("Content-Disposition", "inline: BulkBarcodes.pdf");
    resp.encodeRedirectURL(bulkBarcodes.getAbsolutePath());
    resp.setContentType("application/pdf");
    resp.setBufferSize(10000000);
    ServletOutputStream out = resp.getOutputStream();
    ServletUtils.returnFile(bulkBarcodes, out);
    out.flush();
    return "success";
    This is my action method which will call when ever i press a button in my jsp page.
    This method will create the barcode for the given barcode number and write that barcode image in pdf file
    (i saw that pdf file which i have created through my above method, This PDF file opening when i was opening manually and the data init that is also correct means successfully it writes the mage of that barcode)
    This method taking the jsp file to open because as earlier i said it was trying to open unknown file type document and i saved that file and opended with editplus and that was the jsp file in which file i am calling my action method I mean to say it was not taking the pdf file which i have created above it was taking the jsp file

  • OIM should send spmlv2 requests via java code to service provider

    Hi,
    We have the situation in which OIM acts as Requesting authority,Spml provider acts as service provider.
    Oim should send spml requests from custom java code.Spml2Client is used.We are not using genericc technology connector.
    Require sample java code for Search operation.
    I had done for modify request.
    The request and response is as follows
    PSO ID returned after searching: org.openspml.v2.msg.spml.PSOIdentifier@5c32a864
    <deleteRequest xmlns='urn:oasis:names:tc:SPML:2:0' recursive='false'/>
    <deleteResponse xmlns='urn:oasis:names:tc:SPML:2:0' status='success'/>
    <modifyRequest xmlns='urn:oasis:names:tc:SPML:2:0' returnData='identifier'>
    <psoID ID='cn=TPS User8,ou=TPS,dc=fosterstechodc,dc=com'/>
    <modification modificationMode='replace'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='otherHomePhone' operation='replace'>
    <dsml:value>999999</dsml:value>
    </dsml:modification>
    </data>
    </modification>
    <modification modificationMode='delete'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='description' operation='delete'>
    </dsml:modification>
    </data>
    </modification>
    <modification modificationMode='add'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='firstname' operation='add'>
    <dsml:value>Barbara</dsml:value>
    </dsml:modification>
    </data>
    </modification>
    </modifyRequest>
    SpmlClient: sending to http://10.101.151.209/ARServerSPML/SPMLProvider.asmx
    <modifyRequest xmlns='urn:oasis:names:tc:SPML:2:0' returnData='identifier'>
    <psoID ID='cn=TPS User8,ou=TPS,dc=fosterstechodc,dc=com'/>
    <modification modificationMode='replace'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='otherHomePhone' operation='replace'>
    <dsml:value>999999</dsml:value>
    </dsml:modification>
    </data>
    </modification>
    <modification modificationMode='delete'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='description' operation='delete'>
    </dsml:modification>
    </data>
    </modification>
    <modification modificationMode='add'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='firstname' operation='add'>
    <dsml:value>Barbara</dsml:value>
    </dsml:modification>
    </data>
    </modification>
    </modifyRequest>
    SpmlClient: received
    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><modifyResponse status="failure" xmlns="urn:oasis:names:tc:SPML:2:0"><error>malformedRequest</error><errorMessage>At least one &lt;modification&gt; element must be specified.</errorMessage></modifyResponse></soap:Body></soap:Envelope>
    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><modifyResponse status="failure" xmlns="urn:oasis:names:tc:SPML:2:0"><error>malformedRequest</error><errorMessage>At least one &lt;modification&gt; element must be specified.</errorMessage></modifyResponse></soap:Body></soap:Envelope>
    org.openspml.v2.util.Spml2ExceptionWithResponse: At least one <modification
    The response says the modifaction tag is not present.
    The code for this request is
    Modification[] modifications =
                   { newModWithDSMLMod("otherHomePhone", "999999", ModificationMode.REPLACE),
                             newModWithDSMLMod("description", null, ModificationMode.DELETE),
                             newModWithDSMLMod("cn", "Barbara", ModificationMode.REPLACE)};
                   modifyResp = customSPMLClient.modifyUser(client,searchPSOId,modifications);
    method:
    public ModifyResponse modifyUser(Spml2Client client,PSOIdentifier psoId,Modification[] modifications) throws Exception {
              client.setTrace(true);
              ReflectiveXMLMarshaller marshaller = new ReflectiveXMLMarshaller();
              ModifyRequest modReq = new ModifyRequest(null, // String requestId,
                        null, // ExecutionMode executionMode,
                        psoId, // PSOIdentifier psoID
                        modifications, // Modification[] modifications
                        ReturnData.IDENTIFIER // ReturnData returnData
              System.out.println(modReq.toXML(marshaller));
              ModifyResponse modResp = (ModifyResponse) client.send(modReq);
              System.out.println(modResp.toXML(marshaller));
              return modResp;
    private static Modification newModWithDSMLMod(String modName, String modValue, ModificationMode modMode)
         throws DSMLProfileException
              /*DSMLModification dsmlMod = null;
              dsmlMod = new DSMLModification(modName, modValue, modMode);
              Extensible data = new Extensible();
              data.addOpenContentElement(dsmlMod);
              Selection component = null;
              return new Modification(component, data, null, modMode);
    Please help me out.
    I need sample java code for search operation tooo.
    regards,
    Sindhu.M

    the sample JAVA codes are provided for sending SPML requests, HTTPClient and one more (i dont remember rite now) within the OIM installation folders itself. It's in the 'SampleHttpClient' folder. Check it once. WSDL, sample XML's and the JAVA codes all are there. You just need to set the classpath and run it.
    - oidm.

  • Split XML in Multiple XML files with Java Code

    Hi guys , i have following xml file as input ....
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <T0020
    xsi:schemaLocation="http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.safersys.org/namespaces/T0020V1">
    <INTERFACE>
    <NAME>SAFER</NAME>
    <VERSION>04.02</VERSION>
    </INTERFACE>
    <TRANSACTION>
    <VERSION>01.00</VERSION>
    <OPERATION>REPLACE</OPERATION>
    <DATE_TIME>2009-09-01T00:00:00</DATE_TIME>
    <TZ>CT</TZ>
    </TRANSACTION>
    <IRP_ACCOUNT>
    <IRP_CARRIER_ID_NUMBER>274845</IRP_CARRIER_ID_NUMBER>
    <IRP_BASE_COUNTRY>US</IRP_BASE_COUNTRY>
    <IRP_BASE_STATE>AR</IRP_BASE_STATE>
    <IRP_ACCOUNT_NUMBER>55002</IRP_ACCOUNT_NUMBER>
    <IRP_ACCOUNT_TYPE>I</IRP_ACCOUNT_TYPE>
    <IRP_STATUS_CODE>100</IRP_STATUS_CODE>
    <IRP_STATUS_DATE>2007-11-06</IRP_STATUS_DATE>
    <IRP_UPDATE_DATE>2009-08-03</IRP_UPDATE_DATE>
    <IRP_NAME>
    <NAME_TYPE>LG</NAME_TYPE>
    <NAME>A P SUPPLY CO</NAME>
    <IRP_ADDRESS>
    <ADDRESS_TYPE>PH</ADDRESS_TYPE>
    <STREET_LINE_1>1400 N OATS</STREET_LINE_1>
    <STREET_LINE_2/>
    <CITY>TEXARKANA</CITY>
    <STATE>AR</STATE>
    <ZIP_CODE>71854</ZIP_CODE>
    <COUNTY>MILLER</COUNTY>
    <COLONIA/>
    <COUNTRY>US</COUNTRY>
    </IRP_ADDRESS>
    <IRP_ADDRESS>
    <ADDRESS_TYPE>MA</ADDRESS_TYPE>
    <STREET_LINE_1>P O BOX 1927</STREET_LINE_1>
    <STREET_LINE_2/>
    <CITY>TEXARKANA</CITY>
    <STATE>AR</STATE>
    <ZIP_CODE>75504</ZIP_CODE>
    <COUNTY/>
    <COLONIA/>
    <COUNTRY>US</COUNTRY>
    </IRP_ADDRESS>
    </IRP_NAME>
    </IRP_ACCOUNT>
    <IRP_ACCOUNT> ..... </IRP_ACCOUNT>
    <IRP_ACCOUNT> ..... </IRP_ACCOUNT>
    <IRP_ACCOUNT> ..... </IRP_ACCOUNT>
    </T0020>
    and i want to take this xml file and split it into multiple files through java code like this ...
    File1.xml
    <T0020>
    <IRP_ACCOUNT> ..... </IRP_ACCOUNT>
    <IRP_ACCOUNT> ..... </IRP_ACCOUNT>
    </T0020>
    File2.xml
    <T0020>
    <IRP_ACCOUNT> ..... </IRP_ACCOUNT>
    <IRP_ACCOUNT> ..... </IRP_ACCOUNT>
    </T0020>
    like wise...
    Each xml file contain maximum 10 or 15 IRP_ACCOUNT.
    Can somebody please help me ? How can i do it with stax like start element and all ?
    thanks in advance.

    Ah, sorry, strike that. You want multiple files. I think the easiest way is to simply parse with DOM. [http://www.w3schools.com/xpath/default.asp] . And here [http://www.w3schools.com/xpath/default.asp].
    You can output the various XML elements using a PrintWriter or creating a separate DOM document for each file you want to create and serializing that.
    - Saish

  • Hi I have a geometry problem.Can anyone help with java code

    Hi I have a non simple polygon . My job is to make it a simple. for that First I need to find the intersecting lines say line AB intersects line CD. If so then I must replace AB & CD with AC & BD or AD or BC which ever keeps the polygon closed . So can anyone help me out with this code
    import java.io.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class Simple{
    static int POINTWID = 4; // size of points
    // the x and y arrays hold the coordinates
    // the B array is the order of the points in the polygon
    // You want to fill the C array with the simple polygon
    static double x[] = new double[200];
    static double y[] = new double[200];
    static int B[] = new int[200]; // the permutation matrix
    static int C[] = new int[200]; // the one that becomes simple
    static SimpleFrame myFrame;
    static int numPoints = 3;
    public static void main(String args[]) {
    makePolygons();
    // Create the frame to draw on
    myFrame = new SimpleFrame();
    myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    myFrame.setSize(600, 600);
    myFrame.setVisible(true);
    public static void makePolygons(){
    // Build an array of random points in the unit square
    for(int i = 0; i < numPoints; i++){
    x[i] = Math.random();
    y[i] = Math.random();// Sample program
    B[i] = i; // default permutation
    // Create the simple polygon
    createSimplePolygon();
    * This is the only function you need to mess with
    public static void createSimplePolygon(){
    // Initialize the C[] array with the identity permutation
    for(int i = 0; i < numPoints; i++)
    C[i] = i;
    // Bubble sort the points from left to right
    for(int i = 0; i < numPoints; i++)
    for(int j = 0; j < numPoints - 1; j++)
    if(x[C[j]] > x[C[j+1]]){
    int temp = C[j];
    C[j] = C[j+1];
    C[j+1] = temp;
    public static class SimpleFrame extends JFrame{
    public static JSlider numPointsSlider;
    public SimpleFrame()
    super("Create you own Simple Polygon");
    Container content = getContentPane();
    content.setLayout(new java.awt.BorderLayout());
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.setPreferredSize (new java.awt.Dimension(300, 400));
    tabbedPane.addTab("Scrambled", new ScrambledPanel());
    tabbedPane.addTab("Simple", new SimplePanel());
    content.add(tabbedPane, java.awt.BorderLayout.CENTER);
    // Slider for the number of points
    numPointsSlider = new JSlider (javax.swing.SwingConstants.HORIZONTAL,
    3, 100, 11);
    numPointsSlider.addChangeListener (new javax.swing.event.ChangeListener () {
    public void stateChanged (javax.swing.event.ChangeEvent evt) {
    numPointsSliderStateChanged (evt);
    content.add(numPointsSlider, java.awt.BorderLayout.SOUTH);
    private void numPointsSliderStateChanged (javax.swing.event.ChangeEvent evt) {
    numPoints = numPointsSlider.getValue();
    makePolygons();
    repaint();
    public static class ScrambledPanel extends JPanel{           
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    // First set the scaling to fit the window
    Dimension size = getSize();
    int Xwid = (int) (0.95 * size.width);
    int Ywid = (int) (0.95 * size.height);
    // First draw the segments
    g2.setColor(Color.red);
    for(int i = 0; i < numPoints; i++)
    g2.drawLine((int) (Xwid * x[B[i]]),
    (int) (Ywid * y[B[i]]),
    (int) (Xwid * x[B[(i+1) % numPoints]]),
    (int)(Ywid * y[B[(i+1) % numPoints]]));
    // Now draw the points
    for(int i = 0; i < numPoints; i++){
    g2.fillRect((int) (Xwid * x) - POINTWID,
    (int) (Ywid * y[i]) - POINTWID,
    2*POINTWID + 1, 2*POINTWID + 1);
    public static class SimplePanel extends JPanel{
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    // First set the scaling to fit the window
    Dimension size = getSize();
    int Xwid = (int) (0.95 * size.width);
    int Ywid = (int) (0.95 * size.height);
    // First draw the segments
    g2.setColor(Color.red);
    for(int i = 0; i < numPoints; i++)
    g2.drawLine((int) (Xwid * x[C[i]]),
    (int) (Ywid * y[C[i]]),
    (int) (Xwid * x[C[(i+1) % numPoints]]),
    (int)(Ywid * y[C[(i+1) % numPoints]]));
    // Now draw the points
    for(int i = 0; i < numPoints; i++){
    g2.fillRect((int) (Xwid * x[i]) - POINTWID,
    (int) (Ywid * y[i]) - POINTWID,
    2*POINTWID + 1, 2*POINTWID + 1);

    Hi I am sorry I could explain you properly . Ok
    My program gives me a polygon(as you can see when u
    run this program)But the polygon is a non simple
    polygon.So to make this polygon we must remove all
    the crossings betweeen edges in the polygon.The
    algorithm which i gave will remove all the crossings
    and make the polygon simple.You did not give an algorithm!
    SO my job is to take the
    existing code and implement the algorithm for this
    program in the Createsimpelpolygon() function. For
    this First the program must find whether two edges
    cross if they cross then swap the vertices like
    replace AB & CD with AC & BD or AD & BC.Which ever
    keeps the polygon closed . Still not entirely clear to me. You cannot just go and replace vertexes from a polygon: that way you'll end up with a different polygon.
    So as we go on we find the
    many crossings and iterate the algorithm on all the
    crossings until we get simple polygon.Like I said: I don't really understand what it is you're after. You did not respond to my suggestions, so I gather it is not what you're after?
    What about Polygon Tessellation (Google for it)? Perhaps that's what you want.
    Also, why do you not create a (or use java.awt's) Point class and a Polygon class which holds a java.util.Set of Point's? Your current code looks rather messy.

  • How to lunch Java Console with java code?

    Hi all,
    I have an application which runs using JWS, everything is fine (running during 3 years), but sometimes an unexpected Exception happens, and my client doe not have the Java Console Activated to show (in Windows Control Panel).
    What I want to do is:
    set in the java code to whenever Exceptions occur the Java Console shows up and he (the client) can see and send me the Error Exception.
    Does anybody know how can I set that in my code?
    Thanks.

    Just some using XML, I dont want to use XML
    configuratio.You don't need to use XML for log4j configuration. Log4j properties are set in a .properties file.
    But it sounds like you should build your own logging framework where for every exception that occurs you call the framework and then it will display the exception and stack trace in a dialog box and proceed to email the exception to an email list specified within a property file.

  • How can I achieve this with less code or faster?

    Hi Folks,
    I have 2 database tables, 'products' and 'products_staging'.
    Every day, the 'products_staging' table is updated with a fresh
    batch of products (which are imported from xml files in a seperate
    process using Navicat software). I need to somehow compare this
    database with the 'products' database to look for specific changes
    - i.e changes in price, deleted products, or new products. As some
    of the fields in the 'products' database are manually altered, such
    as the product name, I cannot do a straight sync with them.
    Therefore, I use the only field that will remain unchanged as the
    comparison field.
    The somewhat crude method I have come up with is to loop
    through the 'products_staging' table, looking for that specific
    field against the 'products' table. If it finds it, it then checks
    for a change in the price field (i.e has the price of that product
    changed). If there is a change, the 'products' table is updated.
    Likewise, if it's not found, it's treated as a new product and
    inserted as such and so on. At the end of the loop, the record is
    deleted from the 'products_staging' table - therefore at the end of
    the process, the table is empty ready for the next import the
    following day.
    At the moment, the database handles around 300,000 rows - but
    at some point I'm likely to be dealing with many more than that.
    It's working as it is, but taking a considerable time to do so -
    around 4 hours to go through the lot.
    Any suggestions on a better way of accomplishing this? My
    existing crude code is pasted below (the use of maxrows and the
    redirect is to prevent time-outs - parse2.cfm is virtually
    identical to this);

    Firstly, if possible, get the DBs to talk to each other
    without involving
    CF. That will just be slowing things down. CF's for
    generating HTML
    pages, and whilst it CAN interact with databases, it's not
    the best tool
    for the job.
    If that's not possible, use CF as a bridge between them, but
    only to bulk
    insert all the staging data into a temporary table (either
    literally a
    temporary table, or a permanent one used for holding data
    temporarily ;-)
    on the production DB, and then use a DB procedure to process
    all the data,
    again using only the DB server to do so.
    Lastly, if you MUST use CF to do the data manipulation, then
    minimise your
    hits to the DB. Instead of doing single hits to the
    production DB in your
    prodconnect query, get ALL the data you're likely to need for
    updates in
    one hit, then use CF to generate a payload for a bulk update;
    similarly any
    missing data from production can be inferred from that the
    difference
    between the staging and update data, and that can be used as
    your source of
    payload for a bulk insert.
    As a rule of thumb, if I find myself needing to perform
    single-row queries
    within a loop of another query, I start thinking I'm doing
    something wrong.
    Oh, yeah: when dealing with large amounts of queries like
    that, ALWAYS use
    <cfqueryparam> tags instead of static SQL strings.
    Every non-parameterised
    query you pass to the DB engine will need to be compiled
    first, and then
    it's also cached. Which slows you down, and eats memory on
    the DB server.
    This will leave the problem that you're not going to be
    generating your
    report as you go. However I imagine that's a "nice to have"
    compared to
    ensuring the thing actually works. You can generate your
    report
    separately, after the data processing has been done. I'm
    fairly certain
    you would be able to coerce a log out of the DB server,
    somehow, anyway.
    Adam

  • Technology P2P with JAVA (How can i do for implement this tech with JAVA B)

    Thanks for read this message,,, I will glad with you if you can help me...
    I would like desing, make, build, a point to point aplication with JAVA Builder, I have been reading about sockets but its not enought,,,,,,
    can you help me????
    Thanks

    Well , thanxs for take attention,,,
    I need some information about Point to Point tech because I would like to make an aplication with JAVA Builder...
    First step is to know how works the point to point...could you give me some links?
    Second step is to know how can I do for implement this tech?
    Third step is to know Is Java Builder the most indicate languaje for this aplication?
    Fourth step is - if Java Buider is the indicate tool, What have to know for make the aplication?
    Well,,I dont speak english very well but is the best that i can do?
    BYE

Maybe you are looking for

  • Sales order with reference to Service Notification

    Hi Freinds, I have to create a sales order with reference to Service notification (IW51). can someone sugggest me BAPI or Function module to perform this task. Appriciate your help. Best regards Pravin

  • Probelm checkin in a folder with content categorizer

    Hello all After i started to work with content categorizer i can no longer check in a folder (log will be attached in the next message) This happen when i add the component that allow the content categorizer to check in automatically, when i remove t

  • Can I verify a field-symbol using its component name?

    Hello experts, I am looping at my field-symbol and I need to know what are its component name. I need to create an IF or CASE statement checking whether the field-symbol's component name is equal to that of the value that I declared. I want to do som

  • Mapping of different SAP Clients

    Sir I would like to know that My Company A (SAP system) would like to buy New Company B (which is also SAP ) and Company C (Non-SAP) , we would like to integrate all these systems  to get consolidated information ( especially financial information  )

  • Import dvd-ram video data into version 11

    I work with a mac mini and the external super drive. The importer window does not show the drive. Older posts recommend to use an internal drive, but of course ALL mac mini ONLY have external drives. When I transfer the data to hard disk it is also n