Problem with a small code

Hello , Can anyone plz tell me how do i get this output from this sample code ? im new to java...
public class Fact2
int factorial (int n) {
int res;
System.out.println(n);
if (n == 1) return 1;
res = factorial (n - 1) * n ;
System.out.println("res " + res);
return res;
public static void main (String [] args) {
Fact2 f= new Fact2();
System.out.println("The factorial of this number is " + f.factorial(5));
The output is :
C:\Documents and Settings\AM>java Fact2
5
4
3
2
1
res 2
res 6
res 24
res 120
The factorial of this number is 120
Here , from 5 to 1 is understood and also the last phrase of course , but from where did the variable "res" have these values 2,6,24 ....

2: int factorial (int n) {
3: int res;
4: System.out.println(n);
5: if (n == 1) return 1;
6: res = factorial (n - 1) * n ;
7: System.out.println("res " + res);
8: return res;
9: }
When you call factorial(5) this will happen:
It prints 5 (line 4)
It calls factorial(4) (line 6) - (and waits for it result!!!!!)
factorial(4) shall print 4, and calls factorial(3)
prints 3, calls factorial(2)
prints 2, calls factorial(1)
prints 1, returns 1returns from factorial(1), multiplies it by 2 (line 6), result = 2
prints the result to the screen (line 7)
returns the result (line 8) (thus 2)multiplies the result of factorial(2) with 3 (line 6), result = 6
prints this result, and returns itmultiplies the result of factorial(3) with 4, result = 24
prints this result, and returns itmultiplies the result of factorial(4) with 5, result = 120
prints this result and returns itHope this get things clear to you

Similar Messages

  • Problem with my exe code

    Hello,
    I have a small problem regarding to my code. I have attached the source code. There isn't any problem with the vi code. But when I convert the vi to exe, and double click the exe file in order to open it , the program is trying to start, I mean it is acting like I clicked the run button. I said it is not a problem, because all the values (test duration, delay duration, high limit, low limit) are zero. Therefore it is attempting to run, but only very small portion of the pressure reading occurs. What do you think about the cause of this problem? Thanks for your help.
    Ahmet
    Attachments:
    front panel1.jpg ‏47 KB
    Oksijen_Atolyesi.vi ‏45 KB

    Hi Ahmet,
    when duration and delay are zero, the your DAQ loop will (probably) run only once, thus giving you only small amount of data...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    Oksijen_Atolyesi.vi ‏35 KB

  • Hello, i have a problem with this number code  213:19,  please help me!

    Hello, i have a problem with this number code  213:19,  please help me!

    dan
    What version of Premiere Elements and on what computer operating system is it running?
    If you are using Premiere Elements 13, have you updated it to 13.1 yet? If not, please do so using an opened project's Help Menu/Updates.
    What type of user account are you using....local administrator or domain type?
    Please review the following Adobe document on the 213.19 issue. Have you read that already?
    Error 213:19 | Problem has occurred with the licensing of this product
    ATR

  • Office Home and Student 2010 Install problems with a Key Code Err..

    I had to install a new hard drive, lost everything..So I upgraded to Windows 7 Professional ..
    I own a the 2010 Home and Student CD bought at the Microsoft store...Doesn't come with Outlook...
    So I ordered the Home and Business 2010 disc with Service Pack 1 Included, this has 2010 outlook ...It loaded and worked fine up to the point I had to replace my Drive with New Windows 7 Pro...
    Everything loaded find, but every time I try and use it, its acts like it is caught in some kind of loop...It keep trying install and configure, then ask for my Key Code every time, sort of like a OLMAP132.Dll err...I did manage to make it work once, I even
    got back the test email from Microsoft after setting up Outlook....Then when I rebooted the system, this same loop action started ...
    I have uninstalled this at least 4 times, searched for anything with ties to Microsoft office, and uninstalled it..Then did a New Clean Install...Still getting this key Code question every time I open up a Office program....So, I am saying without a doubt,
    2010 Office Home and Student and Business WILL NOT RUN on Windows 7 professional ......If you have any idea how to fix this..Please respond with facts on how to repair this please....

    Greta,,,After down loading ( Off Cat ) tools...I saved that program...However, there is another major problem with Your Instructions I ran into...It seems I'm not the trusted source to change files such as the Mapi32.dll files..So I was unable to attempt
    your repair ...However I have found instructions for the task, but it seems very complicated for sure.. Here are the instructions, and I  would like for you and maybe a co-worker to check these.. before I make any changes in system..
    How to Change the Trusted Installer name...
    1. Right Click on the File Or directory.
    2.Click On properties, on the Right Click menu.
    3.Click On "" Security "" tab
    4.Click On " Advanced" Button on the bottom.
    5.In the advance Security Dialog Window, Click on "" Owner "" tab
    6.Here you will able to see the Current Owner ( ie: Trusted Installed )
    7. To take owner ship of the object, click on the Edit button, Give permission to UAC , the highlight the user name in the " Change Owner To" box that you want to assign as the owner for the object. Then Click " OK " to finish the process.
    8.Back in the Advanced Security Settings Window , You will see the current owner has changed to the user you just selected.
    9.Click the ""OK "" and exit this window.
    10. Click "'OK"" again, to exit completely from the Properties window..
    11. Repeat Step 1 to 4 to open the object's Properties Window again...
    12.Back in Object's Properties window, click on the edit button , and confirm the UAC elevation request.
    13. Highlight the Administrators in the " group of users names"" box. If the user ID or group that you want to manage the permissions for the object doesn't exist, Click on.."" Add"" button, and type in the user name or
    group name desired into the "" Enter Object names to select ( can use Everyone as user Name)" box and finish off by clicking on the "" OK""
    14. In the permissions for Administrators box below ( or any other user name or group name you choose). click on ""Full Control"" under the ""Allow"" column to assign full access rights control permission to Administrator's
    group....
    http//windows.microsoft.com/en-us/windows-vista/troubleshoot-access-denied-when opening-files-or-folders.

  • Problem with PHP, CSS & Code Navigator in CS4

    Hi,
    I've got al little problem with code navigator. To show the problem, I created this 3 files:
    test1.html
    The CSS-Definition is defined static, with simple HTML.
    <html>
    <head>
         <style type="text/css">
              @import "test.css";
         </style>
    </head>
    <body>
          <p>Hello World</p>
    </body>
    </html>
    test2.php
    The CSS-Definition is defined dynamic, with PHP-Code.
    <html>
    <head>
         <style type="text/css">
              <? echo "@import \"test.css\";\n"; ?>
         </style>
    </head>
    <body>
          <p>Hello World</p>
    </body>
    </html>   
    test.css
    The CSS-File which is imported in test1.html and test2.php
    p {
         font-size:20px;
    The Problem in Dreamweaver CS4
    When opening the test.html - File in Dreamweaver CS4, I can easily see the CSS-Definition of the <p>-Tag in Code Navigator. To edit these definition I can simple open the test.css by clicking on the definition in Code navigator. For a complex webpage this is a greate feature. Sadly, this does not work, when I open the test2.php. Although when going to Live View and selecting the <p>-Tag I can see the CSS-Definition and the file in which it is defined in Code Navigator. But by clicking on the definition the test.css DOES NOT OPEN!
    Has anybody a solution? Because many of our projects have dynamic CSS-Definitions, it would be a shame, if this would not work.
    Tanks for help! :-)

    I've done some testing, which might point you in the direction of an interim solution.
    This is the code for related_files.php:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Related files test</title>
    <?php include('include.css'); ?>
    </head>
    <body>
    <p>This is a paragraph.</p>
    </body>
    </html>
    This is the code for include.css:
    <style type="text/css">
    p {
         font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
         color:#F00;
    </style>
    Note that the include file contains the opening and closing style tags.
    By including your styles like this in a PHP include file, Dreamweaver applies the CSS in Design view (you don't need to turn on Live View). Holding down the Alt key while clicking in Design view brings up the Code Navigator with all the details of the CSS. The one missing link in the chain is that clicking the style selector in the Code Navigator does not open the CSS file. However...
    The file that contains the CSS is listed in the Related Files toolbar, so you can edit it in Split view, and see the results in Design view in exactly the same way as with an HTML page and ordinary style sheet.
    As I say, not the full solution that you wanted, but it might be something worth experimenting with.

  • Problems with the postal code in address iview ESS.

    I would greatly appreciate if someone answer this threat. I am having this big problem with the address iview. It is not possible to change the postal code in the address iview.

    Can you explain the issue? Means for which country this issue is coming. We faced similar issue. There is some bug in ESS/MSS package itself. You send me details of issue at [email protected] I will reply you back with OSS message answered by SAP if that is a bug.

  • Problem with inserting html code.

    Hello,
    I have a problem with the inclusion of this code html connected to the CSS style sheets:
    <head>
    <link href='http://fonts.googleapis.com/css?family=Raleway:320,320,300' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="assets/normalize.css" />
    <link rel="stylesheet" type="text/css" href="assets/demo.css" />
    <link rel="stylesheet" type="text/css" href="assets/component.css" />
      </header>
        <div class="grid">
        <figure class="effect-lily">
        <img src="assets/1.jpg" alt="img01" class="effect-honey"/></figure>
      </a>
    </section>
    </div><!-- /container -->
    </body>
    </html>
    1) Does not appear in the preview thumbnail adobe muse.
    2) The pull-down menu or previously entered disappears from display problems once exported the site in html.
    Removing the html code menu work correctly.
    Where is the problem ??

    Most likely there is a critical code error somewhere. Use the W3C validation tools to check your CSS and HTML code.
    CODE VALIDATION TOOLS
    CSS - http://jigsaw.w3.org/css-validator/
    HTML - http://validator.w3.org/
    Nancy O.

  • Packaging problem with Arial small capital

    Hi there,
    I'm busy with my first real grafic assignment and I'm having trouble with my InDesign cs5 document. The same document in CS3 (I skipped cs4) had no problem.
    The steps I make:
    - preflight check is ok
    - I open the package window, it's al ok
    - press the package button
    - then 'next' on the press instructions
    - I choose a folder and press ok
    - A warning appears. something about restrictions to copy or use a font software for a service provider and trouble with the copyright. (too bad I have no restricted font, I use only Arial regular and in small capital)
    - I press ok to ignore it
    - The package is made and it al looks good until I open the indesign document I just packed. The small capital text has changed in regular. The small capital button does not work anymore in this document, so I can't change it back to small capital again.
    When testing with an other document and more fonts the same problem occurs.
    The first version of my assignment (made in cs3) had no problem with the package tool.
    The only forum in the direction of this problem is here but I haven't got any idea what to do.
    Could anyone help me? Did I do something wrong or is it a cs5 bug?
    Thanks in advance.
    Marianne

    Yes, it's a bug. It was fixed in one of the updates. Current version of CS5 is 7.0.4 and you should install the patch if you haven't done it already.

  • Problem with running sample code from XML Schema Processor for Java

    Hi there,
    I downloaded the XML Schema Processor for Java and tried it out. Unfortunately, it failed at the first step. FYI, I included all xmlparserv2.jar and xmlschema.jar in my classpath.
    I compiled XSDSample.java with a warning: XSDSample.java uses a deprecated API. Recompile with "-deprecation" for details. There was no problem with compiling XSDSetSchema.java.
    When I tried to run report.xml by typing java XSDSample report.xml, I got Parsing report.xml
    NonParserException: null.
    I guess that report.xml from the sample is not valid.
    Could any one give me a hint? Any suggestion would be greatly appreciated.
    ---Denali
    null

    Please post this message at:
    Forums Home » Oracle Technology Network (OTN) » Products » Database » XML DB

  • Problem with too small page size using Java 2D Printing API.

    Hello,
    I have problem with resolution of printer using Java 2D Printing API. Despite my printer has 600 x 600 DPI, inside java.awt.print.Printable.print(Graphics, PageFormat, int) I receive page format with 600 x 840 page size.
    I have tried to set resolution using javax.print.attribute.PrintRequestAttributeSetand javax.print.attribute.standard.PrinterResolution, but with no result.
    Can anybody solve this problem?
    Regards,
    Karl.

    600 x 840 is a Point value; Point is defined as 1/72nd of an inch. Printers do have much higher DPI than this, but I believe that this DPI has to do with richness of the printed image, not an actual ability to color with that level of resolution. You might want to try calling zoom on your Graphics2D object. Otherwise, I don't know what else you can try.

  • Reading TDMS files in Matlab - problems with the example code

    I want to use the TDMS files to store data and do offline analysis in Matlab, version 2009b (either on Mac OS10.6 or Windows XP).
    To test the data import in Matlab I tried the example from http://digital.ni.com/public.nsf/allkb/0EEADA99DC7D00A4862572E30037C3A2 , but without success.
    I tried either with and without the path definition (as explained on the page I referred to before) at the start, and got back the following errors:
    with:
    ??? Error using ==> loadlibrary>deltempfiles at 559
    nilibddc_m.i.
    Error in ==> loadlibrary at 452
        deltempfiles(delfiles);
    Error in ==> Read_TDMData at 7loadlibrary([examplePath '\nilibddc'], hfile);
    without: 
    ??? Error using ==> loadlibrary>deltempfiles at 559
    nilibddc_m.i.
    Error in ==> loadlibrary at 452
        deltempfiles(delfiles);
    Error in ==> Read_TDMData at 36loadlibrary(NI_TDM_DLL_Path,NI_TDM_H_Path); 
    I found a few messages on the issue, dating from 2006 and 2007, that didn't lead to a satisfying solution and was hoping that, by now, there would be a solution to my problem.
    Thanks a lot
    Remco   
    Solved!
    Go to Solution.

    Hi Musk,
    Thanks for your answer. 
    Unfortunately it didn't help as my problem is not discussed there. I have a problem with this line:
    loadlibrary(NI_TDM_DLL_Path,NI_TDM_H_Path);
    I said before that I was using 2009b, but I was mistaken, I have R2008a, but the 'loadlibrary' is opened in a 2008b editor (no idea why). On the Mac I have 2009b installed.
    Thanks
    Remco 

  • Creative cloud desctop application, problems with installing, error-code 49 -

    Nachdem sich meine Creative Cloud Desktop App nicht updaten ließ, wollte ich sie nach der Deinstallation wieder installieren.
    Habe nach Angaben des Supports die opm.db Datei gelöscht.
    mit dem Adobe Creative Cleaner Tool, die Installation der Creative Cloud Desktop Anwendung gelöscht, die anderen Programme jedoch belassen. Schließlich arbeite ich damit.
    Meine Anti-Malware-Programme deinstalliert. (später
    Meine Firewall kurzzeitig außer Betrieb gesetzt.
    Nichts hat funktioniert. Ich kann die Creative Cloud nicht mehr installieren. Es kommt bei der Installation nach einer gewissen Zeit die Fehlermeldung:
    Folgender Fehler ist aufgetreten - Fehler im Installationsprogramm beim Zugriff auf eine wichtige Datei oder Verzeichnis. Versichen Sie die Installation zu wiederholen. (Fehlercode 49)
    Ich habe bisher in keinem Forum eine Antwort gefunden.
    Bitte antwortet wer mir helfen kann!!!
    English:
    I've got problems in updating my CC Desktop App. After it doesn't function, i wanted to reinstall the application. But everytime I tried the folloging error message was on the screen.
    The following error occurred - installer error when accessing an important file or directory. Try to repeat the installation. (Error code 49)
    I just tried it with
    deleting the opm.db file
    the adobe CC cleaner tool
    deinstalling my anti-malware-tool
    nothing helped. Has anyone a tip what i can do? Please help me!

    1.
    2.
    3. No Installation was made and so no installation-Logfile could found. The last one was at 21.06.2014
    just a opm.db file was found. I cannot open it . The last words are just...
    REATE TABLE opm_meta ( key varchar(25), value TEXT, constraint pk PRIMARY KEY (key) )
    indexsqlite_autoindex_opm_meta_1opm_meta
    was this a little helpful for you?

  • Problem with AS 2 code...

    Hi,
    I bought this template because I wanna use certain stuff from
    it for my page.
    Unfortunately I'm not that experienced with Action Script, so
    here we go... (btw, it's AS 2.0)
    I ripped out a portion of the template which is like a photo
    gallery, but only the small preview thumbnails.
    Now, I have a lot of preview thumbnails, but because of
    limitations to the size of the page I can only show a few at once -
    let' say 8 - and then have arrow keys on the top and the bottom to
    go show the next / previous 8 thumbnails.
    In the template that I bought the code, of course, works, but
    when I ripped it out it doesn't really work anymore, probably
    something is missing or has to be adjusted...
    Here's the code that is applied to the preview thumbnails:
    onClipEvent (load) {
    accel =0;
    rate = 0.05;
    trace(_y)
    _root.ykoord=20.5;
    onClipEvent(enterFrame) {
    y=y*accel+(_root.ykoord-_y) * rate;
    _y+=y;
    if(Math.abs(_root.ykoord-_y)<1) { _y=_root.ykoord; }
    Here's the code that is applied to one of the arrow buttons:
    on (rollOver) {
    gotoAndPlay("S1");
    on (releaseOutside, rollOut) {
    gotoAndPlay("S2");
    on (release) {
    if (_root.ykoord>-200) {
    _root.ykoord -= 308;
    The rollover effect for the button is working, just when u
    click on them nothing is moving / transitioning.
    Like I said, in the original template the code is working.
    Because of my very limited action script skills ;) I just
    understand half of the code that's why I can't seem to adjust it...
    I managed to write my own very simple code to make the
    buttons move the preview thumbnails, something like:
    on (release) {
    _root.small_pics_all.small_pics._y =
    _root.small_pics_all.small_pics._y - 308;
    but it just does not have the nice transition scrolling that
    the other one has...
    Any help is very, very appreciated ! ;)
    Mike

    Hi Kiran,
    The log files i mentioned can be found in /usr/sap/<SID>/<instanceID>/work/
    As for the java heap settings, if you see in the log files the error "cannot reserve enough space for object heap" then you need to lower the values of -Xmx and -Xms JVM options, via configtool.
    See
    http://help.sap.com/saphelp_nw2004s/helpdata/en/00/3ca3e81b5a4c749b860ab1ed1fb206/content.htm
    Greetings, Myriana

  • UTF-16 and SQL 2005. Any problems with surrogate pair code points?

    Do nvarchar and nchars in SQL2005 offer full UTF-16 support?
    As far as I can tell two nchars are necessary to store a full 32 bit surrogate pair UTF-16 code point. Everyone happy with that?
     Provided that all my nchars(x) and nvarchars(x) have sufficient size (x is big enough), should I expect any problems using the full range of UTF-16 characters?

    You can find more info here:
    http://blogs.msdn.com/michkap/archive/2006/06/05/617896.aspx
    and
    http://msdn.microsoft.com/en-us/library/bb330962.aspx
    http://blogs.msdn.com/qingsongyao/archive/2008/08/11/why-should-we-bother-about-surrogate-characer.aspx

  • Problems with backing Java Code

    Earlier I manually deleted the processChange event handler method for a textfield from the backing java code. As I had no plans to use that event handler. Now my page abends with a message stating that the process chnage method is not available. I tried to add via the event handler for the textbox using the GUI but it does not add the process change event handler method. Using an another process change method as a model I manually entered the code to handle process change for the text bos. Now I am getting an internal server exception - Null in one of the parameters. PLEASE HELP. What are my options - Delete and re-create the entire page

    Hi,
    Yes I am using the recommeded code: The Text field generating the null exception is addDataSourceTF. Whenever we click on the addDataSourceBTN we get an Internal exception.
    Thanks very much for looking into this problem. Any advice will be greatly appreciated.
    <h:panelGrid binding="#{MainPage.gridPanel1}" cellpadding="3" cellspacing="2" columnClasses="" id="gridPanel1" style="background-color: rgb(204, 255, 204); left: 48px; top: 312px; position: absolute">
    <h:inputText binding="#{MainPage.addDataSourceTF}" id="addDataSourceTF" style="font-family: Arial,Helvetica,sans-serif"
    validator="#{MainPage.addDataSourceTF_validate}" valueChangeListener="#{MainPage.addDataSourceTF_processValueChange}"/>
    <h:commandButton action="#{MainPage.addDataSourceBTN_action}" binding="#{MainPage.addDataSourceBTN}" id="addDataSourceBTN"
    image="resources/button32.jpg" value="Add Data Source"/>
    <h:selectOneMenu binding="#{MainPage.deleteDataSourceDD}" id="deleteDataSourceDD" immediate="true" onchange="this.form.submit();"
    style="height: 23px; width: 164px" valueChangeListener="#{MainPage.deleteDataSourceDD_processValueChange}">
    <f:selectItems binding="#{MainPage.dropdown1SelectItems}" id="dropdown1SelectItems" value="#{MainPage.database_infoRowSet.selectItems['DB_SRC,DB_SRC']}"/>
    </h:selectOneMenu>
    <h:commandButton action="#{MainPage.deleteDataSourceBTN_action}" binding="#{MainPage.deleteDataSourceBTN}" id="deleteDataSourceBTN"
    image="resources/delete.jpg" value="Submit"/>
    </h:panelGrid>
    Backing Java Code:
    * MainPage.java
    * Created on December 15, 2004, 1:45 AM
    * Copyright adear1
    package dissertation;
    import javax.faces.*;
    import com.sun.jsfcl.app.*;
    import javax.faces.component.html.*;
    import com.sun.jsfcl.data.*;
    import javax.faces.component.*;
    import javax.faces.event.*;
    import com.sun.sql.rowset.*;
    import javax.faces.context.FacesContext;
    import javax.faces.application.FacesMessage;
    import javax.faces.convert.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.DataSource;
    import java.lang.*;
    import javax.faces.context.*;
    public class MainPage extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Definition">
    private int __placeholder;
    private HtmlForm form1 = new HtmlForm();
    public HtmlForm getForm1() {
    return form1;
    public void setForm1(HtmlForm hf) {
    this.form1 = hf;
    private HtmlCommandButton addDataSourceBTN = new HtmlCommandButton();
    public HtmlCommandButton getAddDataSourceBTN() {
    return addDataSourceBTN;
    public void setAddDataSourceBTN(HtmlCommandButton hcb) {
    this.addDataSourceBTN = hcb;
    private HtmlCommandButton searchDataBTN = new HtmlCommandButton();
    public HtmlCommandButton getSearchDataBTN() {
    return searchDataBTN;
    public void setSearchDataBTN(HtmlCommandButton hcb) {
    this.searchDataBTN = hcb;
    private HtmlCommandButton scrubbingRulesBTN = new HtmlCommandButton();
    public HtmlCommandButton getScrubbingRulesBTN() {
    return scrubbingRulesBTN;
    public void setScrubbingRulesBTN(HtmlCommandButton hcb) {
    this.scrubbingRulesBTN = hcb;
    private HtmlCommandButton scrubDataSourceBTN = new HtmlCommandButton();
    public HtmlCommandButton getScrubDataSourceBTN() {
    return scrubDataSourceBTN;
    public void setScrubDataSourceBTN(HtmlCommandButton hcb) {
    this.scrubDataSourceBTN = hcb;
    private HtmlCommandButton uploadDataSourceBTN = new HtmlCommandButton();
    public HtmlCommandButton getUploadDataSourceBTN() {
    return uploadDataSourceBTN;
    public void setUploadDataSourceBTN(HtmlCommandButton hcb) {
    this.uploadDataSourceBTN = hcb;
    private HtmlCommandButton deleteDataSourceBTN = new HtmlCommandButton();
    public HtmlCommandButton getDeleteDataSourceBTN() {
    return deleteDataSourceBTN;
    public void setDeleteDataSourceBTN(HtmlCommandButton hcb) {
    this.deleteDataSourceBTN = hcb;
    private HtmlInputText addDataSourceTF = new HtmlInputText();
    public HtmlInputText getAddDataSourceTF() {
    return addDataSourceTF;
    public void setAddDataSourceTF(HtmlInputText hit) {
    this.addDataSourceTF = hit;
    private HtmlSelectOneMenu deleteDataSourceDD = new HtmlSelectOneMenu();
    public HtmlSelectOneMenu getDeleteDataSourceDD() {
    return deleteDataSourceDD;
    public void setDeleteDataSourceDD(HtmlSelectOneMenu hsom) {
    this.deleteDataSourceDD = hsom;
    private DefaultSelectItemsArray dropdown1DefaultItems = new DefaultSelectItemsArray();
    public DefaultSelectItemsArray getDropdown1DefaultItems() {
    return dropdown1DefaultItems;
    public void setDropdown1DefaultItems(DefaultSelectItemsArray dsia) {
    this.dropdown1DefaultItems = dsia;
    private UISelectItems dropdown1SelectItems = new UISelectItems();
    public UISelectItems getDropdown1SelectItems() {
    return dropdown1SelectItems;
    public void setDropdown1SelectItems(UISelectItems uisi) {
    this.dropdown1SelectItems = uisi;
    private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();
    public HtmlPanelGrid getGridPanel1() {
    return gridPanel1;
    public void setGridPanel1(HtmlPanelGrid hpg) {
    this.gridPanel1 = hpg;
    private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid();
    public HtmlPanelGrid getGridPanel2() {
    return gridPanel2;
    public void setGridPanel2(HtmlPanelGrid hpg) {
    this.gridPanel2 = hpg;
    private HtmlOutputText welcomeOT = new HtmlOutputText();
    public HtmlOutputText getWelcomeOT() {
    return welcomeOT;
    public void setWelcomeOT(HtmlOutputText hot) {
    this.welcomeOT = hot;
    private JdbcRowSetXImpl database_infoRowSet = new JdbcRowSetXImpl();
    public JdbcRowSetXImpl getDatabase_infoRowSet() {
    return database_infoRowSet;
    public void setDatabase_infoRowSet(JdbcRowSetXImpl jrsxi) {
    this.database_infoRowSet = jrsxi;
    private DefaultSelectItemsArray listbox1DefaultItems1 = new DefaultSelectItemsArray();
    public DefaultSelectItemsArray getListbox1DefaultItems1() {
    return listbox1DefaultItems1;
    public void setListbox1DefaultItems1(DefaultSelectItemsArray dsia) {
    this.listbox1DefaultItems1 = dsia;
    private HtmlSelectOneListbox dataSourceLB = new HtmlSelectOneListbox();
    public HtmlSelectOneListbox getDataSourceLB() {
    return dataSourceLB;
    public void setDataSourceLB(HtmlSelectOneListbox hsol) {
    this.dataSourceLB = hsol;
    private DefaultSelectItemsArray listbox1DefaultItems2 = new DefaultSelectItemsArray();
    public DefaultSelectItemsArray getListbox1DefaultItems2() {
    return listbox1DefaultItems2;
    public void setListbox1DefaultItems2(DefaultSelectItemsArray dsia) {
    this.listbox1DefaultItems2 = dsia;
    private UISelectItems listbox1SelectItems = new UISelectItems();
    public UISelectItems getListbox1SelectItems() {
    return listbox1SelectItems;
    public void setListbox1SelectItems(UISelectItems uisi) {
    this.listbox1SelectItems = uisi;
    private JdbcRowSetXImpl database_infoRowSet1 = new JdbcRowSetXImpl();
    public JdbcRowSetXImpl getDatabase_infoRowSet1() {
    return database_infoRowSet1;
    public void setDatabase_infoRowSet1(JdbcRowSetXImpl jrsxi) {
    this.database_infoRowSet1 = jrsxi;
    private JdbcRowSetXImpl user_tableRowSet = new JdbcRowSetXImpl();
    public JdbcRowSetXImpl getUser_tableRowSet() {
    return user_tableRowSet;
    public void setUser_tableRowSet(JdbcRowSetXImpl jrsxi) {
    this.user_tableRowSet = jrsxi;
    private HtmlMessages messageList1 = new HtmlMessages();
    public HtmlMessages getMessageList1() {
    return messageList1;
    public void setMessageList1(HtmlMessages hm) {
    this.messageList1 = hm;
    private HtmlOutputText welcomeOT1 = new HtmlOutputText();
    public HtmlOutputText getWelcomeOT1() {
    return welcomeOT1;
    public void setWelcomeOT1(HtmlOutputText hot) {
    this.welcomeOT1 = hot;
    // </editor-fold>
    public MainPage() {
    // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
    try {
    database_infoRowSet.setDataSourceName("java:comp/env/jdbc/mySQL");
    database_infoRowSet.setCommand("SELECT ALL database_info.DB_SRC, database_info.USER_ID FROM database_info WHERE database_info.USER_ID = ?");
    database_infoRowSet1.setDataSourceName("java:comp/env/jdbc/mySQL");
    database_infoRowSet1.setCommand("SELECT ALL database_info.DB_SRC, database_info.DB_URL, database_info.DB_SCHEMA, database_info.DB_TYPE, database_info.USER_ID FROM database_info WHERE database_info.USER_ID = ?");
    user_tableRowSet.setDataSourceName("java:comp/env/jdbc/mySQL");
    user_tableRowSet.setCommand("SELECT * FROM user_table");
    } catch (Exception e) {
    log("MainPage Initialization Failure", e);
    throw e instanceof javax.faces.FacesException ? (FacesException) e: new FacesException(e);
    // </editor-fold>
    // Additional user provided initialization code
    try{
    database_infoRowSet.setString(1, getSessionBean1().getSbUserID());
    database_infoRowSet1.setString(1, getSessionBean1().getSbUserID());
    database_infoRowSet.execute();
    database_infoRowSet1.execute();
    database_infoRowSet1.first();
    if (database_infoRowSet.next()) {
    // If no row found then make the following button's as readonly
    database_infoRowSet.first();
    else {
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage(
    "Please Add Data Source to Begin Processing", ""));
    searchDataBTN.setDisabled(true);
    scrubbingRulesBTN.setDisabled(true);
    scrubDataSourceBTN.setDisabled(true);
    uploadDataSourceBTN.setDisabled(true);
    catch (Exception ex){
    log("Error in initializing database_info Row Set", ex);
    protected dissertation.ApplicationBean1 getApplicationBean1() {
    return (dissertation.ApplicationBean1)getBean("ApplicationBean1");
    protected dissertation.SessionBean1 getSessionBean1() {
    return (dissertation.SessionBean1)getBean("SessionBean1");
    * Bean cleanup.
    protected void afterRenderResponse() {
    user_tableRowSet.close();
    database_infoRowSet1.close();
    database_infoRowSet.close();
    public String searchDataBTN_action() {
    // TODO Following code was replaced by static navigation
    // TODO Replace with your code
    //if no value selected then we prompt them to select a row
    if (dataSourceLB.getValue().equals("")||dataSourceLB.getValue()== null){
    // return error msg to select a row before continuing
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage("Please select a data source to process", ""));
    return null;
    else {
    // call method to retrieve the db_schema from the
    getDbDetails();
    getDbDriver();
    return "searchcriticaldata";
    public String scrubbingRulesBTN_action() {
    // TODO Replace with your code
    if (dataSourceLB.getValue().equals("")||dataSourceLB.getValue()== null){
    // return error msg to select a row before continuing
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage("Please select a data source to process", ""));
    return null;
    else {
    // call method to retrieve the db_schema from the
    getDbDetails();
    getDbDriver();
    return "definecolumnrules";
    public String scrubDataSourceBTN_action() {
    // TODO Replace with your code
    if (dataSourceLB.getValue().equals("")||dataSourceLB.getValue()== null){
    // return error msg to select a row before continuing
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage("Please select a data source to process", ""));
    return null;
    else {
    // call method to retrieve the db_schema from the
    getDbDetails();
    getDbDriver();
    return "scrubdata";
    public String uploadDataSourceBTN_action() {
    // TODO Replace with your code
    if (dataSourceLB.getValue().equals("")||dataSourceLB.getValue()== null){
    // return error msg to select a row before continuing
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage("Please select a data source to process", ""));
    return null;
    else {
    // call method to retrieve the db_schema from the
    getDbDetails();
    getDbDriver();
    return "uploaddata";
    public String addDataSourceBTN_action() {
    // TODO Following code was replaced by static navigation
    if ( false) {
    // TODO Replace with your code
    if (addDataSourceTF.getValue().equals("")){
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage(
    "Please specify Data Source to Add", ""));
    return null;
    else {
    String woSpaces = ((String)addDataSourceTF.getValue()).replace(' ', '_');
    getSessionBean1().setSbDataSrc(woSpaces);
    return "adddatasrc";
    return "adddatasrc";
    public void getDbDetails(){
    try {
    Context ctx = new InitialContext();
    if (ctx == null) throw new NamingException("No Initial Context");
    DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mySQL");
    if (ds == null) throw new NamingException("No Data Source mySQL");
    Connection conn = ds.getConnection();
    if (conn == null)
    throw new SQLException("Unable to establish connection");
    String sql = "Select db_src, db_url, db_schema, db_type user_id, src_password from database_info where db_src=?";
    PreparedStatement pstmt = conn.prepareStatement(sql);
    pstmt.setString(1, (String) dataSourceLB.getValue());
    ResultSet rs = pstmt.executeQuery();
    if (rs.next()){
    getSessionBean1().setSbDataSrc(rs.getString("db_src"));
    getSessionBean1().setSbDb_Schema(rs.getString("db_schema"));
    getSessionBean1().setSbDb_Type(rs.getString("db_type"));
    getSessionBean1().setSbDb_Userid(rs.getString("user_id"));
    getSessionBean1().setSbDb_Password(rs.getString("src_password"));
    else
    java.lang.System.out.println("DB_Schema not found for db_src " +
    (String) dataSourceLB.getValue());
    rs.close();
    pstmt.close();
    conn.close();
    catch (SQLException ex) {
    java.lang.System.out.println("\n ----- SQL Exception caught ------\n");
    while (ex !=null){
    java.lang.System.out.println("Message: " + ex.getMessage());
    java.lang.System.out.println("SQLState: " + ex.getSQLState());
    java.lang.System.out.println("ErrorCode: " + ex.getErrorCode());
    ex = ex.getNextException();
    java.lang.System.out.println("");
    catch (NamingException e){
    java.lang.System.out.println("messge unable to establish context in changepassword.jsp");
    public void getDbDriver(){
    try {
    Context ctx = new InitialContext();
    if (ctx == null) throw new NamingException("No Initial Context");
    DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mySQL");
    if (ds == null) throw new NamingException("No Data Source mySQL");
    Connection conn = ds.getConnection();
    if (conn == null)
    throw new SQLException("Unable to establish connection");
    String sql = "Select db_driver from database_type where db_type=?";
    PreparedStatement pstmt = conn.prepareStatement(sql);
    pstmt.setString(1, getSessionBean1().getSbDb_Type());
    ResultSet rs = pstmt.executeQuery();
    if (rs.next()){
    getSessionBean1().setSbDb_Driver(rs.getString("db_driver"));
    else
    java.lang.System.out.println("DB_Driver not found for db_src " +
    (String) dataSourceLB.getValue());
    rs.close();
    pstmt.close();
    conn.close();
    catch (SQLException ex) {
    java.lang.System.out.println("\n ----- SQL Exception caught ------\n");
    while (ex !=null){
    java.lang.System.out.println("Message: " + ex.getMessage());
    java.lang.System.out.println("SQLState: " + ex.getSQLState());
    java.lang.System.out.println("ErrorCode: " + ex.getErrorCode());
    ex = ex.getNextException();
    java.lang.System.out.println("");
    catch (NamingException e){
    java.lang.System.out.println("messge unable to establish context in changepassword.jsp");
    public String deleteDataSourceBTN_action() {
    // TODO Replace with your code
    try {
    Context ctx = new InitialContext();
    if (ctx == null) throw new NamingException("No Initial Context");
    DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mySQL");
    if (ds == null) throw new NamingException("No Data Source mySQL");
    Connection conn = ds.getConnection();
    if (conn == null)
    throw new SQLException("Unable to establish connection");
    String sql = "Delete from database_info where db_src=?";
    PreparedStatement pstmt = conn.prepareStatement(sql);
    pstmt.setString(1, (String) deleteDataSourceDD.getValue());
    pstmt.executeUpdate();
    pstmt.close();
    conn.close();
    return "success";
    catch (SQLException ex) {
    java.lang.System.out.println("\n ----- SQL Exception caught ------\n");
    while (ex !=null){
    java.lang.System.out.println("Message: " + ex.getMessage());
    java.lang.System.out.println("SQLState: " + ex.getSQLState());
    java.lang.System.out.println("ErrorCode: " + ex.getErrorCode());
    ex = ex.getNextException();
    java.lang.System.out.println("");
    return "failure";
    catch (NamingException e){
    java.lang.System.out.println("messge unable to establish context in changepassword.jsp");
    return "failure";
    public void addDataSourceTF_processValueChange(ValueChangeEvent vce) {
    // TODO Replace with your code
    public void deleteDataSourceDD_processValueChange(ValueChangeEvent vce) {
    // TODO Replace with your code
    public void addDataSourceTF_validate(FacesContext fc, UIComponent uic, Object o) {
    // TODO Replace with your code
    }

Maybe you are looking for