Running Tomcat from a java program

I'm writing a program that shall run Tomcat from the program itself. The eacy way would be to just call org.apache.catalina.startup.Bootstrap.main(String[]) in a new thread, but that gives only a little information to the program about the state of the server. Actually I would only know when the server is told to start (just before the main method is called), and when the server had stopped (just after the main method).
I have browsed the Catalina API documentation and source code for hours, but the only solution I have gotten, writes the standard startup text:
Starting service Tomcat-Standalone
Apache Tomcat/4.0.4
Starting service Tomcat-Apache
Apache Tomcat/4.0.4If I could get that to work, I would could add a LifecycleListener, and get all the info. I need.
The essence of the code I use is this:
CatalinaService cs = new org.apache.catalina.startup.CatalinaService();
Server s = new StandardServer();
StandardService stdService = new org.apache.catalina.core.StandardService();
s.addService(stdService);
cs.setServer(s);
cs.process(new String[]{"start"});but the following also produce a simmilar result:
BootstrapService b = new org.apache.catalina.startup.BootstrapService();
b.load(new TomcatLoader(),null);
b.start();A dirty solution would be to copy the code form Bootstrap.main(String[]) and add a few lines, but I really dosn't like that. It would be a nightmare to maintain, primiarry because I would loose the functionallity of Catalinas class loader (where a lof of classes is loaded).
Does anybody know how I can get Tomcat to run, so I still get my info. and don't use any dirty solutions?

Check out the main method in the source code of class org.apache.catalina.startup.Embedded
It should help you.
Also check out this article
http://www.onjava.com/pub/a/onjava/2002/04/03/tomcat.html

Similar Messages

  • Running ssh from within java program

    Hi!
    I am trying to start ssh from within java e.g.:
    Runtime run = Runtime.getRuntime();
    Process pro = run.exec("ssh -l xx 12.12.12.12");
    But it complains:
    socket: Operation not permitted
    ssh: connect to host 12.12.12.12 port 22: Operation not permitted
    Running ssh from the command prompt works just fine. It's run on win xp.
    What is the problem, and how can I avoid it?
    Endre

    Afraid not. I think maybe it's related to security permissions, but I am really not sure. If you can help, I would appreciate it.
    - Endre

  • Running curl command from a java program using Runtime.getRuntime.exec

    for some reason my curl command does not run when I run it from within my java program and errors out with "https protocol not supported". This same curl command however runs fine from any directory on my red hat linux system.
    To debug the problem, I printed my curl command from the java program before calling Runtime.getRuntime.exec command and then used this o/p to run from the command line and it runs fine.
    I am not using libcurl or anything else, I am running a simple curl command as a command line utility from inside a Java program.
    Any ideas on why this might be happening?

    thanks a lot for your response. The reason why I am using curl is because I need to use certificates and keys to gain access to the internal server. So I use curl "<url> --cert <path to the certificate>" --key "<path to the key>". If you don't mid could you please tell me which version of curl you are using.
    I am using 7.15 in my system.
    Below is the code which errors out.
    public int execCurlCmd(String command)
              String s = null;
              try {
                  // run the Unix "ps -ef" command
                     Process p = Runtime.getRuntime().exec(command);
                     BufferedReader stdInput = new BufferedReader(new
                          InputStreamReader(p.getInputStream()));
                     BufferedReader stdError = new BufferedReader(new
                          InputStreamReader(p.getErrorStream()));
                     // read the output from the command
                     System.out.println("Here is the standard output of the command:\n");
                     while ((s = stdInput.readLine()) != null) {
                         System.out.println(s);
                     // read any errors from the attempted command
                     System.out.println("Here is the standard error of the command (if any):\n");
                     while ((s = stdError.readLine()) != null) {
                         System.out.println(s);
                     return(0);
                 catch (IOException e) {
                     System.out.println("exception happened - here's what I know: ");
                     e.printStackTrace();
                     return(-1);
         }

  • How to execute unix command from the Java program running on Windows

    Hello,
    I need to
    1. Execute a unix shell script from a Java program running on the Windows.
    2. I also need to capture the output of this shell script in my program.
    Please suggest me how to achieve this.
    Thanks in Advance.

    Hi...
    Something is missing here
    If you want to execute a shell script in windows that not posible unless you find or develop a unix shell script parser for windows.
    But if you are trying the execute a unix shell script on a remote unix computer from your java program running on a windows platform you can do that by logging on to the UNIX terminal which is running on port 23 I think.
    You can test this using telnet tool on windows
    just type on command prompt
    telnet <ip of the unix pc> <port number this case 23>
    you should get the unix terminal. If that works you can do the same through java or you can directly conect to port 23 of that pc using sockets that way your program will be platform independant

  • How to run a cygwin.bat from a java program?

    Can you please let me know how to run a cygwin.bat file from a java program and to give commands through java program. I have a program to run .exe files, but when I do the same for the cygwin.bat it doesnt work. In task mgr a BASH and a cmd.exe is running. Please help me on this & bit urgent. Thanks in advance!

    Can you please let me know how to run a cygwin.bat
    file from a java program and to give commands through
    java program. I have a program to run .exe files, but
    when I do the same for the cygwin.bat it doesnt work.Of course not. .bat files are no native executables. You need to open a shell first, like "cmd /c cygwin.bat ..."
    & bit urgent. Thanks in advance!If I had read this earlier I wouldn't have replied. Why exactly is your time worth more than anybody else's?

  • How to run a openssl command from a java program

    Hi All
    Please suggest on how to run a openssl command from a java program.
    I am using this
    Runtime runtime = Runtime.getRuntime();
    runtime.exec("openssl pkcs8 -inform der -nocrypt test.der result.pem");
    This is suppose to take test.der as input and create result.pem.
    There are no errors but the file result.pem isnt created.
    Thanks in Advance

    First off is that openssl command correct? Should it be this instead:
    openssl pkcs8 -inform der -nocrypt -in test.der -out result.pem
    Try out your openssl command within a command prompt so that you know that it works ok. I think the command line you specified waits on stdin (well it does for me).
    After that.....
    runtime.exec creates a Process object. If you do this:
    Process openssl = runtime.exec("....")
    then you can examine the return code from openssl to see the exit code - for instance if the input file does not exist then exit = 1. You can test for this with Java
    Alternatively you could get the stderr from the process and look inside it - if it is 0 length then all is good, if it has some text in there then it has likely failed. You could then throw an exception and include the stderr output in the exception messgae. You may need to experiment with this, runnig it first when openssl is happy then running it again when openssl is upset.
    M

  • How to compile and run a .java file from another java program

    hello,
    can any one tell me how to compile and run a *.java* file from another java program which is not in same directory?

    Well a smarter way of implementing this is by using a solution provided by Java Itself.
    If you are using J2SE 6.0+ there is an in built solution provided along with JDK itself and inorder to go ahead with solution the below are set of API which you;d be using it for compiling Java Programs (Files)
    http://java.sun.com/javase/6/docs/api/javax/tools/package-summary.html
    How do i do that ??
    Check out the below articles which would help you of how to do that
    http://www.ibm.com/developerworks/java/library/j-jcomp/index.html
    http://www.javabeat.net/javabeat/java6/articles/java_6_0_compiler_api_1.php
    http://books.google.com/books?id=WVbpv8SQpkEC&pg=PA155&lpg=PA155&dq=%22javax+tools%22+compiling+java+file&source=web&ots=XOt0siYe-f&sig=HH27ovuwvJgklIf8omTykUmy-eM
    Now once we are done with compilation.In order to run a Specific class all you ought to do is create an object and its specific methods of a specified class included in the CLASSPATH which you can manage it easily by usage little bit reflections.
    Hope that might help :)
    REGARDS,
    RaHuL

  • How to run a remote application (Non Java) from a Java program

    Could you please tell me how to run a remote application (Non-Java) from a Java program without using RMI. Please tell me know the procedure and classes to be used.
    Cheers
    Ram

    what do you mean remote application.In the other pc or in your pc just apart from you application?
    If the application is in your pc,the method which the upper has mentioned is
    a good one!
    But if the application you want to run is not in your computer,the method can't do. And you can use socket with which you can build an application listening some port in the pc which contains the application you want to run .When you want to run that application ,send the Start_Command to the listening application.Then listening application will run the application with the help of the method the upper mentioned.

  • Running a Linux command "clear" from a Java program

    Hello. How to run a simple linux command to clear the screen from a Java program. I did the following
    Process p = Runtime.getRuntime().exec("clear");
    Nothing is happening.

    you're not supposed to mess with the shell, youdon't own it and
    shouldn't try to dictate what happens with it.
    The shell is a multiuser system,What?
    The command shell (for example sh, ksh, bash, csh,
    zsh) is a process, a command interpeter just like any
    other (user mode) program.
    yes, and there can be multiple processes writing to it at any one time.
    You do NOT have exclusive access to it, nor should you ever assume you do.
    In a multiuser system there can be several shells
    running on behalf of several users. The same user can
    run several shells.
    Yes, and each shell can be accessed by multiple processes at any one time.
    So what?
    Process a writes to the shell.
    Process b writes to the shell.
    Process a clears the shell, removing whatever process b wrote there.
    You've just messed up process b, or at the very least its output.
    Do NOT assume you have exclusive access to any shell.

  • Calling jsp page from a java program

    Hello,
    Is it possible to call a JSP page from a java program? If so, please let me know how it is possible.
    I have a JSP page that inserts 10 records in a database based on the attribute given to the page. When the java program is executed all the 10 records need to be inserted.
    The JSP page is already running fine in Tomcat.
    Thanks and Regards,
    Prasanna.

    MVC has applied the standard of seperate your view , model and controller. I believe nobody will insert data from jsp page,better practice should be inserted from your database layer, normally is like DAO layer. so you should pass your data from jsp to your backend.
    hopefully it's help u

  • How to start java.exe from a java program in windows ?

    Hi,
    I did like to know, if its possible to run java.exe from a java program on windows ? The java.exe should be visible from checking the processes that are currently running using the Task Manager on windows.

    Runtime.getRuntime().exec("java Sample");

  • How to have an Oracle procedure send and receive value from a java program.

    The below procedure is place inside a package. This procedure "get_extract_ready_headers " is selecting columns store_number, terminal_number, tran_number, tran_date, cust_id from the source REX_HEAD_EXTRACT table. This information is selected into a ref cursor. The data has cust_id field which is encrypted. How do I modify the procedure get_extract_ready_headers and accomplish 2 things?
    1. Make this procedure to read the "cust_id" value from the source table and send the value to a Java program "getheaderinfo" (this java program decrypts the cust_id field).
    2. When we get the unencrypted value back from the Java program, make the procedure accept this decrypted value and use it to update CUST_ID value in the target table TRAN_HEAD table. I am using Oracle 11.2.0.2, and TOAD 10.5.1.3.
    -- Procedural code
    PROCEDURE get_extract_ready_headers (p_records OUT SYS_REFCURSOR)
    IS
    BEGIN
       OPEN p_records FOR
       SELECT store_number, terminal_number, tran_number, tran_date, cust_id FROM REX_HEAD_EXTRACT;
    END;--Table Structure for source table REX_HEAD_EXTRACT
    CREATE TABLE REX_HEAD_EXTRACT
      REX_SEQ_NBR         NUMBER(20),
      REVISION_NUMBER         NUMBER,
      DAY                     NUMBER(3),
      RESA_TRAN_SEQ_NO        NUMBER(20),
      BUSINESS_DATE           DATE,
      TRAN_SEQ_NBR            NUMBER(12),
      ORG_NUMBER              NUMBER,
      STORE_NUMBER            NUMBER,
      TRAN_DATE               DATE,
      TERMINAL_NUMBER         NUMBER,
      TRAN_NUMBER             NUMBER,
      TRAN_TIME               DATE,
      BATCH_NUMBER            VARCHAR2(8 BYTE),
      BATCH_TYPE              VARCHAR2(4 BYTE),
      TRAN_TYPE               VARCHAR2(4 BYTE),
      SUB_TRAN_TYPE           VARCHAR2(4 BYTE),
      CLERK_CODE              VARCHAR2(15 BYTE),
      TRAN_TAXABLE_AMOUNT     NUMBER(12,2),
      TRAN_TAX_TOTAL          NUMBER(12,2),
      TRAN_GROSS_TOTAL        NUMBER(12,2),
      COUP_TOTAL              NUMBER(9,2),
      MKD_TOTAL               NUMBER(9,2),
      EMPLOYEE_NUMBER         VARCHAR2(15 BYTE),
      EMPLOYEE_NAME           VARCHAR2(40 BYTE),
      TRAN_ALTTAXABLE_AMOUNT  NUMBER(12,2),
      TRAN_ALTTAX_TOTAL       NUMBER(12,2),
      SALE_AMOUNT             NUMBER(9,2),
      RETURN_AMOUNT           NUMBER(9,2),
      RETURNED_AMOUNT         NUMBER(9,2),
      NETCASH                 NUMBER(12,2),
      TENDER_CODE             VARCHAR2(4 BYTE),
      MULT_RCPT               VARCHAR2(1 BYTE),
      SPLIT_TENDER            VARCHAR2(1 BYTE),
      RTN_WITH_PURCHASE       VARCHAR2(1 BYTE),
      RTN_WITH_RCPT           VARCHAR2(1 BYTE),
      REASON_CODE             VARCHAR2(4 BYTE),
      PASSWORD                VARCHAR2(10 BYTE),
      RINGTIME                DATE,
      CUST_NUMBER             VARCHAR2(12 BYTE),
      CUST_ID                 VARCHAR2(50 BYTE),
      ZIP_CODE                NUMBER,
      POSTAL_CODE             VARCHAR2(9 BYTE),
      PV_TIME_LAPSE           NUMBER,
      ORIG_STORE_NBR          NUMBER,
      ORIG_TRAN_DATE          DATE,
      ORIG_TRAN_TYPE          VARCHAR2(4 BYTE),
      ORIG_TERM_NBR           NUMBER,
      ORIG_TRAN_NBR           NUMBER,
      ORIG_SALE_AMT           NUMBER(12,2),
      ORIG_TENDER_CODE        VARCHAR2(4 BYTE),
      ORIG_CLERK_CODE         VARCHAR2(15 BYTE),
      PREV_TRAN_TYPE          VARCHAR2(4 BYTE),
      PREV_SUB_TRAN_TYPE      VARCHAR2(4 BYTE),
      GIFT_REGISTRY_ID        VARCHAR2(25 BYTE),
      NO_OF_ITEMS             NUMBER,
      TAX_EXEMPT_ID           VARCHAR2(18 BYTE),
      TRAN_RINGTIME           NUMBER,
      AUDITED                 VARCHAR2(1 BYTE),
      BATCH_VERSION           NUMBER(9,2),
      BATCH_SOURCE            VARCHAR2(5 BYTE),
      CREATE_DATE             DATE,
      CREATE_ID               VARCHAR2(32 BYTE),
      CREATE_PROC             VARCHAR2(32 BYTE),
      MOD_DATE                DATE,
      MOD_ID                  VARCHAR2(32 BYTE),
      MOD_PROC                VARCHAR2(32 BYTE),
      TERMINAL_GROUP          NUMBER,
      USER_DEF_1              NUMBER,
      USER_DEF_2              NUMBER,
      USER_DEF_3              NUMBER,
      USER_DEF_4              NUMBER(12,2),
      USER_DEF_5              NUMBER(12,2),
      USER_DEF_6              NUMBER(12,2),
      USER_DEF_7              VARCHAR2(50 BYTE),
      USER_DEF_8              VARCHAR2(50 BYTE),
      USER_DEF_9              VARCHAR2(50 BYTE),
      MANAGER_NUMBER          VARCHAR2(15 BYTE),
      MANAGER_REASON_CODE     VARCHAR2(10 BYTE),
      MANAGER_SWIPED          VARCHAR2(1 BYTE),
      PHONE_NO                NUMBER(11),
      KCPOS_KTH_USER_101      NUMBER,
      KCPOS_KTH_USER_102      NUMBER,
      KCPOS_KTH_USER_103      NUMBER,
      KCPOS_KTH_USER_104      NUMBER,
      KCPOS_KTH_USER_105      NUMBER,
      KCPOS_KTH_USER_106      NUMBER,
      KCPOS_KTH_USER_107      NUMBER,
      KCPOS_KTH_USER_108      NUMBER,
      KCPOS_KTH_USER_109      NUMBER,
      KCPOS_KTH_USER_110      NUMBER,
      KCPOS_KTH_USER_201      NUMBER(12,2),
      KCPOS_KTH_USER_202      NUMBER(12,2),
      KCPOS_KTH_USER_203      NUMBER(12,2),
      KCPOS_KTH_USER_204      NUMBER(12,2),
      KCPOS_KTH_USER_205      NUMBER(12,2),
      KCPOS_KTH_USER_206      NUMBER(12,2),
      KCPOS_KTH_USER_207      NUMBER(12,2),
      KCPOS_KTH_USER_208      NUMBER(12,2),
      KCPOS_KTH_USER_209      NUMBER(12,2),
      KCPOS_KTH_USER_210      NUMBER(12,2),
      KCPOS_KTH_USER_301      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_302      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_303      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_304      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_305      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_306      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_307      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_308      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_309      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_310      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_401      DATE,
      KCPOS_KTH_USER_402      DATE,
      KCPOS_KTH_USER_403      DATE,
      DISC_TOTAL              NUMBER(9,2)
    CREATE INDEX REX_HEAD_EXTRACT_NDX ON REX_HEAD_EXTRACT
    (REX_SEQ_NBR, REVISION_NUMBER, STORE_NUMBER, TRAN_DATE, TERMINAL_NUMBER, TRAN_NUMBER)-- Create table DDL for target table TRAN_HEAD
    CREATE TABLE NAVISTOR.KCPOS_TRAN_HEADER_BASE
      TRAN_SEQ_NBR            NUMBER(12),
      ORG_NUMBER              NUMBER,
      STORE_NUMBER            NUMBER,
      TRAN_DATE               DATE,
      TERMINAL_NUMBER         NUMBER,
      TRAN_NUMBER             NUMBER,
      TRAN_TIME               DATE,
      BATCH_NUMBER            VARCHAR2(8 BYTE),
      BATCH_TYPE              VARCHAR2(4 BYTE),
      TRAN_TYPE               VARCHAR2(4 BYTE),
      SUB_TRAN_TYPE           VARCHAR2(4 BYTE),
      CLERK_CODE              VARCHAR2(15 BYTE)     NOT NULL,
      TRAN_TAXABLE_AMOUNT     NUMBER(12,2),
      TRAN_TAX_TOTAL          NUMBER(12,2),
      TRAN_GROSS_TOTAL        NUMBER(12,2),
      COUP_TOTAL              NUMBER(9,2),
      MKD_TOTAL               NUMBER(9,2),
      EMPLOYEE_NUMBER         VARCHAR2(15 BYTE),
      EMPLOYEE_NAME           VARCHAR2(40 BYTE),
      TRAN_ALTTAXABLE_AMOUNT  NUMBER(12,2),
      TRAN_ALTTAX_TOTAL       NUMBER(12,2),
      SALE_AMOUNT             NUMBER(9,2),
      RETURN_AMOUNT           NUMBER(9,2),
      RETURNED_AMOUNT         NUMBER(9,2),
      NETCASH                 NUMBER(12,2),
      TENDER_CODE             VARCHAR2(4 BYTE),
      MULT_RCPT               VARCHAR2(1 BYTE),
      SPLIT_TENDER            VARCHAR2(1 BYTE),
      RTN_WITH_PURCHASE       VARCHAR2(1 BYTE),
      RTN_WITH_RCPT           VARCHAR2(1 BYTE),
      REASON_CODE             VARCHAR2(4 BYTE),
      PASSWORD                VARCHAR2(10 BYTE),
      RINGTIME                DATE,
      CUST_NUMBER             VARCHAR2(12 BYTE),
      CUST_ID                 VARCHAR2(50 BYTE) ENCRYPT USING 'AES256' NO SALT,
      ZIP_CODE                NUMBER,
      POSTAL_CODE             VARCHAR2(9 BYTE),
      PV_TIME_LAPSE           NUMBER,
      ORIG_STORE_NBR          NUMBER,
      ORIG_TRAN_DATE          DATE,
      ORIG_TRAN_TYPE          VARCHAR2(4 BYTE),
      ORIG_TERM_NBR           NUMBER,
      ORIG_TRAN_NBR           NUMBER,
      ORIG_SALE_AMT           NUMBER(12,2),
      ORIG_TENDER_CODE        VARCHAR2(4 BYTE),
      ORIG_CLERK_CODE         VARCHAR2(15 BYTE),
      PREV_TRAN_TYPE          VARCHAR2(4 BYTE),
      PREV_SUB_TRAN_TYPE      VARCHAR2(4 BYTE),
      GIFT_REGISTRY_ID        VARCHAR2(25 BYTE),
      NO_OF_ITEMS             NUMBER,
      TAX_EXEMPT_ID           VARCHAR2(18 BYTE),
      TRAN_RINGTIME           NUMBER,
      AUDITED                 VARCHAR2(1 BYTE),
      BATCH_VERSION           NUMBER(9,2),
      BATCH_SOURCE            VARCHAR2(5 BYTE),
      CREATE_DATE             DATE,
      CREATE_ID               VARCHAR2(32 BYTE),
      CREATE_PROC             VARCHAR2(32 BYTE),
      MOD_DATE                DATE,
      MOD_ID                  VARCHAR2(32 BYTE),
      MOD_PROC                VARCHAR2(32 BYTE),
      TERMINAL_GROUP          NUMBER,
      USER_DEF_1              NUMBER,
      USER_DEF_2              NUMBER,
      USER_DEF_3              NUMBER,
      USER_DEF_4              NUMBER(12,2),
      USER_DEF_5              NUMBER(12,2),
      USER_DEF_6              NUMBER(12,2),
      USER_DEF_7              VARCHAR2(50 BYTE),
      USER_DEF_8              VARCHAR2(50 BYTE),
      USER_DEF_9              VARCHAR2(50 BYTE),
      MANAGER_NUMBER          VARCHAR2(15 BYTE),
      MANAGER_REASON_CODE     VARCHAR2(10 BYTE),
      MANAGER_SWIPED          VARCHAR2(1 BYTE),
      PHONE_NO                NUMBER(11),
      KCPOS_KTH_USER_101      NUMBER,
      KCPOS_KTH_USER_102      NUMBER,
      KCPOS_KTH_USER_103      NUMBER,
      KCPOS_KTH_USER_104      NUMBER,
      KCPOS_KTH_USER_105      NUMBER,
      KCPOS_KTH_USER_106      NUMBER,
      KCPOS_KTH_USER_107      NUMBER,
      KCPOS_KTH_USER_108      NUMBER,
      KCPOS_KTH_USER_109      NUMBER,
      KCPOS_KTH_USER_110      NUMBER,
      KCPOS_KTH_USER_201      NUMBER(12,2),
      KCPOS_KTH_USER_202      NUMBER(12,2),
      KCPOS_KTH_USER_203      NUMBER(12,2),
      KCPOS_KTH_USER_204      NUMBER(12,2),
      KCPOS_KTH_USER_205      NUMBER(12,2),
      KCPOS_KTH_USER_206      NUMBER(12,2),
      KCPOS_KTH_USER_207      NUMBER(12,2),
      KCPOS_KTH_USER_208      NUMBER(12,2),
      KCPOS_KTH_USER_209      NUMBER(12,2),
      KCPOS_KTH_USER_210      NUMBER(12,2),
      KCPOS_KTH_USER_301      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_302      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_303      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_304      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_305      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_306      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_307      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_308      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_309      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_310      VARCHAR2(50 BYTE),
      KCPOS_KTH_USER_401      DATE,
      KCPOS_KTH_USER_402      DATE,
      KCPOS_KTH_USER_403      DATE,
      DISC_TOTAL              NUMBER(9,2),
      RTA_RTN_AUTCOD          VARCHAR2(4 BYTE),
      RTA_RTN_COMMID          NUMBER,
      RTA_RTN_EVNTID          NUMBER,
      RTA_RTN_QTY             NUMBER,
      RTA_RTN_RCPT_SCAN       VARCHAR2(1 BYTE),
      RTA_RTN_REFUND_AMT      NUMBER(9,2),
      RTA_RTN_TYPE_CODE       VARCHAR2(4 BYTE),
      RTA_RTN_WITH_RCPT       VARCHAR2(1 BYTE),
      RTA_RTN_COUNT           INTEGER,
      SDEDVAL1                VARCHAR2(50 BYTE)
    )--sample data
    REX_SEQ_NBR,REVISION_NUMBER,DAY,RESA_TRAN_SEQ_NO,BUSINESS_DATE,TRAN_SEQ_NBR,ORG_NUMBER,STORE_NUMBER,TRAN_DATE,TERMINAL_NUMBER,
    TRAN_NUMBER,TRAN_TIME
    478,1,11,12024005,6/11/2012,,1,692,6/11/2012,155,5,6/11/2012 12:57:17 PM,
    479,1,11,12024006,6/11/2012,,1,692,6/11/2012,155,6,6/11/2012 2:01:51 PM,
    480,1,11,12024007,6/11/2012,,1,692,6/11/2012,155,7,6/11/2012 2:47:10 PM

    Assuming that SomeJavePgm is a Java stored function (not a Java program running outside the database) and that it takes as a parameter whatever data type CUST_ID is in TABLE_A (hopefully RAW but potentially VARCHAR2) and returns a string, you would call it just as you would a PL/SQL stored function
    INSERT INTO table_b( cust_id, <<other columns>> )
      SELECT SomeJavaPgm( a.cust_id ), <<other columns>>
        FROM table_a aIf SomeJavePgm is not a Java stored procedure, calling it from PL/SQL becomes much more complicated. You would need whatever machine hosts this program to expose an appropriate API (for example, a web service interface) that you could invoke via UTL_HTTP). You'd need to tell us what that API was, however.
    Justin

  • How to read files on server from a java program?

    Hello,
    I am fairly new to JSP programming. I have an issue with reading files. I am trying to call method of a normal java file from a jsp program. The method I am trying to call does some IO operation on Files. I have the files in the same directory as my class files on server that is in WEB-INF/classes folder. In my java program, I am giving just the file name to open because the files and the classes are in the same directory. But this is not working.
    What exactly should I do to read a file from a java program, that is running on the server?
    Any help is appreciated.
    Thanks,
    Krishna

    String realFilePath = application.getRealPath("/WEB-INF/myFile.txt");
    File fileToOpen = new File(realFilePath);
    out.println(fileToOpen.getAbsolutePath() + ": exists? " + fileToOpen.exists());in this case "application" is a reference to the ServletContext.
    It is an implicit variable in a JSP. In a servlet:
    ServletContext application = getServletConfig().getServletContext();

  • Cannot call ANY stored functions from my Java program

    My problem is that I cannot call ANY stored procedure from my Java
    program. Here is the code for one of my stored procedures which runs
    very well in PL/SQL:
    PL/SQL code:
    CREATE OR REPLACE PACKAGE types AS
    TYPE cursorType IS REF CURSOR;
    END;
    CREATE OR REPLACE FUNCTION list_recs (id IN NUMBER)
    RETURN types.cursorType IS tracks_cursor types.cursorType;
    BEGIN
    OPEN tracks_cursor FOR
    SELECT * FROM accounts1
    WHERE id = row_number;
    RETURN tracks_cursor;
    END;
    variable c refcursor
    exec :c := list_recs(11)
    SQL> print c
    COLUMN1 A1 ROW_NUMBER
    rec_11 jacob 11
    rec_12 jacob 11
    rec_13 jacob 11
    rec_14 jacob 11
    rec_15 jacob 11
    Here is my Java code:
    import java.sql.*;
    import java.io.*;
    import oracle.jdbc.driver.*;
    class list_recs
    public static void main(String args[]) throws SQLException,
    IOException
    String query;
    CallableStatement cstmt = null;
    ResultSet cursor;
    // input parameters for the stored function
    String user_name = "jacob";
    // user name and password
    String user = "jnikom";
    String pass = "jnikom";
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    try { Class.forName ("oracle.jdbc.driver.OracleDriver"); }
    catch (ClassNotFoundException e)
    { System.out.println("Could not load driver"); }
    Connection conn =
    DriverManager.getConnection (
    "jdbc:oracle:thin:@10.52.0.25:1521:bosdev",user,pass);
    try
    String sql = "{ ? = call list_recs(?) }";
    cstmt = conn.prepareCall(sql);
    // Use OracleTypes.CURSOR as the OUT parameter type
    cstmt.registerOutParameter(1, OracleTypes.CURSOR);
    String id = "11";
    cstmt.setInt(2, Integer.parseInt(id));
    // Execute the function and get the return object from the call
    cstmt.executeQuery();
    ResultSet rset = (ResultSet) cstmt.getObject(1);
    while (rset.next())
    System.out.print(rset.getString(1) + " ");
    System.out.print(rset.getString(2) + " ");
    System.out.println(rset.getString(3) + " ");
    catch (SQLException e)
    System.out.println("Could not call stored function");
    e.printStackTrace();
    return;
    finally
    cstmt.close();
    conn.close();
    System.out.println("Stored function was called");
    Here is how I run it, using Win2K and Oracle9 on Solaris:
    C:\Jacob\Work\Java\Test\Vaultus\Oracle9i\FunctionReturnsResultset>java
    list_recs
    Could not call stored function
    java.sql.SQLException: ORA-00600: internal error code, arguments:
    [ttcgcshnd-1], [0], [], [], [], [], [], []
    at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
    at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:889)
    at
    oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:490)
    at
    oracle.jdbc.driver.OracleStatement.getCursorValue(OracleStatement.java:2661)
    at
    oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4189)
    at
    oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4123)
    at
    oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:541)
    at list_recs.main(list_recs.java:42)
    C:\Jacob\Work\Java\Test\Vaultus\Oracle9i\FunctionReturnsResultset>
    Any help is greatly appreciated,
    Jacob Nikom

    Thank you for your suggestion.
    I tried it, but got the same result. I think the difference in the syntax is due to the Oracle versus SQL92 standard
    conformance. Your statament is the Oracle version and mine is the SQL92. I think both statements are acceptable
    by the Oracle.
    Regards,
    Jacob Nikom

  • Need to execute tcl script from a Java Program

    Hello,
    I need to execute a tcl script from a Java Program. But I do not know how to call the tcl Interpreter. Can anybody help me?

    Iam using the exec command as follows:
    Process proc =
    rt.exec("C:/SpirentConnect/engines/tcl/8.3.4/windows/s
    ctcl.exe C:/Hello.tcl");
    But Hello.tcl is not executed.And does that exact string work on the command line?
    And what is the return code from running it?

Maybe you are looking for

  • SURLError 1005? What's That All About?

    Howdy folks, fairly new mac user here. Everything's been just dandy for the last month but tonight Safari took a few attempts to get going: giving me this error code of 1005. After I finally got it running it seems slower than normal and I'm having a

  • Acrobat X pro crash after installing pitstop pro 10

    I'm using Acrobat X Pro. I just installed Enfocus PitStop Pro 10 yesterday. Now a problem always annoys me. When I quit Acrobat after I viewd a PDF file. The software always reports crash. The report as below: Problem signature:   Problem Event Name:

  • HT1380 Attach Lightning to 30-pin Adapter on a universal dock

    Can I attach a Lightning to 30-pin Adapter to the 30 pin socket of my universal dock for listening to music and charging my iPhone 5?

  • Migrating applciation from weblogic to oracle 9i application server(OC4J)??????

    Hi, I am migrating my ejb application from weblogic to oracle 9i application server.What changes are needed to be made in code and what configuration changes are required. In my application i use a couple of session beans wherin a session bean calls

  • LOCATING A DELETED SSRS SHARED DATASET IN TFS

    I had a report when ever I ran it. It refuse to run indicating I had an issue with 1 of my shared dataset. In the designer mode it showed the lock sign for check in for that particular dataset while others were checked out. I did a compare with a pre