Converting the resultset to an arraylist

In my application, I was successful in getting connectivity with the Oracle db and successfully queried it.
I checked out that the ResultSet displayed correct values.
Can I convert this ResultSet into some say ArrayList or something so that it remains with me thoughout the execution of the program? I mean I will have to query the database many times, so this ResultSet will need to be closed.
Is there a problem if copy it into another ResultSet object and dont close it ?

Google Pagination, or possibly better, if it all takes place within a single application, is to design a class for this "query" that preforms the query when initialized, then keeps the ResultSet open until some other part of the program calls some method on the class to close everything up, and use access methods to return specific parts of the data from the query.
i.e.
public class Bogus {
  private Connection conn;
  private Statment stmt;
  private ResultSet rs;
  public Bogus () {
    //open conn, perform query, assign rs
  public Object[] getRow() {
    // assign elements in Row to an Object[] and return it
  public void cleanup () {
    //close the rs, stmt, and conn
}Then pass around the reference to this object.

Similar Messages

  • How to convert DataServices.Result into an Arraylist or ArrayCollection?

    I want to use an ArrayCollection or an ArrayList as a data provider
    for a dataGrid, and then later in a Graph.
    The problem is that the starting point is the FLEX Builder 4 created "datasource.lastResult" value Objects.
    I don't know how to access anything but the Column names.
    The fields returned are:
         gmtdate,hostname,CPUBusy
    I want to show CPU busy for "N" number of hosts.
    So I need to change my result from the SQL query in Action Script into:
        gmtdate, hostname1_CPUbusy, hostname2_CPUbusy, hostnameN_CPUbusy
    Are there any samples of how to convert the .lastResult into an ArrayList?
    The result set is Object based and I can't figure out how to read it.
    Thanks,
    David

    I wish I could change it, but Oracle SQL does not allow for an unknown number of hosts.
    Nor does this version of Oracle have the new pivot function.
    David

  • Converting a ResultSet to a Vector

    hiya i gota question...(my code is below)...im doing a search query which searches the database for the search field and then these gets the results into a ResultSet.
    i then need to print these out in a table kinda thing but at the moment the results are bunched together. this is a problem cos the <A HREF> link is highlighting all the results whereas each result needs to be linked to another page.
    THEREFORE i think i need to convert the resultset to a vector and then print out the vector one by one onto the jsp page.
    Enumeration enum = v.elements();
    while(enum.hasMoreElements()) {
    String s = (String) enum.nextElement();
    query = "SELECT * FROM Login_Details LD, Personal_Details PD, Education E, Work_Experience WE, Skills S WHERE
    LD.Email_Address = PD.Email_Address AND LD.Email_Address = E.Email_Address AND LD.Email_Address = WE.Email_Address AND
    LD.Email_Address = S.Email_Address AND PD.Surname = '" + s + "'";
    ResultSet rs = st.executeQuery(query);
    while(rs.next()) {
    %>
    <%out.println(rs.getString("Surname")); out.println(", "); out.println(rs.getString("Forename"));%>
    <%
    any ideas ???
    thanks

    Hi
    Try this
    <TABLE border=1>
    <%
         while(rs.next()){%>
    <TR>
         <TD>
         <%=rs.getString("Surname")+" "+rs.getString("Forename")%>
         </TD>
    </TR>
         <%}%>
    </TABLE>
    Mars Amutha

  • A bug in the ResultSet.getString method?

    Hi,
    I am using a 8.1.6 database with UTF8 character set on a Win2000 machine. I've inserted some Hebrew characters into a table, and have been able to read them back properly using SQL+.
    However, when I try to retrieve these values from a simple Java program using the resultSet.getString method (via Oracle JDBC driver 8.1.6) I always get the '?' character for every Hebrew character (English characters work fine). However, if I call the 'getBytes' method of the result set, and create a new String instance from that data, it works fine - help needed!
    Thanks...
    null

    However, if I call the 'getBytes' method of the result set, and create a new String instance from that data, it works fine - help needed!Thanks...
    Please show me how to using 'getBytes' method of the result set and create a new string instance from THAT DATA, because this way doesn't work for me. I am converting ZHT16DBT to Unicode, and all I got is ?????.
    Please help me if you have any idea. THANKS
    null

  • The ResultSet class is not very convenient to use

    Often we need to know how many rows have been retrieved from the database before we read each row's data in order to do preparation works such as allocate appropriate memories to store the data.The ResultSet class in java.sql package does not provide a function to retrieve the total rows read from the database. We must do the follow to get the count of rows:
    ResultSet rs;
    rs.last();
    int lastrow = rs.getRow();
    rs.first();
    int firstrow = rs.getRow();
    int rows = lastrow - firstrow + 1;
    String [] data = new String[rows];
    // retrieve each row's data into the string array
    It would be much more convenient if the class can provide a function like:
    rs.getRows();

    Often we need to know how many rows have been
    retrieved from the database before we read each row's
    data in order to do preparation works such as allocate
    appropriate memories to store the data.But then we learn a little bit of Java and realize we can add the rows to a List (such as an ArrayList) without having to know that number in advance.

  • The issue about the ResultSet.TYPE_SCROLL_INSENSITIVE

    my database is oracle ,the oracle charset is "us7ascii".and i save chinese charset in the database ,normally ,i get the data from the database ,use
    Statement s =conn.createStatement();
    then execute the sql, then use
    new String (string.getBytes("iso-8859-1"),"gbk")
    i can get the correct data.but if i use:
    Statement s = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    still use:
    new String (string.getBytes("iso-8859-1"),"gbk")
    convert the encode,but i can't get the correct data ,the result is "?????" ,why ?

    rp0428 wrote:
    Really? Please explain how that is possible.
    The US7ASCII only uses 7 bits to represent each character so can only represent 128 characters; none of them are chinese.Perhaps the sleazy hack "new String(string.getBytes())" actually works to encode and decode characters between Unicode and 7-bit ASCII -- but I haven't got the energy to figure out how it might work. My response to this sort of question is "Configure Oracle with the right character set in the first place so you don't have to deal with it at the application level".

  • Number of rows returned by the resultset is wrong

    Hi All,
    I have pasted the code i used for JDBC. The problem is the number of rows returned by the resultset is 5 times that of the original data. Is something wrong with my code. Can anyone pls point out the mistake I have done if any.
        public ArrayList dataBreakup(String team, int monthNo, int year) {         String sqlDataBreakup = "";         Connection con1 = null;         Statement stmt = null;         ResultSet rs = null;         ArrayList data = new ArrayList();         int noRows = 0;         Calendar cal = Calendar.getInstance();         Calendar cal2 = new GregorianCalendar(cal.get(Calendar.YEAR), monthNo, 1);         int days = cal2.getActualMaximum(cal2.DAY_OF_MONTH);         String start_date = "01-Jan-" + year;         String end_date = days + "-" + monthName[cal2.get(Calendar.MONTH)] + "-" + cal2.get(cal2.YEAR);         System.out.println("START: " + start_date);         System.out.println("END: " + end_date);         databaseConnection dbObject = new databaseConnection();         try {             con1 = dbObject.GetConnection();             stmt = con1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);             sqlDataBreakup = "Select * from EXPENSE_STORE WHERE " +                     "team='" + team + "'AND category != 'Pending PO''s' AND ACCOUNTING_DATE " +                     "BETWEEN to_date('" + start_date + "') AND to_date('" + end_date + "')";             rs = stmt.executeQuery(sqlDataBreakup);                         ResultSetMetaData rsmd = rs.getMetaData();             int numColumns = rsmd.getColumnCount();             data.add(numColumns);             for (int i = 1; i < numColumns + 1; i++) {                 data.add(rsmd.getColumnName(i));             }                        while (rs.next()) {                                noRows++;                 for (int i = 1; i < numColumns + 1; i++) {                     switch (rsmd.getColumnType(i)) {                         case java.sql.Types.NUMERIC:                             data.add(rs.getFloat(i));                             break;                         case java.sql.Types.DATE:                             data.add(rs.getDate(i));                             break;                         default:                             data.add(rs.getString(i));                             break;                     }                                    }                     }             data.add(1, noRows);             rs.close();         } catch (SQLException SQLe) {             System.out.println("DumpData() : SQL Exception" + SQLe.getMessage());             SQLe.printStackTrace();         } catch (Exception e) {             System.out.println("DumpData() : Other Exception");             e.printStackTrace();         } finally {             dbObject.CloseConnection(con1);         }         return data;     }
    Thanks
    Cheers N...

    Only thing i can say is
    try the following
    replace your function by this one and tell us the console output of the same
    public ArrayList dataBreakup(String team, int monthNo, int year) {
            String sqlDataBreakup = "";
            Connection con = null;          
            ArrayList data = new ArrayList();
            int noRows = 0;
            Calendar cal = Calendar.getInstance();
            Calendar cal2 = new GregorianCalendar(cal.get(Calendar.YEAR), monthNo, 1);
            int days = cal2.getActualMaximum(cal2.DAY_OF_MONTH);
            String start_date = "01-Jan-" + year;
            String end_date = days + "-" + monthName[cal2.get(Calendar.MONTH)] + "-" + cal2.get(cal2.YEAR);
            System.out.println("START: " + start_date);
            System.out.println("END: " + end_date);
            System.out.println("START: " + start_date);
            System.out.println("END: " + end_date);
            databaseConnection dbObject = new databaseConnection();
            try {
                con = dbObject.GetConnection();          
                sqlDataBreakup = "Select * from EXPENSE_STORE WHERE " +
                        "team = '"+team+"' AND category != 'Pending PO''s' AND ACCOUNTING_DATE " +
                        "BETWEEN to_date('"+start_date+"') AND to_date('"+end_date+"')";
                   System.out.println("-----------sql starts---------------");
                   System.out.println(sqlDataBreakup);
                   System.out.println("-----------sql ends---------------");
                PreparedStatement pstmt = con.prepareStatement(sqlDataBreakup);
                   pstmt.setString(1, team);
                pstmt.setString(2, start_date);
                pstmt.setString(3, end_date);
                ResultSet rs = pstmt.executeQuery();
                ResultSetMetaData rsmd = rs.getMetaData();
                int numColumns = rsmd.getColumnCount();
                data.add(numColumns);
                for (int i = 1; i < numColumns + 1; i++) {
                    data.add(rsmd.getColumnName(i));
                while (rs.next()) {
                    noRows++;
                    for (int i = 1; i < numColumns + 1; i++) {
                        switch (rsmd.getColumnType(i)) {
                            case java.sql.Types.NUMERIC:
                                data.add(rs.getFloat(i));
                                break;
                            case java.sql.Types.DATE:
                                data.add(rs.getDate(i));
                                break;
                            default:
                                data.add(rs.getString(i));
                                break;
                //data.add(1, noRows);
                   System.out.println("no of Rows : " +noRows );
            } catch (SQLException SQLe) {
                System.out.println("DumpData() : SQL Exception" + SQLe.getMessage());
                SQLe.printStackTrace();
            } catch (Exception e) {
                System.out.println("DumpData() : Other Exception");
                e.printStackTrace();
            } finally {
                dbObject.CloseConnection(con);
            return data;
        }and try running the sql printed on the screen in your db and then let us know the result.
    in this code i have removed some of your code in order to simplify the problem.

  • I need to convert PDF file to Word Document, so it can be edited. But the recognizing text options do not have the language that I need. How I can convert the file in the desired of me language?

    I need to convert PDF file to Word Document, so it can be edited. But the recognizing text options do not have the language that I need. How I can convert the file in the desired of me language?

    The application Acrobat provides no language translation capability.
    If you localize the language for OS, MS Office applications, Acrobat, etc to the desired language try again.
    Alternative: transfer a copy of content into a web based translation service (Bing or Google provides a free service).
    Transfer the output into a word processing program that is localized to the appropriate language.
    Do cleanup.
    Be well...

  • When I sign in to the Adobe Reader XI (which is the only option that I have to open a pdf document, I will sign in to the Adobe ID sign-in page. After I do this, the "Convert To" box goes "gray" and I am unable to convert the document I have selected.  It

    When I sign in to the Adobe Reader XI (which is the only option that I have to open a pdf document, I will sign in to the Adobe ID sign-in page. After I do this, the "Convert To" box goes "gray" and I am unable to convert the document I have selected.  It was working great for the first week that I used it, but now it doesn't give me the converting option.  I am very frustrated as I have done nothing to change anything, and I was thinking this was so great...now I am just pulling out my hair and do not have the option of calling anyone since no phone numbers are listed. I am VERY busy and do not have time to sit and wait over a half an hour to "chat", which I tried to do yesterday.  All I want to do is very simply, convert pdfs to Word.  I have paid for this and am not getting any help. I am not very savvy when it comes to Adobe this program and Adobe that program...I feel I am being scammed as I do not get simple answers for something that appeared was going to be simple. You can't even call customer service to talk to someone live to help walk you through. 

    Hello Kathie,
    Sorry for the inconvenience that has caused to you.
    Please let me know if you have tried converting any other PDF to word with Reader.
    Alos, please sign up at "https://cloud.acrobat.com/" using your Adobe ID credentials. Click on 'ExportPDF' tab and upload the PDF that you want to convert to Word.
    Let me know if this converts fine.
    Hope to hear from you.
    regards,
    Anubha

  • Which is the best software to convert the video files for itouch?

    I got a 3rd gen itouch. Is there any software that helps to convert the video files. so I can sync those files to my itouch. " Handbrake " used to work pretty good. but now i still can convert the video files to m4v format but itunes doesn't allow me to put those files in. Please Help!

    You may have different menu options than Half bit Bit Ah. The support page on how to do it is at https://support.apple.com/kb/TS1497. In part it says:
    If you did not purchase videos from the iTunes Store, they are may not be in a format that you can play on your iPhone/iPod. In many cases, you can convert them to the correct format using iTunes or QuickTime.
    * Using iTunes: Select a video and choose Advanced > Create iPod or iPhone Version
    * Using Mac OS X v10.6: Open the video in QuickTime Player and choose Share > iTunes and then select the iPhone & iPod option.
    Hope that helps!

  • Why does JDBC keep connections open even though I close the resultsets?

    I attached my program and my output. Please bear with me for the long output. My question here is why do the connections remain even though I closed the resultsets. I need to reuse my prepared statements, but don't want to keep the oracle sessions open. Is this possible? What do I need to do?
    If you notice in the program, I have executed the query to find the number of open sessions 5 times.
    1) After creating the connections
    2) After creating the prepared statements
    3) After executing them
    4) After getString on the resultSets
    5) After closing the resultsets.
    And the sessions are still there even is Step 5 :-(
    import java.sql.*;
    * Title:
    * Description:
    * Copyright: Copyright (c) 2001
    * Company:
    * @author
    * @version 1.0
    public class Test {
    String dburl = "jdbc:oracle:thin:@oracle92:1521:oracle92";
    String query = "select s.username,s.sid ,s.logon_time, s.serial#,sql.sql_text"+
    " from v$session s, v$sqltext sql where sql.address = "+
    "s.sql_address and sql.hash_value = s.sql_hash_value "+
    "and upper(s.username) like 'KRTEMP%'"+
    " order by s.username ,s.sid ,s.serial# ,sql.piece" ;
    // String query = "select s.username, s.sid ,s.logon_time, s.status from v$session s where upper(s.username) like 'KRTEMP%'";
    public Test(int num) throws Exception {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection[] con = new Connection[num];
    for(int i=0; i<num; i++) {
    con[i] = DriverManager.getConnection(dburl, "krtemp", "krtemp");
    executeQuery();
    PreparedStatement[] ps = new PreparedStatement[num];
    for(int i=0; i<num; i++) {
    ps[i] = con.prepareStatement("select * from contact");
    executeQuery();
    ResultSet[] rs = new ResultSet[num];
    for(int i=0; i<num; i++) {
    rs[i] = ps[i].executeQuery();
    executeQuery();
    for(int i=0; i<num; i++) {
    ResultSetMetaData meta = rs[i].getMetaData();
    while(rs[i].next()) {
    for(int j=1; j<=meta.getColumnCount(); j++) {
    rs[i].getString(j);
    executeQuery();
    for(int i=0; i<num; i++) {
    rs[i].close();
    executeQuery();
    private void executeQuery() throws Exception {
    Connection con = DriverManager.getConnection(dburl, "krtemp", "krtemp");
    PreparedStatement ps = con.prepareStatement(query);
    ResultSet rs = ps.executeQuery();
    ResultSetMetaData meta = rs.getMetaData();
    System.out.println("-----");
    while(rs.next()) {
    for(int i=1; i<=meta.getColumnCount(); i++) {
    System.out.print(rs.getString(i));
    System.out.print(" ");
    System.out.println();
    System.out.println("-----");
    public static void main(String[] args) throws Exception {
    Test test = new Test(5);
    The output is
    KRTEMP 9 2005-06-27 17:09:30.0 5436 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS WH
    ERE PARAMETER ='NLS_
    KRTEMP 9 2005-06-27 17:09:30.0 5436 DATE_FORMAT'
    KRTEMP 34 2005-06-26 18:51:01.0 3629 rename tstore to store
    KRTEMP 37 2005-06-27 17:09:25.0 4209 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS W
    HERE PARAMETER ='NLS_
    KRTEMP 37 2005-06-27 17:09:25.0 4209 DATE_FORMAT'
    KRTEMP 74 2005-06-27 17:09:26.0 17625 select appId from profile_application_tabl
    e wher
    KRTEMP 74 2005-06-27 17:09:26.0 17625 e appName=:1 and appVersion=:2
    KRTEMP 83 2005-06-27 17:09:25.0 1771 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS W
    HERE PARAMETER ='NLS_
    KRTEMP 83 2005-06-27 17:09:25.0 1771 DATE_FORMAT'
    KRTEMP 105 2005-06-27 17:09:30.0 3296 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 105 2005-06-27 17:09:30.0 3296 DATE_FORMAT'
    KRTEMP 111 2005-06-27 17:09:25.0 4878 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 111 2005-06-27 17:09:25.0 4878 DATE_FORMAT'
    KRTEMP 153 2005-06-27 17:09:30.0 31065 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 153 2005-06-27 17:09:30.0 31065 DATE_FORMAT'
    KRTEMP 163 2005-06-27 17:09:30.0 3205 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 163 2005-06-27 17:09:30.0 3205 DATE_FORMAT'
    KRTEMP 183 2005-06-27 17:09:30.0 3465 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 183 2005-06-27 17:09:30.0 3465 DATE_FORMAT'
    KRTEMP 191 2005-06-27 17:09:26.0 5438 select appId from profile_application_tabl
    e wher
    KRTEMP 191 2005-06-27 17:09:26.0 5438 e appName=:1 and appVersion=:2
    KRTEMP 256 2005-06-27 17:09:30.0 2718 select s.username,s.sid ,s.logon_time, s.s
    erial#,sql.sql_text fr
    KRTEMP 256 2005-06-27 17:09:30.0 2718 om v$session s, v$sqltext sql where sql.ad
    dress = s.sql_address
    KRTEMP 256 2005-06-27 17:09:30.0 2718 and sql.hash_value = s.sql_hash_value and
    upper(s.username) like
    KRTEMP 256 2005-06-27 17:09:30.0 2718 'KRTEMP%' order by s.username ,s.sid ,s.s
    erial# ,sql.piece
    KRTEMP 9 2005-06-27 17:09:30.0 5436 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS WH
    ERE PARAMETER ='NLS_
    KRTEMP 9 2005-06-27 17:09:30.0 5436 DATE_FORMAT'
    KRTEMP 34 2005-06-26 18:51:01.0 3629 rename tstore to store
    KRTEMP 37 2005-06-27 17:09:25.0 4209 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS W
    HERE PARAMETER ='NLS_
    KRTEMP 37 2005-06-27 17:09:25.0 4209 DATE_FORMAT'
    KRTEMP 74 2005-06-27 17:09:26.0 17625 select appId from profile_application_tabl
    e wher
    KRTEMP 74 2005-06-27 17:09:26.0 17625 e appName=:1 and appVersion=:2
    KRTEMP 83 2005-06-27 17:09:25.0 1771 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS W
    HERE PARAMETER ='NLS_
    KRTEMP 83 2005-06-27 17:09:25.0 1771 DATE_FORMAT'
    KRTEMP 105 2005-06-27 17:09:30.0 3296 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 105 2005-06-27 17:09:30.0 3296 DATE_FORMAT'
    KRTEMP 111 2005-06-27 17:09:25.0 4878 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 111 2005-06-27 17:09:25.0 4878 DATE_FORMAT'
    KRTEMP 153 2005-06-27 17:09:30.0 31065 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 153 2005-06-27 17:09:30.0 31065 DATE_FORMAT'
    KRTEMP 163 2005-06-27 17:09:30.0 3205 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 163 2005-06-27 17:09:30.0 3205 DATE_FORMAT'
    KRTEMP 183 2005-06-27 17:09:30.0 3465 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 183 2005-06-27 17:09:30.0 3465 DATE_FORMAT'
    KRTEMP 191 2005-06-27 17:09:26.0 5438 select appId from profile_application_tabl
    e wher
    KRTEMP 191 2005-06-27 17:09:26.0 5438 e appName=:1 and appVersion=:2
    KRTEMP 232 2005-06-27 17:09:31.0 5893 select s.username,s.sid ,s.logon_time, s.s
    erial#,sql.sql_text fr
    KRTEMP 232 2005-06-27 17:09:31.0 5893 om v$session s, v$sqltext sql where sql.ad
    dress = s.sql_address
    KRTEMP 232 2005-06-27 17:09:31.0 5893 and sql.hash_value = s.sql_hash_value and
    upper(s.username) like
    KRTEMP 232 2005-06-27 17:09:31.0 5893 'KRTEMP%' order by s.username ,s.sid ,s.s
    erial# ,sql.piece
    KRTEMP 34 2005-06-26 18:51:01.0 3629 rename tstore to store
    KRTEMP 37 2005-06-27 17:09:25.0 4209 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS W
    HERE PARAMETER ='NLS_
    KRTEMP 37 2005-06-27 17:09:25.0 4209 DATE_FORMAT'
    KRTEMP 74 2005-06-27 17:09:26.0 17625 select appId from profile_application_tabl
    e wher
    KRTEMP 74 2005-06-27 17:09:26.0 17625 e appName=:1 and appVersion=:2
    KRTEMP 83 2005-06-27 17:09:25.0 1771 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS W
    HERE PARAMETER ='NLS_
    KRTEMP 83 2005-06-27 17:09:25.0 1771 DATE_FORMAT'
    KRTEMP 111 2005-06-27 17:09:25.0 4878 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 111 2005-06-27 17:09:25.0 4878 DATE_FORMAT'
    KRTEMP 232 2005-06-27 17:09:31.0 5893 select s.username,s.sid ,s.logon_time, s.s
    erial#,sql.sql_text fr
    KRTEMP 232 2005-06-27 17:09:31.0 5893 om v$session s, v$sqltext sql where sql.ad
    dress = s.sql_address
    KRTEMP 232 2005-06-27 17:09:31.0 5893 and sql.hash_value = s.sql_hash_value and
    upper(s.username) like
    KRTEMP 232 2005-06-27 17:09:31.0 5893 'KRTEMP%' order by s.username ,s.sid ,s.s
    erial# ,sql.piece
    KRTEMP 256 2005-06-27 17:09:31.0 2783 select s.username,s.sid ,s.logon_time, s.s
    erial#,sql.sql_text fr
    KRTEMP 256 2005-06-27 17:09:31.0 2783 om v$session s, v$sqltext sql where sql.ad
    dress = s.sql_address
    KRTEMP 256 2005-06-27 17:09:31.0 2783 and sql.hash_value = s.sql_hash_value and
    upper(s.username) like
    KRTEMP 256 2005-06-27 17:09:31.0 2783 'KRTEMP%' order by s.username ,s.sid ,s.s
    erial# ,sql.piece
    KRTEMP 9 2005-06-27 17:09:30.0 5436 select * from contact
    KRTEMP 34 2005-06-26 18:51:01.0 3629 rename tstore to store
    KRTEMP 37 2005-06-27 17:09:25.0 4209 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS W
    HERE PARAMETER ='NLS_
    KRTEMP 37 2005-06-27 17:09:25.0 4209 DATE_FORMAT'
    KRTEMP 74 2005-06-27 17:09:26.0 17625 select appId from profile_application_tabl
    e wher
    KRTEMP 74 2005-06-27 17:09:26.0 17625 e appName=:1 and appVersion=:2
    KRTEMP 83 2005-06-27 17:09:25.0 1771 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS W
    HERE PARAMETER ='NLS_
    KRTEMP 83 2005-06-27 17:09:25.0 1771 DATE_FORMAT'
    KRTEMP 105 2005-06-27 17:09:30.0 3296 select * from contact
    KRTEMP 111 2005-06-27 17:09:25.0 4878 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 111 2005-06-27 17:09:25.0 4878 DATE_FORMAT'
    KRTEMP 153 2005-06-27 17:09:30.0 31065 select * from contact
    KRTEMP 163 2005-06-27 17:09:30.0 3205 select * from contact
    KRTEMP 173 2005-06-27 17:09:31.0 3922 select s.username,s.sid ,s.logon_time, s.s
    erial#,sql.sql_text fr
    KRTEMP 173 2005-06-27 17:09:31.0 3922 om v$session s, v$sqltext sql where sql.ad
    dress = s.sql_address
    KRTEMP 173 2005-06-27 17:09:31.0 3922 and sql.hash_value = s.sql_hash_value and
    upper(s.username) like
    KRTEMP 173 2005-06-27 17:09:31.0 3922 'KRTEMP%' order by s.username ,s.sid ,s.s
    erial# ,sql.piece
    KRTEMP 183 2005-06-27 17:09:30.0 3465 select * from contact
    KRTEMP 191 2005-06-27 17:09:26.0 5438 select appId from profile_application_tabl
    e wher
    KRTEMP 191 2005-06-27 17:09:26.0 5438 e appName=:1 and appVersion=:2
    KRTEMP 232 2005-06-27 17:09:31.0 5893 select s.username,s.sid ,s.logon_time, s.s
    erial#,sql.sql_text fr
    KRTEMP 232 2005-06-27 17:09:31.0 5893 om v$session s, v$sqltext sql where sql.ad
    dress = s.sql_address
    KRTEMP 232 2005-06-27 17:09:31.0 5893 and sql.hash_value = s.sql_hash_value and
    upper(s.username) like
    KRTEMP 232 2005-06-27 17:09:31.0 5893 'KRTEMP%' order by s.username ,s.sid ,s.s
    erial# ,sql.piece
    KRTEMP 256 2005-06-27 17:09:31.0 2783 select s.username,s.sid ,s.logon_time, s.s
    erial#,sql.sql_text fr
    KRTEMP 256 2005-06-27 17:09:31.0 2783 om v$session s, v$sqltext sql where sql.ad
    dress = s.sql_address
    KRTEMP 256 2005-06-27 17:09:31.0 2783 and sql.hash_value = s.sql_hash_value and
    upper(s.username) like
    KRTEMP 256 2005-06-27 17:09:31.0 2783 'KRTEMP%' order by s.username ,s.sid ,s.s
    erial# ,sql.piece
    KRTEMP 9 2005-06-27 17:09:30.0 5436 select * from contact
    KRTEMP 34 2005-06-26 18:51:01.0 3629 rename tstore to store
    KRTEMP 37 2005-06-27 17:09:25.0 4209 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS W
    HERE PARAMETER ='NLS_
    KRTEMP 37 2005-06-27 17:09:25.0 4209 DATE_FORMAT'
    KRTEMP 74 2005-06-27 17:09:26.0 17625 select appId from profile_application_tabl
    e wher
    KRTEMP 74 2005-06-27 17:09:26.0 17625 e appName=:1 and appVersion=:2
    KRTEMP 83 2005-06-27 17:09:25.0 1771 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS W
    HERE PARAMETER ='NLS_
    KRTEMP 83 2005-06-27 17:09:25.0 1771 DATE_FORMAT'
    KRTEMP 105 2005-06-27 17:09:30.0 3296 select * from contact
    KRTEMP 111 2005-06-27 17:09:25.0 4878 SELECT VALUE FROM NLS_INSTANCE_PARAMETERS
    WHERE PARAMETER ='NLS_
    KRTEMP 111 2005-06-27 17:09:25.0 4878 DATE_FORMAT'
    KRTEMP 153 2005-06-27 17:09:30.0 31065 select * from contact
    KRTEMP 163 2005-06-27 17:09:30.0 3205 select * from contact
    KRTEMP 183 2005-06-27 17:09:30.0 3465 select * from contact
    KRTEMP 191 2005-06-27 17:09:26.0 5438 select appId from profile_application_tabl
    e wher
    KRTEMP 191 2005-06-27 17:09:26.0 5438 e appName=:1 and appVersion=:2
    KRTEMP 204 2005-06-27 17:09:32.0 1478 select s.username,s.sid ,s.logon_time, s.s
    erial#,sql.sql_text fr
    KRTEMP 204 2005-06-27 17:09:32.0 1478 om v$session s, v$sqltext sql where sql.ad
    dress = s.sql_address
    KRTEMP 204 2005-06-27 17:09:32.0 1478 and sql.hash_value = s.sql_hash_value and
    upper(s.username) like
    KRTEMP 204 2005-06-27 17:09:32.0 1478 'KRTEMP%' order by s.username ,s.sid ,s.s
    erial# ,sql.piece
    KRTEMP 232 2005-06-27 17:09:31.0 5893 select s.username,s.sid ,s.logon_time, s.s
    erial#,sql.sql_text fr
    KRTEMP 232 2005-06-27 17:09:31.0 5893 om v$session s, v$sqltext sql where sql.ad
    dress = s.sql_address
    KRTEMP 232 2005-06-27 17:09:31.0 5893 and sql.hash_value = s.sql_hash_value and
    upper(s.username) like
    KRTEMP 232 2005-06-27 17:09:31.0 5893 'KRTEMP%' order by s.username ,s.sid ,s.s
    erial# ,sql.piece
    KRTEMP 256 2005-06-27 17:09:31.0 2783 select s.username,s.sid ,s.logon_time, s.s
    erial#,sql.sql_text fr
    KRTEMP 256 2005-06-27 17:09:31.0 2783 om v$session s, v$sqltext sql where sql.ad
    dress = s.sql_address
    KRTEMP 256 2005-06-27 17:09:31.0 2783 and sql.hash_value = s.sql_hash_value and
    upper(s.username) like
    KRTEMP 256 2005-06-27 17:09:31.0 2783 'KRTEMP%' order by s.username ,s.sid ,s.s
    erial# ,sql.piece

    Why do the connections stay open? Because you haven't closed them.
    You answered your own question: obviously closing the ResultSet is NOT the same thing as closing the connection.
    When you do a query, you want to get the connection, statement, and result set, load the data from the result set into an object or data structure, and then immediately close them all again in reverse order of creation. You want to keep the scope as narrow as possible. You want to use a connection pool to keep the cost of obtaining a connection down. You should leave caching of the PreparedStatements to the JDBC driver.
    %

  • Need to convert the Varchar2 to decimal

    Hi,
    I need to convert source sybase varchar2 record in to decimal record in Target DB2 table by using the function in Oracle data integrator.
    In my source table, column is defined as varchar2 (4) and in target table same column has defined as Decimal (2). So, is there any function to convert the varchar2 data to decimal record.
    thanks,
    keshav.

    Hi SH,
    Thanx so much for your answer!
    Well actually I have managed to do the filters, and right now dealing with the convertion of formats.
    Right now I am working with Oracle DB 11g, and Excel; and what i would like to do is now that is passing from my uploaded excel the info to my Oracle DB would like to control the ways it pases the info.
    Let's say for example, that I have gotten a Field A in my source table (Excel uploaded to ODI), and that on my Orazle Table on Field A i would like to change the data type of the field, or just make sure that the data inserted will always be of certain type? Can I do this with ODI? Could you please give me some advice in how to it? I assume that it should be done on my interface, in the Diagram tab > Target Database > Mapping Area > Implementation Tab > Expression Editor and modify it there, is it?
    As this is mapping from excel, can I just use the excel function? it does not make any sense for me as it is all in Oracle. I am sorry but I am kinda confused now.
    Once again I do really appreciate your help.

  • Need to convert the binary data in blob field to readable format

    Hi,
    We need to convert the Binary data in the BLOB field to readable format and need to display it in Oracle Apps Environment,does anybody come across the similar requirement.
    please advise, thanks in advance.
    Regards,
    Babu.

    You could use standard Attachments functionality here ... if the blob is not in FND_LOBS, insert into FND_LOBS, fnd_attached_documents etc to enable viewing via "Attachments" to the entity the blob is related to.
    Gareth

  • Need help Take out the null values from the ResultSet and Create a XML file

    hi,
    I wrote something which connects to Database and gets the ResultSet. From that ResultSet I am creating
    a XML file. IN my program these are the main two classes Frame1 and ResultSetToXML. ResultSetToXML which
    takes ResultSet & Boolean value in its constructor. I am passing the ResultSet and Boolean value
    from Frame1 class. I am passing the boolean value to get the null values from the ResultSet and then add those
    null values to XML File. When i run the program it works alright and adds the null and not null values to
    the file. But when i pass the boolean value to take out the null values it would not take it out and adds
    the null and not null values.
    Please look at the code i am posing. I am showing step by step where its not adding the null values.
    Any help is always appreciated.
    Thanks in advance.
    ============================================================================
    Frame1 Class
    ============
    public class Frame1 extends JFrame{
    private JPanel contentPane;
    private XQuery xQuery1 = new XQuery();
    private XYLayout xYLayout1 = new XYLayout();
    public Document doc;
    private JButton jButton2 = new JButton();
    private Connection con;
    private Statement stmt;
    private ResultSetToXML rstx;
    //Construct the frame
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    //Component initialization
    private void jbInit() throws Exception {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    xQuery1.setSql("");
    xQuery1.setUrl("jdbc:odbc:SCANODBC");
    xQuery1.setUserName("SYSDBA");
    xQuery1.setPassword("masterkey");
    xQuery1.setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    xQuery1.setSql("Select * from Pinfo where pid=2 or pid=4");
    jButton2.setText("Get XML from DB");
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(java.lang.ClassNotFoundException ex) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(ex.getMessage());
    try {
    con = DriverManager.getConnection("jdbc:odbc:SCANODBC","SYSDBA", "masterkey");
    stmt = con.createStatement();
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    jButton2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton2_actionPerformed(e);
    contentPane.add(jButton2, new XYConstraints(126, 113, -1, -1));
    //Overridden so we can exit when window is closed
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    void jButton2_actionPerformed(ActionEvent e) {
    try{
    OutputStream out;
    XMLOutputter outputter;
    Element root;
    org.jdom.Document doc;
    root = new Element("PINFO");
    String query = "SELECT * FROM PINFO WHERE PID=2 OR PID=4";
    ResultSet rs = stmt.executeQuery(query);
    /*===========This is where i am passing the ResultSet and boolean=======
    ===========value to either add the null or not null values in the file======*/
    rstx = new ResultSetToXML(rs,true);
    } //end of try
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    ======================================================================================
    ResultSetToXML class
    ====================
    public class ResultSetToXML {
    private OutputStream out;
    private Element root;
    private XMLOutputter outputter;
    private Document doc;
    // Constructor
    public ResultSetToXML(ResultSet rs, boolean checkifnull){
    try{
    String tagname="";
    String tagvalue="";
    root = new Element("pinfo");
    while (rs.next()){
    Element users = new Element("Record");
    for(int i=1;i<=rs.getMetaData().getColumnCount(); ++i){
    tagname= rs.getMetaData().getColumnName(i);
    tagvalue=rs.getString(i);
    System.out.println(tagname);
    System.out.println(tagvalue);
    /*============if the boolean value is false it adds the null and not
    null value to the file =====================*/
    /*============else it checks if the value is null or the length is
    less than 0 and does the else clause in the if(checkifnull)===*/
    if(checkifnull){ 
    if((tagvalue == null) || tagvalue.length() < 0 ){
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    root.addContent(users);
    out=new FileOutputStream("c:/XMLFile.xml");
    doc = new Document(root);
    outputter = new XMLOutputter();
    outputter.output(doc,out);
    catch(IOException ioe){
    System.out.println(ioe);
    catch(SQLException sqle){

    Can someone please help me with this problem
    Thanks.

  • How to get the values from the resultset???

    I have a problem with this code given below,
    i am executing an sql query which return a union of values from two tables.
    the problem here is how do i read the values from the resultset.
    here is the code....
    package com.webserver;
    import java.sql.*;
    public class UnionDemo{
    public static void main(String args[]){
    Connection connection =null;
    Statement statement =null;
    ResultSet rs =null;
    try{
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    connection = DriverManager.getConnection("jdbc:oracle:thin:@:1521:ORCL","scott","tiger");
    statement = con.createStatement();
    rs = statement.executeQuery("(select tablename from node where appid=432) union (select tablename from uomnode where appid=432)");
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    while (rs.next()){
    System.out.println(rs.getString(1));
    // instead of rs.getString(1) I also used rs.getString("tablename") but of no success....
    }//end of while
    }catch(Exception exp){
    exp.printStackTrace();
    finally{
    try{
    if (rs!=null) rs.close();
    if (statement!=null) statement.close();
    if (con!=null) con.close();
    }catch(Exception exp1){
    exp1.printStackTrace();
    }//end of finally
    }//end of main
    }//end of class
    when i execute this program i get an oracle error ORA-01009
    which says (java.sql.SQLException: ORA-01009: missing mandatory parameter)
    can anyone help to retrieve the values from this resultset...
    thanx

    [cut]
    i am executing an sql query which return a union of
    values from two tables.
    the problem here is how do i read the values from the
    resultset.[cut]
    When the error occours?
    1) Executing query ?
    2) Retrieving the field from the resultSet ?
    3) ecc. ?
    BTW, first of all, try to execute the query removing the parenthesis
    of the two select statement. I know that there are some problem
    with the oracle jdbc driver about them.
    Hope it helps.

Maybe you are looking for

  • Shared mailbox contacts to Address Book

    Hi all We have recently migrated to an Exchange 2010 environment, our clients using Outlook 2003 and Outlook 2010. We have a large number of shared mailboxes within our organisation that contain their own contacts lists. The shared mailbox is added a

  • I have edited in Photoshop a RAW file from LR

    I've edited a RAW file from LR catalogue by 'Edit in Photoshop'.  I've saved the edited file both as  a TIF file and as a JPEG but only the RAW file and TIF files are visible in the LR catalogue.  When I right click to 'show in Finder', there is the

  • IPod Touch Update Problems

    My iPod won't allow me to update to iOS 5, it is currently on 4.2.1. My iTunes is updated to the latest one but every time I press Check for Update it says "This version of the iPod software (4.2.1) is the current version" The model of the iPod as it

  • Group Membership report script - Modify to change format of output

    Hi all, Slowly getting to grips with Powershell. Such a powerful tool. I've been tasked to develop a reporting script that will output a list of members of a set of groups and have found one of the scripts here to be a great starting point. So this i

  • How to download office 2010 via net

    from where to download office 2010.