Like clause in PreparedStatement not working

Hi
I need to create a PreparedStatement that selects using a like where clause. I do the following:
String param0 = "ABC%";
PreparedStatement pstmt = conn.prepareStatement("select ISSUEID from DMFI_ISSUE where ISIN like ?");
setObject(pstmt,1,param0,java.sql.Types.VARCHAR);
This doesn't work. If param0 is set to the exact value in the database (e.g. "ABCDEF") it selects one, but the like is not working. Is this a jdbc bug? I need to use a PreparedStatement.
Can anyone help?
Thanks

Please ignore, mea culpa, just a vagary of the dos shell. I passed in "abc%" from the dos prompt.

Similar Messages

  • Unplug stopped working this past week so I downloaded 2.052 like suggested and still not working.

    Have enjoyed Unplug and all of a sudden this past week it stopped working completely, not only on YouTube but Vimeo too. Updated like suggested but still not working.

    Please contact the developer by email at [email protected] as this is an add-on and not a Firefox issue.

  • HT4623 Hi, After updating my phone to the iOS 7, it looks like its keypad is not working properly like It gets a little hanged. What would I do solve this?

    Hi, After updating my phone to the iOS 7, it looks like its keypad is not working properly like It gets a little hanged. What would I do solve this?

    Thanks
    it really works.

  • PreparedStatement not working with Oracle

    Hi All,
    I am using preparedStatement in my JDBC code to fetch/insert values from oracle9i database.
    I am checking condition like if a given record does not exist then insert it else update it.
    First time it works when there is no row in database, however for subsequent run it's not able to return me the result though that row exist in database and this resulting in DuplicateKeyException becuase it try to create the row in db again.
    The code is working fine for MySQL DB2 and SQLServer but doesn't work in case oracle 9i
    Here is mycode
    //problem is here 1st time it works next time it is not retunring true though record is there in DB.
    if(isItemExist("1","CORP"))
    updateItem("1","CORP","DESC1");
    else
    insertItem("1","CORP","DESC1");
    public boolean isItemExist(String itemid, String storeid)
    String FIND_SQL = "SELECT item_desc from item where item_id = ? and store_id = ? ";          
    c = utils.getConnection();
    ps = c.prepareStatement();
    int i = 1;
    ps.setString(i++, storeid);
    ps.setString(i++, itemid);
    rs = ps.executeQuery();
    if(rs.next()){
         return true;
    utils.close(c, ps, rs);
    else{
         return false;
    utils.close(c, ps, rs);
    public void createItem(String itemid, String storeid, String item_desc)
    String INSERT_SQL = "INSERT INTO item(item_id,store_id,item_desc)values(?, ?, ?)";
    c = utils.getConnection();
    ps = c.prepareStatement();
    int i = 1;
    ps.setString(i++, itemid);
    ps.setString(i++, storeid);
    ps.setString(i++, item_desc);
    ps.executeUpdate();
    utils.close(c, ps, null);
    public void updateItem(String itemid, String storeid, String item_desc)
    String INSERT_SQL = "UPDATE item SET item_desc = ?, store_id=? WHERE item_id = ?";
    c = utils.getConnection();
    ps = c.prepareStatement();
    int i = 1;
    ps.setString(i++, item_desc);
    ps.setString(i++, storeid);
    ps.setString(i++, itemid);
    ps.executeUpdate();
    utils.close(c, ps, null);
    Kindly suggest what's wrong with code. because same code works with other databse like SQL Server, MySQL but it is not working with oracle9i.

    if(isItemExist("1","CORP"))
    updateItem("1","CORP","DESC1");
    else
    insertItem("1","CORP","DESC1");
    String FIND_SQL = "SELECT item_desc from item where item_id = ? and store_id = ? ";
    ps.setString(i++, storeid);
    ps.setString(i++, itemid);
    String INSERT_SQL = "INSERT INTO item(item_id,store_id,item_desc)values(?, ?, ?)";
    ps.setString(i++, itemid);
    ps.setString(i++, storeid);
    ps.setString(i++, item_desc);
    String INSERT_SQL = "UPDATE item SET item_desc = ?, store_id=? WHERE item_id = ?";
    ps.setString(i++, item_desc);
    ps.setString(i++, storeid);
    ps.setString(i++, itemid);My first guess, looking at the above snippets, would be that the item_id field is a number and not a string and so you should be calling ps.setInt instead of ps.setString when setting that parameter.
    This is only a guess, however, since you have not posted what the actual error is, which will probably give a hint to what the actual error is.

  • Mail Message URLs like message: ... not working with Apple Mail any more

    Links to certain messages are not working for me any more. For example if I drag a Mail to TextEdit Mac OS X creates a correct Link with the scheme: message:<... etc. Those links should open the linked message in Apple Mail. This seems broken for me.
    Is there a way to reenable this functionality, via Terminal or so?
    I have to admit that I used Sparrow for a short time. It looks like this stole the message-linking. Now I completely removed Sparrow, but it is still not working again with Apple Mail. Any suggestions?
    Kind regards,
    Markus

    nope, same result with the flags, and now my eyes are burning from having used outlook mode instead of classic mode.

  • Some keys of keyboard like t ,y f10 not working in my hp pavalion g series

    sir, 
         plz give  solutions for my hp pavalion g series laptop some keyboard keys like t ,y and f10 not working . 
    thamking you
    Aamir Khan 

    Hi,
    Can you provide the full model number for your laptop?  If you don't know the full model number, see The HP Guide To Finding Your Product Model Number.
    Also, what Operating System are you using?  Windows 7, Windows 8?
    I've provided some links below for Windows 7.  First do a hardware test and see if the keyboard is functional, see Testing for Hardware Failures , and look under Component tests and do the keyboard test.  If there is a problem with the keyboard that requires service, it should come out in that test.  Also take a look at Notebook Keyboard Troubleshooting, and since you are having problems with specific keys, look at the Stuck Keys section, and try to reinstall the drivers which is the last section of that document.
    Good Luck,
    R
    Although I am an HP Employee, I am speaking for myself and not for HP.

  • I want to use a dynamic schema name in the from clause but its not working.

    DECLARE
         vblQueryName VARCHAR2(20);
         vblSchemaName VARCHAR2(20);
    BEGIN
         SELECT CurrentSchemaName INTO vblSchemaName FROM HR_989_SCHEMA;
         vblQueryName:='060_525_020';
         INSERT /*+ APPEND(HP_ELIGIBILITIES,4) */ INTO HP_ELIGIBILITIES
              LVL1ID,
              LVL1Desc,
              LVL2ID,
              LVL2Desc,
              LVL3ID,
              LVL3Desc,
              LVL4ID,
              LVL4Desc
         SELECT /*+ PARALLEL(a,4) */
              LVL1ID,
              LVL1Desc,
              LVL2ID,
              LVL2Desc,
              LVL3ID,
              LVL3Desc,
              LVL4ID,
              LVL4Desc
         FROM
         bold     vblSchemaName.HP_ELIGIBILITIES a
         WHERE
              UPPER(LVL2ID) = 'XX' ;
         COMMIT;
    DBMS_OUTPUT.PUT_LINE( 'Query Executed: ' || vblqueryName);
    INSERT INTO HP_QUERYEXECLOG(QueryName) VALUES(vblQueryName);
    EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
    END;
    I want to create a rules table so that the schema name in front of the table name in the from clause can be controlled by a separate table that is maintained but its not working . Help and your valuable inputs needed for this issue

    I want to use a dynamic schema name in the from clauseyou can alternatively set the current schema as e.g. in:
    declare
       vblqueryname    varchar2 (20);
       vblschemaname   varchar2 (20);
    begin
       select currentschemaname into vblschemaname from hr_989_schema;
       vblqueryname := '060_525_020';
       execute immediate 'alter session set current_schema=' || vblschemaname;
       insert /*+ APPEND(HP_ELIGIBILITIES,4) */
             into hp_eligibilities (lvl1id,
                                    lvl1desc,
                                    lvl2id,
                                    lvl2desc,
                                    lvl3id,
                                    lvl3desc,
                                    lvl4id,
                                    lvl4desc
          select /*+ PARALLEL(a,4) */
                lvl1id,
                 lvl1desc,
                 lvl2id,
                 lvl2desc,
                 lvl3id,
                 lvl3desc,
                 lvl4id,
                 lvl4desc
            from hp_eligibilities a
           where upper (lvl2id) = 'XX';
       commit;
       dbms_output.put_line ('Query Executed: ' || vblqueryname);
       insert into hp_queryexeclog (queryname)
       values (vblqueryname);
    exception
       when no_data_found
       then
          null;
    end;

  • Returning Clause out parameter not working

    I have Oracle 11g (I think?) and VS2010.
    I am using an insert statement with the returning clause to return an identity value that is created by a Sequence/Trigger. The problem I am having is that it is not updating the out parameter in C#. Here's some sample code. I have tested the insert statement in SQL Developer and it works. The C# statement does do the insert, but the out parameter remains null. I have tried ParameterDirection as ReturnValue, InputOutput, and Output. None of those worked. The output value remains null no matter what I try to do. I even lifted this example (Oracle Sequences), ran it, and it also errored and is not returning out parameters. (Error Msg: Unable to cast object of type 'Oracle.DataAccess.Types.OracleDecimal' to type 'System.IConvertible'.Couldn't store <null> in ID Column.  Expected type is Int32.).
    I have searched and searched the web over and I cannot figure out why this does not work. Any help would be most appreciated!!
    MyTable
    MyTable_ID  Number (38)
    Note            Varchar2 (500 byte)
    =================================================
                    try
                        if (insertCmd.Connection.State == ConnectionState.Closed)
                            insertCmd.Connection.Open();
                        int recs = insertCmd.ExecuteNonQuery();
                        this.Id = Convert.ToInt32(insertCmd.Parameters[":Id"].Value);
                    catch (Exception err) {  }
                    finally {  insertCmd.Connection.Close(); }
    private OracleCommand insertCmd
                get
                    OracleCommand insCmd = Context.DataBaseConnection.CreateCommand();
                    insCmd.CommandText = string.Format(
                        @"Insert into MyTable (Note)
                          Values (:Note)
                          Returning MyTable_ID into :Id");
                    insCmd.Parameters.Clear();
                    OracleParameter noteParam = new OracleParameter(":Note", OracleDbType.Varchar2, Note, ParameterDirection.Input);
                    OracleParameter idParam = new OracleParameter(":Id", OracleDbType.Int32, 38, "Calibration_Session_Id");
                    idParam.Direction = ParameterDirection.Output;
                    insCmd.Parameters.Add(idParam);
                    insCmd.Parameters.Add(noteParam);
                    insCmd.BindByName = true;
                    return insCmd;

    Okay, I changed my insert command text to this...
    insCmd.CommandText = string.Format(
                        @"Begin
                             Insert into MyTable (Note)
                             Values (:Note)
                             Returning MyTable_ID into :Id;
                             Commit; End;");
    There was no change. Am I doing an explicit transaction wrong?

  • Looks like JOptionPane setLocation did not work??

    Hi,Sir:
    I hope to put following JOptionPane dialog box in any place I want, such as 100,100 from top left origin in window.
    but it Looks like that JOptionPane setLocation did not work at all.
    what is wrong here?? is it a bug??
    How to solve it?
    Thanks
    import javax.swing.JOptionPane;
    public class Main {
      public static void main(String args[]) {
         JOptionPane jo= new  JOptionPane();
         jo.setLocation(100,100);
        String response = jo.showInputDialog
          ( "What is your first name?????" );
            System.out.println(response);
              

    is it a bug??Yes, its a bug with your code.
    showInputDialog(...) is a static method. It does not use the instance of the Object.
    Read the JOptionPane API. It explains how to create and use a JOption pane directly. Search for the text "Direct Use".

  • Facebook like BOX html snippet not working

    Hi All,
    Somehting is driving me crazy - I can't seem to add a like BOX to my Iweb page - no problem with the like button, bu I want to use the box because it shows my stream. Facebook generates three codes HTML5, XFBML and Iframe and none of them work... the snippet stays empty and blank.....
    This is the code that is generated by facebook:
    <iframe src="//www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com% 2Fpages%2Fstarfish%2F88301317903&amp;width=292&amp;colorscheme=light&amp;show_fa ces=false&amp;border_color&amp;stream=true&amp;header=false&amp;height=395" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:395px;" allowTransparency="true"></iframe>
    converting my URL to the following code (as I have seen elsewhere in the forum) is not working... like this:
    <iframe src="//www.facebook.com/plugins/likebox.php?href=http://www.facebook.com/pages/starfish/88301317903&width=292&colorscheme=light&s how_faces=false&border_color&stream=true&header=false&height=395" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:395px;" allowTransparency="true"></iframe>
    All help is much appreciated!

    There are errors in both your original facebook code and the new version you created. Try this...
    <iframe src="http://www.facebook.com/plugins/likebox.php?href=http://www.facebook.com/pages/s tarfish/88301317903&width=292&colorscheme=light&show_fa ces=false&amp;border_color&amp;stream=true&amp;header=false&amp;height=395" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:395px;" allowTransparency="true"></iframe>

  • PreparedStatement not working

    Hi,
    I am having some problem using PreparedStatement.executeUpdate() . I want to be able to prepare several queries before commiting and I wrote this just to test it
    PreparedStatement stmt= aConnection.prepareStatement("update trans_test1 set field1='a text field' where field1='other text'");
              stmt.executeUpdate();
              aConnection.commit();
              stmt.close();
              aConnection.close();
    when it hits this line "stmt.executeUpdate();" the program just stops running and after a while throws this error.
    java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
    I set the auto commit to false but I still can't get it working and do not understand the problem. Any one can help?
    Thanks so much
    Alejo

    Hi,
    I am having some problem using
    PreparedStatement.executeUpdate() . I want to be able
    to prepare several queries before commiting and I
    wrote this just to test it
    PreparedStatement stmt=
    aConnection.prepareStatement("update trans_test1 set
    field1='a text field' where field1='other text'");
              stmt.executeUpdate();This is wrong in so many ways:
    (1) Use the bind variables.
    (2) Close resources properly in a finally block.
    (3) You don't show where you set auto commit to false
    (4) You don't show where you rollback in the event of a failure.
    >
    I set the auto commit to false but I still can't get
    it working and do not understand the problem. Any one
    can help?A snippet like this isn't enough. Post all the code.
    Which database are you using, and which driver?
    %

  • Postgres/mysql PreparedStatement not working

    Hi All,
    I am encountering errors when using a "?" in PrepareStatement.
    like PrepareStatment pstmt = conn.prepareStatement(update table set col1 = ?")
    this only occurs for posrgresql and mysql. is there a fix for this?
    Thanks

    What exactly is your problem. It can't be that using a ? is the problem, because the ? is what makes a PreparedStatement a PreparedStatement. So what, exactly, is the problem. The code snippet containing a full PreparedStatement construction, parameter setting, and execution along with any errors/exceptions/"unexpected results" will be needed to solve your problem.
    P.S. I hope that code segment you provided was hand typed and not copied because you are missing the " at the beginning of the SQL.

  • Like Phrase DW query not working

    I'm using the DW Recordset Query to search the news table,
    filtering where story CONTAINS form variable Request.search
    here is my page code, the input textfield has a dynamic
    Request Variable called search that I dragged onto this textfield.
    I hoped that my query would filter the news full STORY by whatever
    the user enters into the textfield.
    In Simple mode of the Recordset Dialog box it works
    perfectly, it asks me to enter a test value and I get accurate
    results BUT when I toggle over to the Advanced view of the same
    Recordset Dialog box and try test I do not get a chance to enter a
    value but always get 4 out of 7 results. When I upload it live I
    get the 4 results no matter what I type in text field.
    Code attached and thank you
    Jim

    Hi Jim,
    jimkemble wrote:
    > I'm using the DW Recordset Query to search the news
    table, filtering where
    > story CONTAINS form variable Request.search
    >
    > here is my page code, the input textfield has a dynamic
    Request Variable
    > called search that I dragged onto this textfield. I
    hoped that my query would
    > filter the news full STORY by whatever the user enters
    into the textfield.
    >
    > In Simple mode of the Recordset Dialog box it works
    perfectly, it asks me to
    > enter a test value and I get accurate results BUT when I
    toggle over to the
    > Advanced view of the same Recordset Dialog box and try
    test I do not get a
    > chance to enter a value but always get 4 out of 7
    results. When I upload it
    > live I get the 4 results no matter what I type in text
    field.
    When you go into advanced view, the value that you enter is
    the default
    for MMColParam. In your case its the number 1. During
    testing, enter
    your test value in the default value field of MMColParam, but
    once your
    done, use something that you hope to never have, like -1.
    Steve
    > Code attached and thank you
    > Jim
    >
    > <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    > <!--#include
    file="../Connections/orig_lcba_connection.asp" -->
    > <%
    > Dim rsKeyword__MMColParam
    > rsKeyword__MMColParam = "1"
    > If (Request.Form("Request.search") <> "") Then
    > rsKeyword__MMColParam = Request.Form("Request.search")
    > End If
    > %>
    > <%
    > Dim rsKeyword
    > Dim rsKeyword_cmd
    > Dim rsKeyword_numRows
    >
    > Set rsKeyword_cmd = Server.CreateObject
    ("ADODB.Command")
    > rsKeyword_cmd.ActiveConnection =
    MM_orig_lcba_connection_STRING
    > rsKeyword_cmd.CommandText = "SELECT * FROM news WHERE
    story LIKE ?"
    > rsKeyword_cmd.Prepared = true
    > rsKeyword_cmd.Parameters.Append
    rsKeyword_cmd.CreateParameter("param1", 200,
    > 1, 255, "%" + rsKeyword__MMColParam + "%") ' adVarChar
    >
    > Set rsKeyword = rsKeyword_cmd.Execute
    > rsKeyword_numRows = 0
    > %>
    > <%
    > Dim Repeat1__numRows
    > Dim Repeat1__index
    >
    > Repeat1__numRows = -1
    > Repeat1__index = 0
    > rsKeyword_numRows = rsKeyword_numRows + Repeat1__numRows
    > %>
    > <%
    >
    > Repeat1__numRows = 10
    > Repeat1__index = 0
    > rsKeyword_numRows = rsKeyword_numRows + Repeat1__numRows
    > %>
    > <!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>Untitled Document</title>
    > </head>
    >
    > <body>
    > <table width="650" border="0" cellspacing="0"
    cellpadding="0">
    > <tr>
    > <td><form id="form1" name="form1" method="get"
    action="kw_search_jim.asp">
    > <input name="search" type="text" id="search"
    value="<%= Request("search")
    > %>" />
    > <br />
    > <input type="submit" value="Search" />
    > </form> </td>
    > <td> </td>
    > </tr>
    > </table>
    > <p> </p>
    >
    > <table border="1">
    > <tr>
    > <td>newsDate</td>
    > <td>title</td>
    > <td>story</td>
    > <td>author</td>
    > </tr>
    > <% While ((Repeat1__numRows <> 0) AND (NOT
    rsKeyword.EOF)) %>
    > <tr>
    > <td
    valign="top"><%=(rsKeyword.Fields.Item("newsDate").Value)%></td>
    > <td
    valign="top"><%=(rsKeyword.Fields.Item("title").Value)%></td>
    >
    <td><%=(rsKeyword.Fields.Item("story").Value)%></td>
    > <td
    valign="top"><%=(rsKeyword.Fields.Item("author").Value)%></td>
    > </tr>
    > <%
    > Repeat1__index=Repeat1__index+1
    > Repeat1__numRows=Repeat1__numRows-1
    > rsKeyword.MoveNext()
    > Wend
    > %>
    > </table>
    > </body>
    > </html>
    > <%
    > rsKeyword.Close()
    > Set rsKeyword = Nothing
    > %>
    >

  • Receiving "like" notifications from Facebook not working

    All of my friends receive a notification from Facebook when somebody likes their status. For example, when their phone is locked they will get a notification that someone liked their status.  My iPhone 4 doesn't do that though. I get other notifications such as comments, friend requests, etc. but not likes. I've deleted the app, compared it to others but it still doesn't work. Is there a way I can fix this?

    The same problem here. It used to work for a while. But after the last update it stopped working.
    if I get an e-mail reply to an event, it does not update the attendee list.
    i figured out though, that if you drag the .ics file onto iCal window (events part), the attendee status is updated and event is marked as done, but there is still a question mark in the upper part of the event.
    obviously a bug.

  • PreparedStatements not working

    I have just set up a web application on a server only for some reason, prepared statements do not seem to be working. It is running jdk1.3 and tomcat and mysql. It all works fine on my local machine but when placed on the server the preparedstatements are not recognised. Does anyone have any ideas how to remedy this?
    Thanks

    Hi,
    try loads of debugging using system.out.prinln statements which will show up in the log and also in the tomcat batch window. You'll probably find you are not passing the correct or null variables into the statement, maybe.
    best,
    kev

Maybe you are looking for

  • Framemaker and C#

    Hello, I have a C# windows application that interacts with the database and does some processing. Is it possible to invoke this application from within frame? Also, is it possible to pass the data back to Frame from this application (eg. on click on

  • Using the Dollar($) Sign in a User Function Implementation

    Hi All, Just a quick question: how could you use a dollar($) sign in the implementation (Oracle) of a user function? I'm asking because the table name that I'm using in the implementation happens to contain the dollar sign (I$_FACT_SALES) and from th

  • Output type and Routine

    Hi All, I have created one Z* output type and attached it with Z* program. and it is having routine called ENTRY_N. Now when i execute a transaction which will trigger my output type, is giving me error saying "Processing routine ENTRY_N in program Z

  • Tutorial on interfaces in oracle apps

    can anyone provide me sites having tutorials on oracle apps interfaces.

  • Updating a Java GUI with c++

    Hi, I've been working with JNI for a few months now, but I am struggling with an important piece of the application I'm creating. What I have is a Java GUI which I use to create an existing c++ application through JNI. What I would like to do is have