Problem while querying from java

I have a query like this ...
Select name,description,start_date from Events where TO_CHAR(start_date,'MM/DD/YYYY')='09/19/2004';
I want to execute the same query using java for which i say
String QQQ="Select name,description,start_date from Events where TO_CHAR(start_date,'MM/DD/YYYY')='?/?/?'"
PreparedStatement stmt = conn.prepareStatement(QQQ);
stmt.setString(1,"09");
stmt.setString(2,"27");
stmt.setString(3,"2004");
But I am not getting the results. Is there anything wrong with the Qusetion marks(?) in the query ?
I get the results if i directly enter the value for the question mark.
Please help.
Thanks.

Date date = get a Date object somehow, perhaps from SimpleDateFormat.parse()
String query = "Select name,description,start_date from Events where start_date = ?";
PreparedStatement ps = con.prepareStatement(query);
ps.setDate(1, date);
ps.executeQuery();

Similar Messages

  • Problem while querying from jsp

    I have a query like this ...
    Select name,description,start_date from Events where TO_CHAR(start_date,'MM/DD/YYYY')='09/19/2004';
    I want to execute the same query using java for which i say
    String QQQ="Select name,description,start_date from Events where TO_CHAR(start_date,'MM/DD/YYYY')='?/?/?'"
    PreparedStatement stmt = conn.prepareStatement(QQQ);
    stmt.setString(1,"09");
    stmt.setString(2,"27");
    stmt.setString(3,"2004");
    But I am not getting the results. Is there anything wrong with the Qusetion marks(?) in the query ?
    I get the results if i directly enter the value for the question mark.
    Please help.
    Thanks.

    You would either need to explicitly concatenate the bind variables, i.e.
    String QQQ="Select name,description,start_date from Events where TO_CHAR(start_date,'MM/DD/YYYY')=? || '/' || ? || '/' || ?"or you would need to have a single bind variable and pass the whole string
    String QQQ="Select name,description,start_date from Events where TO_CHAR(start_date,'MM/DD/YYYY')=?"
    stmt.setString(1, "09/27/2004" );Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • BEx Query from Java

    Hi
    Can I call a BEx Query from Java . If yes, in what format data will be returned? We just need data, we want to structure it in Java for display in a Flex UI.
    Please note that I have very limited knowledge of both Java and BI.
    Thanks in advance for your help.
    Best Regards
    Saurabh

    Hi,
    Yes you can. It will be contained in a web template.
    Please read through the link below and the related links contained within.
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/0d/af12403dbedd5fe10000000a155106/frameset.htm
    Thanks,
    Michael
    Edited by: Michael Devine on May 25, 2010 3:40 PM

  • Translation problem , While conversion from English to Poland

    Hello Gurus
    Pl suggest  Translation problem , While conversion from English to Poland  getting message
    "Code page not found for Poland "
    Code page 1401 exits in system
    SAP version 4.6C
    Best regards
    Krish

    Dear Vamsi,
    Please check the below lonk may be it heps.
    Translation to different languages. How??????
    Regards
    Pranay

  • LDAP Query from Java taking abnormally long

    Is there any reason why this query would take an abnormally long time? When I run the query from the command line it comes back practically instantly, but when I access it via Java it takes close to 30 seconds.
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.NamingEnumeration;
    import javax.naming.NamingException;
    import javax.naming.directory.Attribute;
    import javax.naming.directory.Attributes;
    import javax.naming.directory.DirContext;
    import javax.naming.directory.InitialDirContext;
    import javax.naming.directory.SearchControls;
    import javax.naming.directory.SearchResult;
    public class LDAPTest {
          * @param args
         public static void main(String[] args) {
              String username = System.getProperty("user.name");
              String LDAPServer = "ldap://ldap.myldapserver.net/";
              //String attribute = "";
              String query = "uid=" +username;
              Hashtable env = new Hashtable();
            env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
            env.put(Context.PROVIDER_URL, LDAPServer);
            DirContext context = null;
            NamingEnumeration enumeration = null;
              try {
                   context = new InitialDirContext(env);
                SearchControls ctrl = new SearchControls();
                ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);
                enumeration = context.search("", query, ctrl);
                //while (enumeration.hasMore()) {
                     SearchResult searchResult = (SearchResult) enumeration.next();
                    Attributes attributes = searchResult.getAttributes();
                    Attribute attr = attributes.get("cn");
                    String cn = (String) attr.get();
                    System.out.println(" Person Common Name = " + cn);
            } catch (NamingException e) {
                throw new RuntimeException(e);
            } finally {
                if (enumeration != null) {
                    try {
                         enumeration.close();
                    } catch (Exception e) {
                if (context != null) {
                    try {
                         context.close();
                    } catch (Exception e) {
    }

    njb7ty wrote:
    One way to speed it up is to only retreive those attributes your interested in via ctls.setReturningAttributes.
    Also, if you know what sub directories you want to look in, you can create a list of just those subdirectories and look through them one at a time via ctls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
    SearchControls ctls = new SearchControls();
    ctls.setReturningAttributes((String[])attrIDs.toArray(new String[attrIDs.size()]));
    //only look at the immediate folder level specified (not in sub-folders)
    ctls.setSearchScope(SearchControls.ONELEVEL_SCOPE);Hi, thanks. I tried these, unfortunately I don't know enough about ldap to set the onelevel_scope properly. I have narrowed it down as a combination of load and login issues. For example, in our test environment the java program returns instantly with anonymous. In our production environment it returns in about 30-40 seconds with no login credentials supplied. (it does allow anonymous access). I made sure I set the authentication to none when attempting to try this. But when I do an anonymous query from the command line via a ldapsearch program it pulls the results instantly. (i know it is anonymous because if I specify credentials it pulls back additional data). For some reason it just takes really long to resolve in our production environment if I try anonymous access and I haven't figured it out yet. When I supply login credentials to our production environment it comes back in under a fifth of a second.

  • Problem while migrating from JSF1.1 to JSF1.2

    I'm facing the following issues while migrating from WAS 6.1 to WAS7.0
    For this I have upgraded Jsf 1.1 to 1.2 and webmodule to 2.5, and following errors I'm having...
    1. Description     The method getExceptionMessageString(String) is undefined for the type Util
    2. Description The method getMyForm(UIComponent) in the type CommandLinkRenderer is not applicable for the arguments (FacesContext, UICommand)     
    3. Description     The method getName() is undefined for the type HtmlBasicRenderer.Param     LinkRendererWithName.java
    4. Description     The method getParamList(UIComponent) in the type HtmlBasicRenderer is not applicable for the arguments (FacesContext, UICommand)
    5. Description     The method getValue() is undefined for the type HtmlBasicRenderer.Param     LinkRendererWithName.java
    Any alternative methods to those above methods in JSF1.2?
    or am I need to upgrade any of the jaf dependencies?
    Any suggestions are appreciated.
    Thanks

    i_oss wrote:
    But you should consider implementing your Renderers only using the API and not extending the com.sun.faces.* implementation classes, or you might end up changing your code again on your next jsf updates.Hm, good thinking. I didn't think about the split between the API and the implementation.
    OT question on that subject: is it really good design to have that split? JSF, JAXB, JAX-WS, even CDI has an API and an implementation part to it. But do we really need that? In the case of JSF, you have Mojarra and Myfaces (and some other obscure JSF implementation I believe). But why would you use Myfaces over Mojarra since they both solve the same problem and are both actively developed? Why do we have to deal with API/implementation conflict hell that you can often find when using JAXB, especially in a Mavenized environment? We have Weld as the implementation for CDI. What would move anyone to make a 'competing' implementation of it?
    For something like JPA I can at least understand it; the persistence providers were already there before JPA saw the light of day. There was no need for Sun to create a competing implementation, so they provided the API in stead. But in all other cases... I just don't get it.

  • Problem opening device from Java on Windows XP

    Hi,
    I am having trouble opening the TUN device (it is a virtual network device developed by the OpenVPN project - http://openvpn.net) from Java on Windows.
    I found from the registry that the key for the device on my machine is
    {5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.
    From elsewhere on the web, I found that on Windows this device can be
    addressed as \\.\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap
    I then wrote up a short C code,
    char *tun_dev_name = "\\\\.\\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap";
    FILE *f = fopen(tun_dev_name, "rw");
    fclose(f);
    HANDLE h = CreateFile(tun_dev_name, GENERIC_WRITE | GENERIC_READ, 0, 0, \
    OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0);
    CloseHandle(h);In the above code, the FILE* returned is non-NULL and the HANDLE returned is positive.
    However, when I try to do the same in Java using the code below,
    String tun_dev_name =
    new String("\\\\.\\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap");
    RandomAccessFile raf = new RandomAccessFile(tun_dev_name, "rw");
    []/code]
    a "java.io.IOException: Invalid argument" is thrown. The same exception is thrown when I try to open either FileInputStream or FileOutputStream instead of RandomAccessFile.
    In fact, when I invoke the above C code as a native method from within Java,
    though a valid HANDLE is still returned, the FILE* returned is now NULL. I
    have tried giving all permissions to my codebase using Java's policytool, but that didn't help. BTW, I ran all this code on Windows XP from cygwin.
    Clearly this problem isn't with OpenVPN because I'm able to open the device using both fopen and CreateFile from C. Please let me know if one of you knows what the problem could be and what I need to do to fix it. In case, this is not the right forum for this question, kindly let me know which other forum I should pose this question on.
    Thanks!
    Harsha                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    I am sorry but looks like somehow some text got missed out from my message.
    After the C code and before the Java code, I had intended to mention that when that C code is compiled and run independently, both the fopen and CreateFile calls work fine, with a non-NULL FILE* and a valid HANDLE being returned, respectively.
    And as I have already mentioned, when I invoke the C code as a native method from within Java, the CreateFile still works but the fopen fails returning NULL.
    Sorry for missing that out. Hope somebody will be able to help me out.
    Thanks!
    Harsha

  • Problems Accessing VARRAY from Java

    Hi,
    I am calling a stored procedure with IN parameters as VARRAYS from Java application.
    There are two schemas in the database. One main schema, say 'MAIN_SCHEMA' which contains all the table,VARRAYS,packages etc. There are public synonyms for all the database object including VARRAYS in this schema. The java application uses a connection pool created using another user say 'ADMIN'. This user has been granted priviliges for acccessing all the objects in the 'MAIN_SCHEMA'. For the VARRAYS we have created public synonyms and granted EXECUTE for ADMIN.
    However when I try to execute the stored procedure from java , I get an SQLException("invalid name pattern: ADMIN.UIDARRAY")
    I solved the problem temporarily by prefixing the main schema name to the name of the VARRAY. The sample code I have used is as below. but I am not sure if this is the correct way of doing it. I do not understand why we have to prefix the schema name if we have priviliges and public synonyms on the object.
    public void setPendingForfeituresUids(java.util.List pendingForfeituresUids) throws DAOException{
    try{
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor(
    "MAIN_SCHEMA.UIDARRAY", con);
    array = new ARRAY(descriptor, con, pendingForfeituresUids.toArray());
    if(array == null){
    stmt.setNull(3,java.sql.Types.ARRAY);
    }else{
    stmt.setArray(3, array);
    }catch(SQLException e){
    closeStatement();
    releaseLobWrappers();
    throw new DAOException(e);
    Database and Drivers used
    I am using Oracle 9.2.0.1.0, Weblogic 8.1, Oracle Jdbc thin driver for 9.2 that comes bundled with weblogic (ojdbc14.jar)
    Any help on this is welcome.
    Thanks,
    Sunil

    Hi Sunil,
    I was wondering if you had any solution to the problem you listed.
    We are also facing a similar problem and is reported to oracle. Its a Bug as per oracle.
    Any help in getting this resolved is appreciated.
    Thanks,
    Sandip
    [email protected]

  • Ms Access query from Java

    I'm trying to finish a program but there are some bugs in accessing the database, the connection opened well and i can retreive any data from the data base but when i wrote this sql statement:
    rs = stmt.executeQuery("Select number,Type, sum(charge) from invoice where date between '" + d1 +"' and '"+ d2 + "' Group By number, Type;");
    an error was appeared with:
    "data type mismatch in criteria expression"
    the d1 and d2 are variables with date datatype
    in invoice table "date" is an attribute with date/time datatype..
    anyone to help me??
    thanks all

    the real problem here that in java d1 and d2 areNo the real problem is your refusal to use Prepared Statements.
    converted from from string to date data type
    so it consists of: dayname, day , month, hour, and
    year
    and in MS Access the date attribute is consist of
    day, month and year only.. If you used Prepared Statements then this would not matter.
    so when i compare these d1and d2 in java with date in
    ms access it cause miss match data type error..
    how to make d1,d2 in the format "dd/mm/yyyy" and
    still date data type???
    USE PREPARED STATEMENTS.
    java.sql.PreparedStatement
    Look that up. Annie gave you an example in her post.

  • Problem while issueing from batch

    Dear Gurus
    Suppose I have got a finished product x for this I have maintained a bom of suppose a, b,c all three roh.Out of these 3 I have say c batch managed. Through mb1c suppose  I recieved roh c in different batches and kept them in the store.Now after creating production order in the order bom I am mentioning batch for the material c i.e I am telling from which batch it should issue.While issueing from mb1a to the order if I issue full quantity of c then the sytem is doing it without any problem from that batch that I mentioned in production order.If suppose I issue partial quantity of c then also it is taking but if I again try to issue the rest of the partial quantity the system is giving the error message 'issue quantity is greater than the reservation quantity'.For other roh which are not maintained in batch the system is allowing  to issue as many number of times as required up to the reservation quantity.
    Please tell me the reason why it is behaving like this
    Regards
    Sandip Sarkar

    Hi,
    As per the scenario given by you, you are not using the Automatic Batch determination Process for system to check the stock of BOM item material and assign the btach in Production order.
    You are assigning manually the btach number in the production order component overview against the component. As you are not issuing the material in a single storke system is giving this message.
    As suggested by Brahmankar you can either set the message as "Warning"  OR  "Balnk (No Information)"  in Tcode : OMCQ and then try issuing the material against the production order in partial qualtities.
    Hope this will help you.
    Regards
    Rdahka mk

  • Problems while retrieving from content repository

    Hi,
    I am facing problems while retrieving documents stored the content repository. I have some pdf files as well as text documents stored in the content repository. I need to get retrieve the contents of the text files. My problem lies with how to retrieve the data from the files.
    I have used SCMS_URL_GENERATE, followed by the FM ''HTTP_GET''.  Though I  do get the File id , my problem is how to proceed from this point. Should i wriite an RFC ?
    Thanks and Regards,
    Anie

    Hi,
    I checked the code one again - SCMS_URL_GENERATE is used to send url to the user (to open file in web browser).
    SCMS_HTTP_GET code looks like this:
    CONCATENATE <ls>-vbeln space <ls>-optarcnr
      INTO lv_vbeln_obj
      RESPECTING BLANKS.
    SELECT SINGLE *
      FROM toa01
      WHERE sap_object EQ 'VBRK'
        AND archiv_id EQ co_arch
        AND ar_object EQ 'SDOINVOICE'
        AND object_id EQ lv_vbeln_obj.
    CALL FUNCTION 'SCMS_HTTP_GET'
      EXPORTING
        crep_id   = co_arch
        doc_id    = toa01-arc_doc_id
        comp_id   = 'data'
        length    = 0
        no_cache  = no_cache
      IMPORTING
        length    = comp-size
        mimetype  = comp-type
      TABLES
        data      = comp-bin
      EXCEPTIONS
        not_found = 1
        OTHERS    = 2.
      IF sy-subrc IS NOT INITIAL.
        PERFORM log_create USING <ls>-vbeln.
      ENDIF.
    IF comp-bin IS NOT INITIAL.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          bin_filesize = comp-size
          filename     = dstpc
          filetype     = 'BIN'
        TABLES
          data_tab     = comp-bin
        EXCEPTIONS
          OTHERS       = 1.
      IF sy-subrc IS NOT INITIAL.
        PERFORM log_create USING <ls>-vbeln.
      ELSE.
        MESSAGE s000(38) WITH 'Success'.
      ENDIF.
    ENDIF.
    Regards,
    Przemysław

  • How to open a brio Query from Java

    Hi,
    I am working with Hyperion Intellegence Explorer to take care of the MIS related activities, to pull out the Data from the Data Base and Export it to the Excel
    Actually this is a BAU.
    So i want to reduce my work burdon. I am a Java Progrrammer too. So i want to automate all the thing from Java.
    Pls help me below to open a Brio files from Java,so that i can proceed to process the Query and export it on to the Excel.,

    Don't double post the same question. You can continue in your previous thread
    [http://forums.sun.com/thread.jspa?threadID=5367120]
    I'm locking this one and it will be removed it later.
    db

  • Jintegra problem - accessing Matlab from Java??

    Hi:
    Sorry if this post doesn't belong here!!
    I am accessing Matlab from JAVA using JIntegra for COM. I tried running the example in their website.
    (http://j-integra.intrinsyc.com/support/com/doc/other_examples/Matlab.htm)
    I have also posted the example below. I am using their trial version and have included all the jars as said. I get the an unexpected output (all zero's) for reading a variable in the matlab workspace. I don't understand why I get this. Can anyone let me know if this runs for you??
    Thanks
    Pavan
    Example code from Jintegra website:
    public class MatlabExample {
    public static void main(java.lang.String[] args) throws Exception {
    try {
    // DCOM authentication: Make sure NT Domain, NT User, NT Password are valid credentials.
    // Uncomment this line if MatlabExample.java remotely accesses MATLAB :
    // com.linar.jintegra.AuthInfo.setDefault("NT DOMAIN", "NT USER", "NT PASSWORD");
    // Create the MATLAB object
    // Specify host name or IP address of MATLAB machine as parameter if
    // MatlabExample.java remotely accesses MATLAB.
    // mlapp.MLApp mlApp = new mlapp.MLApp("123.456.789.0");
    mlapp.MLApp mlApp = new mlapp.MLApp();
    String result = mlApp.execute("a = [1 2 3 4; 5 6 7 8;]");
    System.out.println("Execute result is " + result);
    double mreal[][] = new double[2][4];
    double mimage[] = new double[0];
    mlApp.getFullMatrix("a", "base", new Object[]{mreal}, new Object[]{mimage});
    for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 4; j++) {
    System.out.println(mreal[i][j]);
    } finally {
    com.linar.jintegra.Cleaner.releaseAll();
    }

    ......How are you declaring the class in your JSP? ... are you instantiating it as a bean using the useBean tag, or just instantiating it in your code like normal.
    Maybe you could post the relevant JSP code too?
    Hello again,
    Only the last string is populating after the file has be tokenized. What I'll like to accomplish is passing the very first string in the file. I did not get too far in the JSP file setup because the code is still in it's testing stage, but any help will be highly appreciated.
    Here is the JSP code
    <%@page import="dev.*" %>
    <%@page session="true" language="java" import="java.io.*" %>
    <jsp:useBean id="wagerhist" scope="request" class="dev.RoundDetail2" />
    <html>
    <head>
    <title>Round Detail</title>
    <body>
      <table width="530" bordercolor="#000000" valign="top">
        <tr>
              <td align="left"  width="19%">Game ID<%=wagerhist.string_gameID%></td>
              <td align="left"  width="30%">  </td>
              <td align="left"  width="20%">card1</td>
              <td align="left"  width="31%">  </td>
            </tr>
      </table>
    </body>
    </html>

  • Urgent : problem while migrating from forms 6i to 9i

    We are trying to upgrade forms 6i to forms 9i.
    One of our forms is using the host command to call a shell script . This command worked successfully in the form when it was
    in character mode in forms 6i. But we are facing problems while deploying it on web using forms9i.
    Would appreciate an early response.
    Regards ,
    Pooja

    Hi Pooja,
    1. Please check out the script by running it manually in the App Server Machine.
    2. If you are using any environment variables in the shell script, that are not defined in the shell script itself, then try defining in the shell script itself. Because, the environment variable that you are using might not be availble for the script while running using host.
    HTH,
    Regards,
    Arun

  • To Open a Brio Query from Java

    Hi,
    I am using Hyperian Intellegence Explorer to get a information from the Data Base.
    I want to do it automatic,because this we are doing this as a BAU.
    I want to reduce my work load ,so thatpln to write a Code.
    Please help me how to Open an existing BrioQuery from Java.

    corlettk wrote:
    http://geocities.com/khory_scythe/Praxeum/jedicode.html
    Yeah that fits... except I swear a lot. Is that allowed?
    Jedi use their powers to defend and protect, never to attack others.Can we throw an exception for this one?
    edit: actually i disagree with the whole jedi code, its wrong, wheres the fun...
    Mel

Maybe you are looking for

  • Assigning plant to company code

    Hi All, I have created a company code 3333 copying company code 0001. similarly, I created a new plant AB01 copying plant 0001. Now, When I try to assign the plant AB01 to my company 3333, it displays an error message "Plant AB01 is already assigned

  • Is patch 140995-07 for SunRay supported with VDI 3.2?

    I have an existing VDI 3.2 infrastructure in place and have just bought some SunRay 3I DTU's and want to know if the Patch bundle 140995-07 is supported in this environment. I have Files included with this patch: Note:     SUNWlibusbut-4.2-77.27.i386

  • How to Rename Windows Partition

    I used WinClone to create a Windows partition on my Mac drive and restored a previously-saved backup of the Windows installation. Everything worked perfectly except that WinClone renamed the Windows partition "untitled" when it performed the restorat

  • LSMW for Listings via Batch Input recording - Help ?

    Hi Has anyone had any luck with trying to upload Listings via LSMW at all ? I have created on, via batch input recording I have lots of records with entries from 1 to 16 I have recorded enough entries to cope with 16 However when i try to execute the

  • Can I retrieve my original Apple ID password

    Is it possible to retrieve my original Apple ID password...? I cannot re set new password as I can't remember my first password..I've restored my ipad to factory settings but still can't use apps because of forgotten original password. I've changed p