Use plsql within java (or javascript) programs

hi,
to interface with oracle db, I've always used PLSQL blocks within programs written in C language but now I've to insert PLSQL blocks in java or javascript language
I don't know if it's possibile and I don't know how to do it
may someone explicate it to me?
thanks a lot!

mfran2002 wrote:
hi,
to interface with oracle db, I've always used PLSQL blocks within programs written in C language but now I've to insert PLSQL blocks in java or javascript language
I don't know if it's possibile and I don't know how to do it
may someone explicate it to me?
thanks a lot!There is no pre-processor in the Java standard packages (don't know if there is one out there somewhere, but I imagine that there probably is) as there is for Pro*C. Oracle have one in store??? ... hope so.
So in Java the SQL (including function calls) is built as Strings, which are then fed as arguments to the execute methods of Statement, or to the PreparedStatement itself - that tutorial will spell this all out well.
So the SQLs can be static or build dynamically.
~Bill
Also ... you can store Java stored procedures in the Oracle DB, wrapped as PL/SQL functions and then call them as such.

Similar Messages

  • Using Scanner within Java Program

    How do i call a scanner (scan documents) from a java application and collect the output from scanner in java application.

    Hi,
    You can try a package named: JTwain, which is available at http://asprise.com/product/jtwain.
    JTwain supports all kinds of digital cameras and scanners. You can use Java to access, contorl digital cameras and scanners, and of course, to acquire images with flexible settings.
    The developers' guide is available @ http://asprise.com/product/jtwain/devGuide.php
    In the simplest case, one line of Java code can solve your problem.
    Good luck!

  • Antcall causes FileNotFoundException if using executeTarget within java

    Hi all,
    this is my first post here, so i dont know if it's the right place (sorry if so).
    I try to run an ant target within a java program.
    My build file (test.xml) is:
    <project name="test" default="usage" basedir=".">
      <target name="test1" >
        <echo message="Target test1" />
        <antcall target="test2"/>
      </target>
      <target name="test2" >
        <echo message="Target test2" />
      </target>
    </project>My java programm is:
    public static void main (String [] a) {
      String buildFileName = "test.xml";
      File buildFile = new File (".",buildFileName);
      Project project = new Project();
      project.init();
      ProjectHelper helper = new ProjectHelperImpl();
      helper.parse(project, buildFile);
      project.executeTarget("test1");     
    }This causes following exception:
    Exception in thread "main" test.xml:4: The following error occurred while executing this line:
    java.io.FileNotFoundException: build.xml
         at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:539)
         at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:336)
         at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107)
         at org.apache.tools.ant.Task.perform(Task.java:364)
         at org.apache.tools.ant.Target.execute(Target.java:341)
         at org.apache.tools.ant.Target.performTasks(Target.java:369)
         at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
         at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
         at test.Test.main(Test.java:19)
    Caused by: java.io.FileNotFoundException: build.xml
         at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:243)
         at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:140)
         at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:91)
         at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:334)
         ... 7 more
    Caused by: java.io.FileNotFoundException: build.xml
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:198)
         ... 10 moreIf I use <ant antfile="test.xml" target="test2"/> instead it works perfecly. But I don't want to. The target "antcall" was created to call targets within the same build-file, but why build.xml is referenced anywhere?
    Might this be an ant bug?
    Any ideas?
    Tx

    Disregard, sorry, got confused about build.xml and text.xml.
    May I advise to ask at an Ant forum, though?

  • Email Password after reset, using PLSQL or Java

    Hi,
    Through user management, users passwords can be reset and sent via email automatically.
    Which database procedure behind the scene is used for this? I've created a script to automate user creation and I need a way to email the passwords to users and I think we can re use Oracle solution that emails the password after reset.
    Pls let me know if you have any details of PLSQL/Java used to reset and email the password
    Thanks

    Pls let me know if any one has any inputs on this.
    thanks

  • Trying to use grep from within java,using exec command!

    Hi all!
    I would like to run a grep function on some status file, and get a particular line from it, and then pipe this line to another file.
    Then perfom a grep on the new file to check how many of the lines above are present in that file, and then write this value to a new file.
    The final file with a numerical value in it, i will read from within java,as one reads normal files!
    I can run simple commands using exec, but am kinda stuck with regards to the above!
    Maybe i should just do all the above from a script file and then run the script file from exec. However, i dont want to do that, because it kinda makes the system dependent,..what if i move to a new machine, and forget to install the script, then my program wont work!
    Any advise?
    Thanks
    Regards

    With a little creativity, you can actually do all that from the command line with a single command. It'll look a little crazy, but it can be done.
    Whether the script exists on the local machine or not has zero to do with platform indpendence. You assumedly have to get the application onto the local machine, so including the script is not really an issue at all. However, you're talking about system independence, yet still wishing to run command line arguments? The two are mutually exclusive.

  • Re-use message mapping from within java mapping?

    Hi there,                                                                               
    I have a question regarding java mapping. What I would like to do is to re-use an existing message mapping from within java mapping.
    Technicaly, message mapping is perfomed by com.sap.aii.mappingtool.tf3.AMappingProgram.execute, right? I would like to call that mapping program for a specifc message mapping from within my java mapping.
    Pseudo java code would look like this:
    public void execute(InputStream in, OutputStream out)
      throws StreamTransformationException {
    com.sap.aii.mappingtool.tf3.AMappingProgram.execute(in,out,'SomeMessageMapping');
    SomeMessageMapping is a message mapping that is defined in the integration repository.
    Is it possible? If so, could you provide me with some details?
    Thank you and best regards,
    Wolfgang

    Hi Wolfgang,
    very interesting idea?
    I would activa a dummy message mapping. than I would have a look in the file directory of the java-stack and try to find out the name of the *.class or *.jar file.
    On the other hand you could generate a tpz-transport-file an unpack this file, to explore the name of the *.class or *.jar
    Unfortunately I do not have access to the file system. So I can't explore the name.
    Regards Mario

  • How to find out top 10 records from the R/3 using Java code (WD Program)

    Hi Experts,
    I have used Java Web Dynpro program to fetch records from the backend. Following code helps me and fetches record. As per the customer reqirement, we have to fetch only top 10 records (Actual Cost) from the backend. So I have to modify the Java code. How I can do so? Please help.
              wdContext.nodeGraphData().invalidate();
              IPublicCostcnt.IGraphDataElement categoryElement;
                   for (int i = 0; i < wdContext.nodeItab_Final1().size(); i++) {
                   categoryElement = wdContext.createGraphDataElement();
                   categoryElement.setCostElement(""+ wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getDescription());
                   categoryElement.setActualCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getActual_Cost().toString());
                   categoryElement.setPlannedCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getPlan_Cost().toString());
                   wdContext.nodeGraphData().addElement(categoryElement);
    Regards,
    Gary

    Dear SDN Users,
    This is how I resolved the issue.
    1) Requested ABAPer to provide me sorted data. The data has been sorted in descending order of actual_cost.
    2) After that I used following code. This resolved the issue.
         if (wdContext.nodeItab_Final1().size()>10){
         IPublicCostcnt.IGraphDataElement categoryElement;
              for (int i = 0; i < 10; i++) {
              categoryElement = wdContext.createGraphDataElement();
              categoryElement.setCostElement(""+ wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getDescription());
              categoryElement.setActualCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getActual_Cost().toString());
              categoryElement.setPlannedCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getPlan_Cost().toString());
              wdContext.nodeGraphData().addElement(categoryElement);
         if (wdContext.nodeItab_Final1().size()<=10){
         if (wdContext.nodeItab_Final1().size()>0){
         IPublicCostcnt.IGraphDataElement categoryElement;
              for (int i = 0; i < wdContext.nodeItab_Final1().size(); i++) {
              categoryElement = wdContext.createGraphDataElement();
              categoryElement.setCostElement(""+ wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getDescription());
              categoryElement.setActualCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getActual_Cost().toString());
              categoryElement.setPlannedCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getPlan_Cost().toString());
              wdContext.nodeGraphData().addElement(categoryElement);
    Regards,
    Gary

  • Information Retrieval with Genetic Programming using J2ME and Java WTK

    i have a big project to make a software using java programming especially n using J2ME and Java Wireless Toolkit, and i'm a begginer for java programming. I have no idea for the interface and how to setting connection between my phone mobile and GPRS. what should i do? thank you

    I believe MIT has lots of sourcecode. Try searching their site.

  • Error using java and javascript

    I have a jsp page that links to a bean and is working fine (getting data from the database).
    On a html form I have a button with a picture that fires off javascript when clicked:
    <BUTTON TYPE=reset onclick=showinfo('<%=index%>')>
    <IMG SRC="http://localhost:8080/Portal/Images/q2.bmp" ALT="Info">
    </BUTTON>
    The javascript function just opens a new window and displays the text sent in:
    <Script Language=JavaScript>
    function showinfo(arrayindex)
    InfoWin=window.open("","InfoWin","width=345,height=220");
    InfoWin.document.write(arrayindex);
    return false;
    </Script>
    Well in the above example index is a number (pulled from the database using a java bean and javascript converts it into a string then the function displays it correctly. If I replace <%=index%> with regular text it works fine as well(because java isn't used to pull data)! The problem occurs when I retrieve text data from the database and send it to the function. The web page gives errors about a nonterminating string. But I can move the code to somewhere else on the form(as long as I don't send it to java script) and it will print the text to the screen. I can also view the source of the web page and the html shows the text from the data base as if I hard coded the text into the javascript!!!!!!!!!!!!!!!!!
    This must be a bug between java and javascript!
    -can pass numbers(from a database) between the two
    -can't pass text (from a database)between the two
    Any info would help!

    Found the problem myself!
    I am using an odbc connection to msaccess and the spaces in the text was messing things up!
    After taking out the spaces it worked again.

  • Why using JDeveloper runing java program is faster

    I have written a java program by JDeveloper 3.0, press run button to run the java check
    the performance.
    and then close JDeveloper, try to run the java program only on NT workstation.
    I found that the performance is lower than
    running inside JDeveloper.
    Why the reason ?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Rob (JDeveloper Team):
    If you are running under JDK 1.2, then the reason is that internally JDeveloper uses the OJVM (Oracle Java VM) which is faster than most other JVM's on NT. You may wish to try your app with the JDK 1.3 rc2 from the Javasoft website (which uses HotSpot) and will be faster than the stock JDK 1.2.
    <HR></BLOCKQUOTE>
    Is compatiable using SQLJ for HotSpot ?
    and if not using HotSpot
    Can I uses OJVM only to run my program ?
    How to do ?
    Thank you
    null

  • Program using javac and java

    Hello all:
    When I am in my file folder on my university of linux account, which contaning all the neccessary files(they are all in default package, which means that they are not in any sub folder of this folder) to run my program, I use the command(xml.jar is a jar file in the folder)
    javac -classpath xml.jar Main.java
    to compile my project, it says that it cannot file
    symbol(the symbol is the name of a class I wrote in the current folder, so I do not why this error occurs?).
    But when I was using the command
    javac -classpath xml.jar *.java
    No error was output, it compile successfully.
    However, when I was using the command
    java -classpath xml.jar Main < temp.input
    It give me the following error message:
    Exception in thread "main"
    java.lang.NoClassDefFoundError: Main/java
    I was so confused about it, because my program runs successful using eclipse. I do not know what is wrong with it? Any advice will help

    But I think it is in linux based system. And when it give me the following error message
    y:~/Spring2006/project/MeeshQuest: java -classpath xml.jar;. Main < temp.input
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)
    where options include:
    -d32 use a 32-bit data model if available
    -d64 use a 64-bit data model if available
    -client to select the "client" VM
    -server to select the "server" VM
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A : separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:<value>
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    -agentlib:<libname>[=<options>]
    load native agent library <libname>, e.g. -agentlib:hprof
    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
    load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
    load Java programming language agent, see java.lang.instrument
    /usr/local/bin/.: Permission denied.

  • 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

  • How can I write and read the LPT within JAVA?

    Hello!
    I'm new to JAVA.
    I made a simple JAVA application with few buttons and labels with NetBeans.
    I add ActionListener to button but don't know to write the handling code that should to write a byt to the DATA register in the LPT port of the PC box.
    From where can I get the code for this, maybe within JDK documentation?
    Any advices will be appreciated!
    Regards, csPaul

    I have ever programmed an LPT data sender using VB.net and inpout32.dll(will be very easy to search using google). for Java, try this:
    http://www.geocities.com/Juanga69/parport/
    I've just download the sample also, wanna try to...
    And some people say that JNI allow us to embedd C++ code within our Java program.. I don't know about this yet...

  • Java Server Pages Programming Database Access Error Through Tomcat

    Question# 1
    I am trying to access MYSQL Database through JAVA Server Pages programming using Tomcat Server as web server on win xp.
    Whenever I give following url http://localhost:8080/jspBook/ch1/customers.jsp in web browser , I get followin errors.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NullPointerException
    org.apache.jsp.ch1.customers_jsp._jspService(org.apache.jsp.ch1.customers_jsp:96)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.
    Apache Tomcat/5.5.15
    I am facing this problem since one month. I tried searching on google, but could not get concrete answer. I have configured mysqlconnector to connect to mysql and also configured other things in Tomcat's webapps folder. But I could not overcome this error.
    Please reply urgently. Thankz for the help and time. ?
    <!-- JSP Directives -->
    <%@ page import="java.sql.*" %>
    <%@ page contentType="text/html" %>
    <html>
    <head>
         <title>Insurance Quoting System</title>
    </head>
    <body>
    <basefont face="Arial">
    <!-- JSP Declarations -->
    <%! ResultSet rs = null;%>
    <!-- JSP Scriptlet -->     
    <%
         try {
              Class.forName("org.gjt.mm.mysql.Driver");
              Connection db = DriverManager.getConnection(
    "jdbc:mysql://localhost:3306/quoting");
              Statement s = db.createStatement();
              rs = s.executeQuery("select * from customer");
         catch (Exception e) {
    // For now, just report the error to the system log
         System.out.println(e.toString());
    %>
    <!-- Template text -->
    <table width="550" border="0" align="center">
    <tr>
    <td bgcolor="#006633">
    <div align="center">
              <font size="6" color="#FFFFFF"><b>Insurance Quoting System</b></font>
         </div>
    </td>
    </tr>
    <tr>
    <td>
    <p> </p>
    <p> </p>
    <p align="center"><b>Customers</b></p>
    <table width="290" border="0" align="center">
    <%
         try {
              while (rs.next()) {
    %>
    <!-- JSP Expressions used within template text -->
         <tr>
              <td width="20"><%= rs.getInt(1) %></td>
              <td width="70"><%= rs.getString(2) %></td>
              <td width="70"><%= rs.getString(3) %></td>
              <td width="40">
                   <a href="custMaint.jsp?id=<%= rs.getString(1) %>&action=edit">edit
    </a>
              </td>
              <td width="40">
                   <a href="custMaint.jsp?id=<%= rs.getString(1) %>&action=delete">delete
    </a>
              </td>
              <td width="40">
                   <a href="custMaint.jsp?id=<%= rs.getString(1) %>&action=newQuote">new quote
    </a>
              </td>
         </tr>
    <%
         catch (SQLException e) {
         // For now, just report the error to the system log
         System.out.println(e.toString());
    %>
    </table>
    </td>
    </tr>
    <tr>
         <td>
              <p> </p>
         <p align="center">New Customer</p>
         </td>
    </tr>
    </table>
    </body>
    </html>
    I have tried all possible configurations of classpath with mysqlconnectorj and Tomcat, but i could not find any solution. Plz help urgently. Thankz a lot.

    Your DB connection is probably failing
    As a result your result set "rs" is null when you get to it later on, causing a null pointer exception.
    Do you need to provide a username/password for your database?
    Have you configured your database to allow connections from localhost?
    If you haven't already figured it out, doing SQL programming in a JSP is bad practice. Put your SQL code into a java bean / class where it belongs.

  • What's the difference between java and Javascript?

    I a new programer, I am getting Java down. Now I want to add some java scripts to my site. Is there any difference between java and Javascript? Can I use the Java API site refference and classes? Thanks..

    Java is a programming language, Javascript is more for web pages. It is used to add interactivity to your web pages. 2 different languages.
    check out www.java.sun.com for Sun Java stuff.
    Lynn

Maybe you are looking for