String Query

String s = "Test";
I have declared an string literal.
Can anyone explain me how does it accesses all methods of class String even if i have not created an instance of String class.
Thanks
Pinto

As akulinsk mentioned in
http://forum.java.sun.com/thread.jsp?thread=252438&forum=31&message=935987
In fact there is no difference.First syntax is just a shortcut for second. There is a little difference.
When you do something like this:
String a = "aaa";
String b = "aaa";
String c = "aaa";
there is only one representation of string literal "aaa" in memory. When you do this like this:
String a = new String("aaa");
String b = new String("aaa");
String c = new String("aaa");
you will have three instances of this string in memory.

Similar Messages

  • Prepared XmlQueryExpression with variables vs String query

    John,
    I have ran into another performance problem. This time it is the same xpath expression. The difference is one is a prepared one with variables that are being reset for each execution thread where as the other one is alway a new string query with each execution thread.
    dbxml> info
    Version: Oracle: Berkeley DB XML 2.3.10: (January 30, 2007)
    Berkeley DB 4.5.20: (September 20, 2006)
    Default container name: en-US
    Type of default container: NodeContainer
    Index Nodes: on
    Shell and XmlManager state:
    Verbose: on
    Query context state: LiveValues,Eager
    declare default element namespace "http://dto.destination.dbxml.valhalla.starwood.com";
    collection("en-US")/City[CityDetail/PropertyIds/PropertyId=100]/CityItems/CityItem[@CityItemId=(actual collection of 500 double values)]
    Time: 498 ms
    vs
    declare default element namespace "http://dto.destination.dbxml.valhalla.starwood.com"; collection("en-US")/City[CityDetail/PropertyIds/PropertyId=$PropertyId]/CityItems/CityItem[@CityItemId=$Ids]
    Time: 104291 ms
    A snippet of query plans is following:
    dbxml> queryplan 'declare default element namespace "http://dto.destination.dbxml.valhalla.starwood.com";
    collection("en-US")/City[CityDetail/PropertyIds/PropertyId=100]/CityItems/CityItem[@CityItemId=(196970,339036)]'
    <XQuery>
    <DbXmlNav>
    <LookupIndex container="en-US">
    <ValueQP index="node-element-equality-double" operation="eq" child="PropertyId:http://dto.destination.dbxml.valhalla.starwood.com"
    value="100"/>
    </LookupIndex>
    <DbXmlStep axis="parent-of-child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="PropertyIds" nodeType="element"/>
    <DbXmlStep axis="parent-of-child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityDetail" nodeType="element">
    <OQPlan>P(node-element-presence-none,=,CityDetail:http://dto.destination.dbxml.valhalla.starwood.com)</OQPlan>
    </DbXmlStep>
    <Join type="parent-of-child" return="argument">
    <DbXmlNav>
    <QueryPlanFunction result="collection" container="en-US">
    <OQPlan>n(P(node-element-presence-none,=,CityDetail:http://dto.destination.dbxml.valhalla.starwood.com),V(node-element-equality-double,P
    ropertyId:http://dto.destination.dbxml.valhalla.starwood.com,=,'100'),u(n(P(node-element-presence-none,=,CityItem:http://dto.destination
    .dbxml.valhalla.starwood.com),V(node-attribute-equality-double,@CityItemId,=,'196970')),n(V(node-attribute-equality-double,@CityItemId,=
    ,'339036'),P(node-element-presence-none,=,CityItem:http://dto.destination.dbxml.valhalla.starwood.com))))</OQPlan>
    </QueryPlanFunction>
    <DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="City" nodeType="element"/>
    </DbXmlNav>
    </Join>
    <DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityItems" nodeType="element"/>
    <DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityItem" nodeType="element">
    <OQPlan>P(node-element-presence-none,=,CityItem:http://dto.destination.dbxml.valhalla.starwood.com)</OQPlan>
    </DbXmlStep>
    <Join type="attribute" return="context_item">
    <LookupIndex container="en-US">
    <UnionQP>
    <ValueQP index="node-attribute-equality-double" operation="eq" child="CityItemId" value="196970"/>
    <ValueQP index="node-attribute-equality-double" operation="eq" child="CityItemId" value="339036"/>
    </UnionQP>
    </LookupIndex>
    </Join>
    </DbXmlNav>
    </XQuery>
    <XQuery>
    <DbXmlNav>
    <LookupIndex container="en-US">
    <ValueQP index="node-element-equality-double" operation="eq"
    child="PropertyId:http://dto.destination.dbxml.valhalla.starwood.com">
    <Variable name="PropertyId"/>
    </ValueQP>
    </LookupIndex>
    <DbXmlStep axis="parent-of-child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="PropertyIds" nodeType="element"/>
    <DbXmlStep axis="parent-of-child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityDetail" nodeType="element">
    <OQPlan>P(node-element-presence-none,=,CityDetail:http://dto.destination.dbxml.valhalla.starwood.com)</OQPlan>
    </DbXmlStep>
    <Join type="parent-of-child" return="argument">
    <DbXmlNav>
    <QueryPlanFunction result="collection" container="en-US">
    <OQPlan>n(P(node-element-presence-none,=,CityDetail:http://dto.destination.dbxml.valhalla.starwood.com),P(node-element-presence-none,=,C
    ityItem:http://dto.destination.dbxml.valhalla.starwood.com),P(node-attribute-equality-double,prefix,@CityItemId),P(node-element-presence
    -none,=,PropertyId:http://dto.destination.dbxml.valhalla.starwood.com))</OQPlan>
    </QueryPlanFunction>
    <DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="City" nodeType="element"/>
    </DbXmlNav>
    </Join>
    <DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityItems" nodeType="element"/>
    <DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityItem" nodeType="element">
    <OQPlan>P(node-element-presence-none,=,CityItem:http://dto.destination.dbxml.valhalla.starwood.com)</OQPlan>
    </DbXmlStep>
    <Join type="attribute" return="context_item">
    <DbXmlNav>
    <LookupIndex container="en-US">
    <PresenceQP index="node-attribute-equality-double" operation="prefix" child="CityItemId"/>
    </LookupIndex>
    <DbXmlCompare name="equal" join="self">
    <Variable name="Ids"/>
    </DbXmlCompare>
    </DbXmlNav>
    </Join>
    </DbXmlNav>
    </XQuery>
    Any ideas of what is going on?
    Thanks,
    Dmitriy

    Dmitriy,
    Do you have patch #4 for 2.3.10 applied?
    http://www.oracle.com/technology/products/berkeley-db/xml/update/2.3.10/patch.2.3.10.html
    Regards,
    George

  • Help, slow VBA OLED connection string query...

    Hi all,
    Purpose: To determine if a city and state combination exists in an existing excel workbook.
    Using: VBA with an OLED connection so I don't have to open the workbook. 
    Code:
    Dim cn As New ADODB.Connection
    Dim srcData, cmd As String
    Dim cityADO As Boolean
    With cn
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .ConnectionString = "Data Source=" & srcData _
    & "Extended Properties=""Excel 12.0;"""
    .Open
    End With
    cmd = "SELECT COUNT (*) FROM [" & sSrc & "$A:B] WHERE [City]='" & cCty & _
    "' AND [State]='" & cSt & "';"
    Set rst = cn.Execute(cmd)
    cityADO = CInt(rst.GetString)
    I'm self teaching myself and this is part of a self imposed project. (It's basically checking addresses from a list in an excel sheet. Using Bing or google maps API would be cheating in this case) . So my issue is this method is slow and I was wondering if
    there was a faster way meeting my objective or if there is something wrong in my code that could be causing a bottleneck.

    Hi DaBirdGUY,
    I made a simple demo with your code, and I did not see the obvious performance issue from the query. Based on my understanding, Excel is not a file format designed for high performance query, so it could be slow when the row count is large. A common way
    to improve the performance is load the data to memory and query in memory.
    In addition, if the row count is very large, I will recommend you use SQL Server to query rather than Excel spreadsheet.
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • Set Query String Parameter

    What I am trying to do is to check whether does that variable exist in the querystring, if it does change the value to another value.
    How am I suppose to do abt doing that?

    Well, it's not too complex to do it with java... here is a simple example:
    public class QueryStringChanger
         public static String changeParameter(String query, String key, String value)
              String[] keyValuePairs = query.split("&");
              StringBuffer newQuery = new StringBuffer();
              for (int k = 0; k < keyValuePairs.length; k++)
                   if (keyValuePairs[k].indexOf(key) != -1)
                        String[] thePair = keyValuePairs[k].split("=");
                        keyValuePairs[k] = thePair[0] + "=" + value;
                   if (k != 0) newQuery.append("&");
                   newQuery.append(keyValuePairs[k]);
              return newQuery.toString();
         public static void main(String[] args)
              if (args.length != 3)
                System.out.println("Syntax: java QueryStringChanger 'the query string' theKey theValue\n"+
                                   "Example: java QueryStringChanger page=1&area=3&title=Not+So+Good title Pretty+Darn+Good");
                System.exit(1);
              System.out.println(changeParameter(args[0], args[1], args[2]));
              System.exit(0);
    }Not so sure what you would gain from a HashTable though...

  • Set query string programmatically

    Is there a way to set the query string of a report programmatically at runtime? Something like clientDoc.setQueryString( query ).
    Thanks

    Well, it's not too complex to do it with java... here is a simple example:
    public class QueryStringChanger
         public static String changeParameter(String query, String key, String value)
              String[] keyValuePairs = query.split("&");
              StringBuffer newQuery = new StringBuffer();
              for (int k = 0; k < keyValuePairs.length; k++)
                   if (keyValuePairs[k].indexOf(key) != -1)
                        String[] thePair = keyValuePairs[k].split("=");
                        keyValuePairs[k] = thePair[0] + "=" + value;
                   if (k != 0) newQuery.append("&");
                   newQuery.append(keyValuePairs[k]);
              return newQuery.toString();
         public static void main(String[] args)
              if (args.length != 3)
                System.out.println("Syntax: java QueryStringChanger 'the query string' theKey theValue\n"+
                                   "Example: java QueryStringChanger page=1&area=3&title=Not+So+Good title Pretty+Darn+Good");
                System.exit(1);
              System.out.println(changeParameter(args[0], args[1], args[2]));
              System.exit(0);
    }Not so sure what you would gain from a HashTable though...

  • Can't fetch clob and long in one select/query

    I created a nightmare table containing numerous binary data types to test an application I was working on, and believe I have found an undocumented bug in Oracle's JDBC drivers that is preventing me from loading a CLOB and a LONG in a single SQL select statement. I can load the CLOB successfully, but attempting to call ResultSet.get...() for the LONG column always results in
    java.sql.SQLException: Stream has already been closed
    even when processing the columns in the order of the SELECT statement.
    I have demonstrated this behaviour with version 9.2.0.3 of Oracle's JDBC drivers, running against Oracle 9.2.0.2.0.
    The following Java example contains SQL code to create and populate a table containing a collection of nasty binary columns, and then Java code that demonstrates the problem.
    I would really appreciate any workarounds that allow me to pull this data out of a single query.
    import java.sql.*;
    This class was developed to verify that you can't have a CLOB and a LONG column in the
    same SQL select statement, and extract both values. Calling get...() for the LONG column
    always causes 'java.sql.SQLException: Stream has already been closed'.
    CREATE TABLE BINARY_COLS_TEST
    PK INTEGER PRIMARY KEY NOT NULL,
    CLOB_COL CLOB,
    BLOB_COL BLOB,
    RAW_COL RAW(100),
    LONG_COL LONG
    INSERT INTO BINARY_COLS_TEST (
    PK,
    CLOB_COL,
    BLOB_COL,
    RAW_COL,
    LONG_COL
    ) VALUES (
    1,
    '-- clob value --',
    HEXTORAW('01020304050607'),
    HEXTORAW('01020304050607'),
    '-- long value --'
    public class JdbcLongTest
    public static void main(String argv[])
    throws Exception
    Driver driver = (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    DriverManager.registerDriver(driver);
    Connection connection = DriverManager.getConnection(argv[0], argv[1], argv[2]);
    Statement stmt = connection.createStatement();
    ResultSet results = null;
    try
    String query = "SELECT pk, clob_col, blob_col, raw_col, long_col FROM binary_cols_test";
    results = stmt.executeQuery(query);
    while (results.next())
    int pk = results.getInt(1);
    System.out.println("Loaded int");
    Clob clob = results.getClob(2);
    // It doesn't work if you just close the ascii stream.
    // clob.getAsciiStream().close();
    String clobString = clob.getSubString(1, (int)clob.length());
    System.out.println("Loaded CLOB");
    // Streaming not strictly necessary for short values.
    // Blob blob = results.getBlob(3);
    byte blobData[] = results.getBytes(3);
    System.out.println("Loaded BLOB");
    byte rawData[] = results.getBytes(4);
    System.out.println("Loaded RAW");
    byte longData[] = results.getBytes(5);
    System.out.println("Loaded LONG");
    catch (SQLException e)
    e.printStackTrace();
    results.close();
    stmt.close();
    connection.close();
    } // public class JdbcLongTest

    The problem is that LONGs are not buffered but are read from the wire in the order defined. The problem is the same as
    rs = stmt.executeQuery("select myLong, myNumber from tab");
    while (rs.next()) {
    int n = rs.getInt(2);
    String s = rs.getString(1);
    The above will fail for the same reason. When the statement is executed the LONG is not read immediately. It is buffered in the server waiting to be read. When getInt is called the driver reads the bytes of the LONG and throws them away so that it can get to the NUMBER and read it. Then when getString is called the LONG value is gone so you get an exception.
    Similar problem here. When the query is executed the CLOB and BLOB locators are read from the wire, but the LONG is buffered in the server waiting to be read. When Clob.getString is called, it has to talk to the server to get the value of the CLOB, so it reads the LONG bytes from the wire and throws them away. That clears the connection so that it can ask the server for the CLOB bytes. When the code reads the LONG value, those bytes are gone so you get an exception.
    This is a long standing restriction on using LONG and LONG RAW values and is a result of the network protocol. It is one of the reasons that Oracle deprecates LONGs and recommends using BLOBs and CLOBs instead.
    Douglas

  • Verifying and parsing "query" in cm:select query="..." ...

    I'm writting a session EJB that's passed a param (String query) which is supposed
    to be any valid "query" string passed to the cm:select tag (see "http://edocs.bea.com/wlcs/docs31/p13ndev/jsptags.htm#1057716"
    for more info on this tag and the query param).
    My problem is this: I don't think I should write ALL the stuff to validate and
    parse this string because bea has already done it in: com.beasys.commerce.foundation.expression.*;
    but the only source of documentation available on those classes is the Javadoc(which
    isn't that complete). Has anyone used these classes before(Search, Expression,
    Criteria, Logical)? Does anyone know of some documents on how to use them?
    Please help if you can. I'd really appreciate it. Thanks.

    rajan please just google or search SDN. there are large number of post for this..
    to give you a head start: for using a particular index in the select query a %_HINTS ORACLE 'INDEX clause is added

  • OpenSQLException while executing a select query

    Hi,
    I am attempting to code an SQL query in a servlet  and get the following exception:
    com.sap.sql.log.OpenSQLException:
    Below is the code snippet I am using:
    String weekStart = request.getParameter("weekStart");
    String weekEnd = request.getParameter("weekEnd");
    final Connection con = ConnectionManager.getConnection();
    Statement stmt = con.createStatement();
    String query = "select * from SCHEDULES where BUS_PARTNER_ID = '" + empID + "' and SCHED_DATE  >= '" + Date.valueOf(weekStart) + "' AND  SCHED_DATE  <= '" + Date.valueOf(weekStart) + "';";
    final ResultSet rs = stmt.executeQuery(query);
    The fromDate and toDate parameters are of type string and have format yyyy-mm-dd which is getting passed to the servlet .Values are like 2010-07-13 etc.Issue seems to be with the date beacuse query is working fine without date parameters.
    Can someone please tell me what I am doing wrong and how to fix it?
    thanks
    Reena

    Yes. I understand. Seems as if that's one of the reasons for the error. However, Note:401436.1 speaks on Bug fixes by problem type and listed IOT related bugs.

  • How to write a SQL query in Java

    Hi, I'm writing a program that pulls all data from the database with a simple "SELECT * FROM [TABLE NAME]. The problem is that I don't know how to set it up properly. My code will only connect to the database but not execute the query. Please help.
    {code}import java.sql.*;
    import java.util.Properties;
    import java.sql.*;
    public class DatabaseSelect {
    public static void main(String[] args) {
    System.out.println("Connected to the database!");
    Connection conn = null;
    String url = "jdbc:oracle://localhost:1571/";
    String dbName = "jdbc";
    String driver = "com.oracle.jdbc.Driver";
    String userName = "HR";
    String password = "database";
    String query = "SELECT * FROM HR";
    try {
    Class.forName(driver).newInstance();
    conn = DriverManager.getConnection(url+dbName,userName,password);
    System.out.println("Connected to the database");
    } catch (Exception e) {
    e.printStackTrace();
    }{code}

    pbsacct_1 wrote:
    I added it between my System.out statement and the catch exception. This is what I put, but I'm getting the same result. I looks like a lot of errors. The only thing that prints is the "Connected to database".
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    ResultSet srs = stmt.executeQuery("SELECT * FROM HR");Here is what displays in the console.
    Connected to the database!
    java.lang.ClassNotFoundException: com.oracle.jdbc.Driver
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:164)
         at Discussion10.DatabaseSelect.main(DatabaseSelect.java:26)You are not connecting.
    Because you aren't even loading the driver.
    To be honest if you can't decipher a stack trace with "java.lang.ClassNotFoundException" on your own you are not ready for JDBC anyway.

  • Set Page item value when paging through an sql query report

    I have a report that includes a checkbox to indicate which rows a process is to be run on. I have a "Select All" button that sets a value to check all boxes in the report, and deselect button to turn that feature off. The page only renders one of the buttons at a time depanding on the value. If the "Select All" is turned on, I would like to set the value to "OFF" when a user goes to another page of the report.
    For example:
    A user enters the page and the report is rendered. The rows returned are greater than what is displayed. The paging options for the report are shown. 1-15 16-30 etc. It is currently showing the first 15 rows of the report.
    The user clicks the select all button, and all checkboxes are now checked. Currently it will remain this way until the deselect button is clicked.
    When the user clicks the report paging, I would like to set the value of the Select All item to off.
    Does anyone know how to do this at this point?

    Hi,
    Try Scott's suggestion in Re: How to get query from region "PL/SQL function body returning string query"?
    Andy

  • Trying to run a query

    I'm trying to run a query in a JTextField and then have that query display the output in a JTable. When I try to use .getText() to store the query in a string I keep getting errors about SQLException. Can anyone lend me in hand in telling me what I'm doing wrong?
    This is the error I get when the line below would say:
    query=jtf.getText();
    c:\java>java myguidemo
    Exception in thread "main" java.sql.SQLException: Invalid SQL type
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
    :112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
    :146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
    :208)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:67)
    at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:946)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
    nt.java:1169)
    at oracle.jdbc.driver.OracleStatement.doScrollExecuteCommon(OracleStatem
    ent.java:4044)
    at oracle.jdbc.driver.OracleStatement.doScrollStmtExecuteQuery(OracleSta
    tement.java:4196)
    at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:
    1280)
    at myguidemo.<init>(myguidemo.java:39)
    at myguidemo.main(myguidemo.java:106)
    c:\java>
    Here is what I have so far. I took out the oracle IP and login. This is a working version, but where query = "SELECT * ....." I would like that to get whatever is typed in the JTextField. Also button1-5 is supposed to display the entire table in the JTable just by clicking it. Right now I just have them to change background color to make sure they worked.
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    public class myguidemo extends JFrame implements ActionListener{
              Connection connection;
              Statement stmt;
              String query;
              ResultSet results;
              ResultSetMetaData md;
              int numrows, numcols;
              AbstractTableModel dataModel;
              Object [][] data;
    JTextField jtf;
    JTable jtb;
    JPanel jp;
    JScrollPane jsp;
    JButton button1, button2, button3, button4, button5;
    public myguidemo() throws Exception{
              Class.forName( "oracle.jdbc.driver.OracleDriver" );
              connection = DriverManager.getConnection("jdbc:oracle:thin:@);
              jp = new JPanel();
              add(jp,BorderLayout.SOUTH);
    jtb = new JTable();
    add(jtb,BorderLayout.CENTER);
    jtf = new JTextField();
    add(jtf,BorderLayout.NORTH);
    query = "SELECT * FROM PATIENT";
    stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    results = stmt.executeQuery(query);
    md = results.getMetaData();
              numcols = md.getColumnCount();
              numrows = 0;
              while(results.next()) numrows++;
              results.beforeFirst();
              data = new Object[numrows][numcols];
              results.next();
              for(int i=0; i<numrows; i++){
                   for(int j=1; j<=numcols; j++){
                        data[i][j-1] = results.getString(j);
                   results.next();
    dataModel = new AbstractTableModel(){
         public int getColumnCount() {return numcols;}
         public int getRowCount() {return numrows;}
         public Object getValueAt(int row, int col) {return data[row][col];}
    jtf.addActionListener(this);
    jtb = new JTable(dataModel);
    jsp = new JScrollPane(jtb);
    add(jsp);
    button1 = new JButton("Doctor");
    button2 = new JButton("Medication");
    button3 = new JButton("Patient");
    button4 = new JButton("Prescription");
    button5 = new JButton("Supplier");
    jp.add(button1);
    jp.add(button2);
    jp.add(button3);
    jp.add(button4);
    jp.add(button5);
    button1.addActionListener(this);
    button2.addActionListener(this);
    button3.addActionListener(this);
    button4.addActionListener(this);
    button5.addActionListener(this);
    setTitle("CSIT");
    setSize(1280,720);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setVisible(true);
    public void actionPerformed(ActionEvent e){
    if (e.getSource() == jtf){
         jtf.setText("");
    if (e.getSource() == button1) jtb.setBackground(Color.RED);
    if (e.getSource() == button2) jtb.setBackground(Color.GREEN);
    if (e.getSource() == button3) jtb.setBackground(Color.BLUE);
    if (e.getSource() == button4) jtb.setBackground(Color.ORANGE);
    if (e.getSource() == button5) jtb.setBackground(Color.YELLOW);
    public static void main(String args[]) throws Exception{
         new myguidemo();
    Edited by: rizzo18 on Dec 12, 2009 1:46 PM
    Edited by: rizzo18 on Dec 12, 2009 2:06 PM

    I'm trying to run a query in a JTextField and then have that query display the output in a JTable.1. Write classes that only do JDBC. If there is any GUI code at all in them then it is wrong.
    2. Test those classes and modify until they work.
    3. Use those classes in your GUI code (other classes) to do what you want.
    Questions about 1 and 2 go in this forum. Questions about 3 go into a GUI forum.
    Use code tags when you post code.

  • Exchange Server Information Store has encountered an error while executing a full-text index query

    Hi Team need help
    Exchange 2013 EAC doesnt show the databases and it gives message
    "Your request couldn't be completed. Please try again in a few minutes."
    Its a 9 Node DAG and I stopped and diabled Search and Search Host controller on all of them
    in the event viewer see a lot of Event id 1012
    Log Name:      Application
    Source:        MSExchangeIS
    Date:          4/1/2013 9:23:48 AM
    Event ID:      1012
    Task Category: General
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      ex1301.dagdc.com
    Description:
    Exchange Server Information Store has encountered an error while executing a full-text index query ("and(or(itemclass:string("IPM.Note*", mode="and"), itemclass:string("IPM.Schedule.Meeting*", mode="and"), itemclass:string("IPM.OCTEL.VOICE*",
    mode="and"), itemclass:string("IPM.VOICENOTES*", mode="and")), subject:string("SearchQueryStxProbe*", mode="and"), folderid:string("48A300C7FBA4DA408B80EB019A1CE94900000000000E0000"))"). Error
    information: System.TimeoutException: Failed to open a channel.
       at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.ExecuteServiceCall(IProcessingEngineChannel& serviceProxy, Action`1 call, Int32 retryCount)
       at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.ExecuteSearchFlow(String flowName, Dictionary`2 inputData)
       at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.<ExecuteInternal>d__18.MoveNext()
       at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.<ExecuteSimple>d__a.MoveNext()
       at Microsoft.Exchange.Server.Storage.FullTextIndex.FullTextIndexQuery.ExecutePagedFullTextIndexQuery(Guid databaseGuid, Guid mailboxGuid, Int32 mailboxNumber, String query, CultureInfo culture, Guid correlationId, QueryLoggingContext loggingContext,
    PagedQueryResults pagedQueryResults)
       at Microsoft.Exchange.Server.Storage.StoreCommonServices.StoreFullTextIndexHelper.ExecuteFullTextIndexQuery(Context context, MailboxState mailboxState, QueryParameters queryParameters, PagedQueryResults pagedQueryResults, ExchangeId searchFolderId,
    SearchExecutionDiagnostics diagnostics)
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="MSExchangeIS" />
        <EventID Qualifiers="49156">1012</EventID>
        <Level>2</Level>
        <Task>1</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2013-04-01T16:23:48.000000000Z" />
        <EventRecordID>192599</EventRecordID>
        <Channel>Application</Channel>
        <Computer>ex1301.dagdc.com</Computer>
        <Security />
      </System>
      <EventData>
        <Data>and(or(itemclass:string("IPM.Note*", mode="and"), itemclass:string("IPM.Schedule.Meeting*", mode="and"), itemclass:string("IPM.OCTEL.VOICE*", mode="and"), itemclass:string("IPM.VOICENOTES*",
    mode="and")), subject:string("SearchQueryStxProbe*", mode="and"), folderid:string("48A300C7FBA4DA408B80EB019A1CE94900000000000E0000"))</Data>
        <Data>System.TimeoutException: Failed to open a channel.
       at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.ExecuteServiceCall(IProcessingEngineChannel&amp; serviceProxy, Action`1 call, Int32 retryCount)
       at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.ExecuteSearchFlow(String flowName, Dictionary`2 inputData)
       at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.&lt;ExecuteInternal&gt;d__18.MoveNext()
       at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.&lt;ExecuteSimple&gt;d__a.MoveNext()
       at Microsoft.Exchange.Server.Storage.FullTextIndex.FullTextIndexQuery.ExecutePagedFullTextIndexQuery(Guid databaseGuid, Guid mailboxGuid, Int32 mailboxNumber, String query, CultureInfo culture, Guid correlationId, QueryLoggingContext loggingContext,
    PagedQueryResults pagedQueryResults)
       at Microsoft.Exchange.Server.Storage.StoreCommonServices.StoreFullTextIndexHelper.ExecuteFullTextIndexQuery(Context context, MailboxState mailboxState, QueryParameters queryParameters, PagedQueryResults pagedQueryResults, ExchangeId searchFolderId,
    SearchExecutionDiagnostics diagnostics)</Data>
        <Binary>5B444941475F4354585D000084000000FF09000000000000000268000000808A00100000000080CA00100000000080B200100000000080D200100000000030FF001000000000309F00100000000030DF001000000000B09D001000000000B0DD001000000000B0ED001000000000B08D001000000000B095001000000000B0A5001000000000</Binary>
      </EventData>
    </Event>

    Hi,
    Please reenable and start the search engine service and try again.
    The simillar case for your reference:
    http://social.technet.microsoft.com/Forums/en-US/exchangesvrgeneral/thread/4f43ef50-b71f-4ab3-8ced-70f1c36c5509
    Hope it is hlepful.
    Fiona Liao
    TechNet Community Support

  • Bind variable error while adding dynamic where clause to VO query

    hi
    i have extended a VO and in the VOImpl i have written the following code
    public class HzPuiClassificationListVOExImpl extends HzPuiClassificationListVOImpl
    public void initQuery(String partyId, String s1, String classCode)
    /* Logging Code*/
    if(this.isLoggingEnabled(OAFwkConstants.PROCEDURE))
    {this.writeDiagnostics(this," > initQuery() , partyId ="+partyId+" , s1 ="+s1+", classCode="+classCode,OAFwkConstants.PROCEDURE);}
    setWhereClauseParams(null);
    setWhereClauseParam(0, classCode);
    setWhereClauseParam(1, classCode);
    setWhereClauseParam(2, partyId);
    String query = super.getQuery();
    * Check if the whereClause is already present
    if(query!=null && query.toUpperCase().indexOf("AAAAA") == -1)
    OAApplicationModule am = (OAApplicationModule)this.getApplicationModule();
    OADBTransaction oadbTxn = am.getOADBTransaction();
    String whereClause = "   class_category IN ("+
    *" SELECT flv.lookup_code"+*
    *" FROM fnd_lookup_values flv, fnd_lookup_values_dfv dfv"+*
    *" WHERE flv.rowid = dfv.row_id"+*
    *" AND flv.lookup_type = 'XXXXX'"+*
    *" AND dfv.context_value = flv.lookup_type"+*
    *" AND dfv.oco_enabled = 'Y' "+*
    this.addWhereClause(whereClause);
    this.executeQuery();
    * This is the default constructor (do not remove)
    public HzPuiClassificationListVOExImpl()
    when i run the page i get this error
    java.sql.SQLException: Missing IN or OUT parameter at index:: 2
    the original vo query below has 3 bind variables
    SELECT *
    FROM (SELECT *
    FROM (SELECT cc.class_category
    ,l.meaning
    FROM hz_class_categories cc
    ,fnd_lookup_types_vl l
    WHERE cc.class_category = l.lookup_type
    AND l.view_application_id = 222
    AND EXISTS (
    SELECT NULL
    FROM hz_code_assignments ca
    WHERE ca.owner_table_name = 'HZ_CLASS_CATEGORIES'
    AND ca.owner_table_id IS NULL
    AND ca.owner_table_key_1 = cc.class_category
    AND ca.class_category = 'CLASS_CATEGORY_GROUP'
    AND ca.class_code = :1
    AND NVL (ca.status, 'A') = 'A'
    AND SYSDATE BETWEEN ca.start_date_active AND NVL (ca.end_date_active, SYSDATE + 1))
    UNION ALL
    SELECT cc.class_category
    ,l.meaning
    FROM hz_class_categories cc
    ,fnd_lookup_types_vl l
    WHERE cc.class_category = l.lookup_type
    AND l.view_application_id = 222
    AND 'INDUSTRIAL_GROUP' <> :2
    AND NOT EXISTS (
    SELECT NULL
    FROM hz_code_assignments ca
    WHERE ca.owner_table_name = 'HZ_CLASS_CATEGORIES'
    AND ca.owner_table_id IS NULL
    AND ca.owner_table_key_1 = cc.class_category
    AND ca.class_category = 'CLASS_CATEGORY_GROUP'
    AND NVL (ca.status, 'A') = 'A'
    AND SYSDATE BETWEEN ca.start_date_active AND NVL (ca.end_date_active, SYSDATE + 1))
    AND hz_classification_v2pub.is_valid_category ('HZ_PARTIES'
    ,cc.class_category
    ,:3) = 'T') a
    WHERE EXISTS (
    SELECT NULL
    FROM hz_class_code_denorm
    WHERE class_category = a.class_category
    AND TRUNC (SYSDATE) BETWEEN NVL (start_date_active, TRUNC (SYSDATE)) AND NVL (end_date_active, TRUNC (SYSDATE))
    AND enabled_flag = 'Y'
    AND LANGUAGE = USERENV ('LANG'))) qrslt
    A similar error was discussed at this link but it did not give final solution
    [http://kr.forums.oracle.com/forums/thread.jspa?threadID=618451]
    help me to solve this issue..
    Thanks,
    Varun
    Edited by: user10707840 on May 19, 2009 7:18 AM

    its not the AM code .. its the code in VOImpl...
    the same code is working in 11i but when its migrated to R12 its giving this error..
    The original seeded VO query in 11i contains the same bind variable :1 at three places
    SELECT * FROM (select class_category, meaning from hz_class_categories, fnd_lookup_types_vl l where hz_class_categories.class_category = l.lookup_type and l.view_application_id = 222 and class_category in (select owner_table_key_1 from hz_code_assignments ca where ca.owner_table_name = 'HZ_CLASS_CATEGORIES' and ca.owner_table_id is null and ca.class_category = 'CLASS_CATEGORY_GROUP' and ca.class_code = :1 and nvl(ca.status, 'A') = 'A' and sysdate between ca.start_date_active and nvl(ca.end_date_active, sysdate+1)) union all select cc.class_category , meaning from hz_class_categories cc, fnd_lookup_types_vl l, hz_class_category_uses cu where cc.CLASS_CATEGORY = cu.class_category AND ( UPPER(CU.ADDITIONAL_WHERE_CLAUSE) LIKE decode(:1, 'ORG_GROUP','%PARTY_TYPE%ORGANIZATION%', 'PERSON_GROUP', '%PARTY_TYPE%PERSON%', '%') or CU.ADDITIONAL_WHERE_CLAUSE IS NULL or UPPER(CU.ADDITIONAL_WHERE_CLAUSE) LIKE '%WHERE 1=1%' ) and cu.owner_table = 'HZ_PARTIES' and cc.class_category = l.lookup_type and l.view_application_id = 222 and cc.class_category not in (select owner_table_key_1 from hz_code_assignments hca where hca.owner_table_name = 'HZ_CLASS_CATEGORIES' and hca.owner_table_id is null and hca.class_category = 'CLASS_CATEGORY_GROUP' and nvl(hca.status, 'A') = 'A' and sysdate between hca.start_date_active and nvl(hca.end_date_active, sysdate+1)) and cc.class_category not in ( 'RELATIONSHIP_TYPE_GROUP', 'CLASS_CATEGORY_GROUP') and 'INDUSTRIAL_GROUP' <> :1) QRSLT ORDER BY meaning
    the code working in 11i had only one setWhereClauseParam line i.e. setWhereClauseParam(0, classCode);
    when i ran the same code in R12 it errd out..
    I checked the original R12 query... it has 3 bind variables :1 , :2 and :3 ... so i added 2 more setWhereClauseParam statements
    setWhereClauseParam(1, classCode);
    setWhereClauseParam(2, partyId);
    but still its giving the same error
    ORIGINAL R12 query already posted above...

  • SQL query works in access 2000 but not through JDBC

    Hello to all as my first posted message, I have a bit of a pickle on my hands. I have a query which is critical to for my application to function.
    In Access 2000
    SELECT sb.SeatName
    FROM SeatBooking sb, Movie m, MovieSession ms, Booking b
    WHERE m.MovieId = ms.MovieId
    AND ms.MovieSessionId = b.MovieSessionId
    AND b.BookingId = sb.BookingId
    AND ms.DateOfSession = #2003/04/16 07:15:00 PM#;
    This query works fine. When I insert it into my code
    String query = "SELECT sb.SeatName \n" +
    "FROM SeatBooking sb, Movie m, MovieSession ms, Booking b \n" +
    "WHERE m.MovieId = ms.MovieId \n" +
    "AND ms.MovieSessionId = b.MovieSessionId \n" +
    "AND b.BookingId = sb.BookingId \n" +
    "AND ms.DateOfSession = #" +
    cp.getMovieSessionAt(i).getTrueTimeOfSession() + "#;";
    The last line of code returns #2003/04/16 07:15:00 PM#; Which is the exact same as in Access.
    To rule out some possibilities
    - there are other less complicated queries which access the same database but work fine. so my code seems to be ok
    - I have tried to use Format() on ms.DateOfSession to match the return value of the java statement (Which is a general date in Access in the format of 16/04/2003 7:15:00 PM)
    Any suggestions would be appreciated!

    Hi Simon,
    On my Windows XP system with J2SE SDK version 1.4.1_02 and Micro$oft Access 2002, I have the following table:
    column name    column type
    id             Number
    name           Text
    updated        Date/TimeUsing the JDBC-ODBC bridge driver (that is part of the J2SE distribution), the following code uses the JDBC "escape" syntax -- and it works.
    import java.sql.*;
    public class JdbcOdbc {
      public static void main(String[] args) {
        Connection dbConn = null;
        ResultSet rs = null;
        Statement stmt = null;
        String sql =
          "SELECT * FROM Table1 WHERE updated = {ts '2003-04-13 07:53:23'}";
        try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          dbConn = DriverManager.getConnection("jdbc:odbc:db1");
          stmt = dbConn.createStatement();
          rs = stmt.executeQuery(sql);
          if (rs.next()) {
            System.out.println("id      = " + rs.getInt(1));
            System.out.println("name    = " + rs.getString(2));
            System.out.println("updated = " + rs.getTimestamp(3));
        catch (SQLException sqlEx) {
          System.err.println("Database operation failed.");
          sqlEx.printStackTrace();
        catch (ClassNotFoundException cnfEx) {
          System.err.println("JDBC driver class not found");
          cnfEx.printStackTrace();
        finally {
          if (rs != null) {
            try {
              rs.close();
            catch (SQLException sqlEx) {
              System.err.println("ERROR: Failed to close result set");
              sqlEx.printStackTrace();
          if (stmt != null) {
            try {
              stmt.close();
            catch (SQLException sqlEx) {
              System.err.println("ERROR: Failed to close statement");
              sqlEx.printStackTrace();
          if (dbConn != null) {
            try {
              dbConn.close();
            catch (SQLException sqlEx) {
              System.err.println("ERROR: Failed to close DB connection");
              sqlEx.printStackTrace();
    }More details about the JDBC escape syntax are available here:
    http://java.sun.com/j2se/1.4.1/docs/guide/jdbc/getstart/statement.html#999472
    Hope this helps you.
    Good Luck,
    Avi.

  • Problem with return a ColdFusion query object from a Java class

    Hi!
    I need to return a ColdFusion query object from a Java class
    using a JDBC result set ( java.sql.ResultSet);
    I have tried to pass my JDBC result set in to the constructor
    of the coldfusion.sql.QueryTable class with this code:
    ColdFusion code
    <cfset pra = createObject("java","QueryUtil").init()>
    <cfset newQuery = CreateObject("java",
    "coldfusion.sql.QueryTable")>
    <cfset newQuery.init( pra.getColdFusionQuery () ) >
    My java class execute a query to db and return QueryTable
    Java code (QueryUtil.java)
    import coldfusion.sql.QueryTable; // (CFusion.jar for class
    QueryTable)
    import com.allaire.cfx //(cfx.jar for class Query used from
    QueryTable)
    public class QueryUtil
    public static coldfusion.sql.QueryTable
    getColdFusionQuery(java.sql.ResultSet rs)
    return new coldfusion.sql.QueryTable(rs);
    but when i run cfm page and coldfusion server tries to
    execute : "<cfset pra =
    createObject("java","QueryUtil").init()>" this error appears:
    Object Instantiation Exception.
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    If i try to execute QueryUtil.java with Eclipse all it works.
    Also I have tried to return java.sql.ResultSet directly to
    coldfusion.sql.QueryTable.init () with failure.
    Do you know some other solution?

    ok
    i print all my code
    pratica.java execute a query to db and return a querytable
    java class
    import java.util.*;
    import java.sql.*;
    import coldfusion.sql.*;
    public class Pratica {
    private HashMap my;
    private String URI,LOGIN,PWD,DRIVER;
    private Connection conn=null;
    //funzione init
    //riceve due strutture converite in hashmap
    // globals
    // dbprop
    public Pratica(HashMap globals,HashMap dbprop) {
    my = new HashMap();
    my.put("GLOBALS",globals);
    my.put("DBPROP",dbprop);
    URI = "jdbc:sqlserver://it-bra-s0016;databaseName=nmobl";
    LOGIN = "usr_dev";
    PWD = "developer";
    DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    try{
    // Carico il driver JDBC per la connessione con il database
    MySQL
    Class.forName(DRIVER);
    /* Connessione alla base di dati */
    conn=DriverManager.getConnection(URI,LOGIN,PWD);
    if(conn!=null) System.out.println("Connection Successful!");
    } catch (ClassNotFoundException e) {
    // Could not find the database driver
    System.out.print("\ndriver non trovato "+e.getMessage());
    System.out.flush();
    catch (SQLException e) {
    // Could not connect to the database
    System.out.print("\nConnessione fallita "+e.getMessage());
    System.out.flush();
    //funzione search
    //riceve un hash map con i filtri di ricerca
    public QueryTable search(/*HashMap arg*/) {
    ResultSet rs=null;
    Statement stmt=null;
    QueryTable ret=null;
    String query="SELECT * FROM TAN100pratiche";
    try{
    stmt = conn.createStatement();// Creo lo Statement per
    l'esecuzione della query
    rs=stmt.executeQuery(query);
    // while (rs.next()) {
    // System.out.println(rs.getString("descrizione"));
    catch (Exception e) {
    e.printStackTrace();
    try {
    ret = Pratica.RsToQueryTable(rs);
    } catch (SQLException e) {
    e.printStackTrace();
    this.close();
    return(ret);
    // ret=this.RsToQuery(rs);
    // this.close(); //chiude le connessioni,recordset e
    statament
    //retstruct CF vede HashMap come struct
    //METODO DI TEST
    public HashMap retstruct(){
    return(my);
    //conversione resultset to querytable
    private static QueryTable RsToQueryTable(ResultSet rs)
    throws SQLException{
    return new QueryTable(rs);
    //chiura resultset statament e connessione
    private void close(){
    try{
    conn.close();
    conn=null;
    catch (Exception e) {
    e.printStackTrace();
    coldfusion code
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN">
    <html>
    <head>
    <title>Test JDBC CFML Using CFScript</title>
    </head>
    <body>
    <cftry>
    <cfset glb_map =
    createObject("java","java.util.HashMap")>
    <cfset dbprop_map =
    createObject("java","java.util.HashMap")>
    <cfset glb_map.init(glb)> <!---are passed from
    another page--->
    <cfset dbprop_map.init(glb["DBPROP"])>
    <cfset pra =
    createObject("java","Pratica").init(glb_map,dbprop_map)>
    <cfset ourQuery
    =createObject("java","coldfusion.sql.QueryTable").init(pra.search())>
    <cfcatch>
    <h2>Error - info below</h2>
    <cfdump var="#cfcatch#"><cfabort>
    </cfcatch>
    </cftry>
    <h2>Success - statement dumped below</h2>
    <cfdump var="#ourQuery#">
    </body>
    </html>
    error at line <cfset pra =
    createObject("java","Pratica").init(glb_map,dbprop_map)>
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    -----------------------------------------------------------------------

Maybe you are looking for

  • Storage Server 2008 R2 backup failure on Windows 8.1 Pro client

    I have a Lenovo Yoga 2 Pro laptop that will not backup to my Windows 2008 R2 Storage Server. These are the most recent events: Log Name:      Application Source:        .NET Runtime Date:          10/2/2014 11:06:10 AM Event ID:      1026 Task Catego

  • How to use TreeExpanderWidget, there is no example or specification about this widget, anyone can tell me how to use it thanks.

    Now I have a TreeView, it works fine.  But all the items in the tree are displayed directly, I want they are collapse at start and just expand on click event ,just like the following picture . I searched all the SDK ,there is no example about this .

  • Newsstand problem

    I subscribe to the Magic Magazine through the App Store and this gets downloaded to the newsstand. Recently though I have been unable to access the magazine when I am offline and when I attempt to it looks like the mag is about to open but then rever

  • RMX Stylus Multi Channel

    I'm trying to Multi Channel Stylus RMX. After I set up 8 Aux tracks in Logic, and change each output in Stylus mixer. I dragged, and dropped the midi pattern on the instrument track, but did not hear any sound when I hit play in Logic. I only hear so

  • TS1368 How can i contact itunes support ?

    I have problem when i want some gold in my game clash of clan , they said Contact itunes support to complet this ?, how ?