GetString-problem

Hello!
Help, i need somebody...
I'm new in C++, VC and Oracle.
I use OCCI to connect on 10g db. Somehow i configured VC so now i can create .exe. I'm not sure that i can repeat configuration:).
In databes there is table whit only varchar2 fields. The problem is in this part of code:
</br>
string c2;</br>
     while(rs->next())</br>
{            counter++;</br>
          for(int i=1; i<=5; i++) {</br>
               c2=rs->getString(i);</br>
          cout <<"row: "<<counter<<" field: "<<i<<" "<<c2<<endl; </br>
     }</br>
          cout <<"******************"<<endl;</br>
}</br>
</br>
Nothing smart. But when getString gets something it fails( An unhandled win32 exception occurred in my.exe [3888] . When i reduce dataset only on fiedls whit "where length(varchar_field)<16" it never throw this exception. If i
Somethimes the program goes whitout any problem.
Please help!!!
I didn't find anything helpful on this forum.

which version of OCCI are you using? Can you try on the latest version (10.2 or 10.1.0.5)?

Similar Messages

  • OCCI -getString problem

    I'm having trouble executing code using the OCCI libraries.  I suspect that it's an issue with the version of OCCI that I'm using but can't seem to resolve the problem myself.
    On Windows 7, I'm using the OCCI libraries from the Oracle Express 11.2 32 bit install.  I'm compiling in Eclipse Luna (for 32 bit) 1a using the CDT plugin.  I'm using the compiler from Microsoft Visual Studio 12.0.
    I'm using the oraocci.lib. (If I use the oraocci11d.lib, my code crashes just trying to make a database connection.)  My current problem is with the oracle::occi::ResultSet::getString method.  If I call it once on my ResultSet, it works fine.  The second call causes my program to crash.
    Here is my code:
    std::sqlStr;
    sqlStr = "SELECT START, END, BATCH_ID, AGENT_ID FROM AGENTS WHERE ID = :1";
    connection code, stmt creation, etc
    oracle::occi::ResultSet *rs = stmt->executeQuery();
    if (rs->next()
       double start = rs->getDouble(1);
       double end = rs->getDouble(2);
       std::string batch = rs->getString(3);
       std::string agent = rs->getString(4);  // CRASH!
    Here is the exception that I get when I try to debug:
    "Unhandled exception at 0x00D82CB8 in DARTester.exe: 0xC0000005: Access violation reading location 0x0000005."
    Any help would be greatly appreciated.

    It is my fault. I use Fedore Core 4 and gcc4.0. By default it linking with libstdc++.6.so, but when I linkint direct with libstdc++.5.so it OK.
    Thank you for support!

  • Problem with getString() in OCCI

    /* <br>
    My name is Chandra, <br>
    I am facing a problem in retriving many records from a table using OCCI <br>
    I am using VC6.0 in WindowXP - SP2 with Oracle 10G client <br>
    <br>
    Here is my Example <br>
    I have no issue with the program when there are 10 records in emp table <br>
    where as I am getting an error when there are 20 records. <br>
    Code is executing till the end <br>
    it also printed Finished Printing which is in main <br>
    and gave the following error <br>
    <br>
    ERROR::: <br>
    1.exe has encountered a problem and needs to close. <br>
    we are sorry for the inconvenience <br>
    Error Signature is saying that it happend with Mod Name ntdll.dll and <br>
    ModVer: 5.1.2600.2180 and Offset:00010fc2 <br>
    When I tried by modifying line <br>
    emp1.ename     = rs->getString(1); <br>
    to <br>
    emp1[i].ename     = "Chandra"; <br>
    it is working Perfectly <br>
    Please advice what is wrong with getString(1); <br>
    Is there any other function which I can use to store the value of ename into a string? <br>
    If there is please advice me how to use. <br>
    Thanks a lot for your support <br>
    Regards, <br>
    Chandra. <br>
    */ <br>
    <b>
    #include <iostream> <br>
    #include <occi.h> <br>
    #include <stdio.h> <br>
    using     namespace oracle::occi; <br>
    using     namespace std; <br>
    int          numberofrecords; <br>
    struct emp <br>
    { <br>
         string     ename; <br>
         int     age; <br>
         int     year; <br>
    }emp1[50]; <br>
    <br>
    void empselect() <br>
    { <br>
         string     user = "scott"; <br>
         string     pass = "tiger"; <br>
         string     osid = ""; <br>
         Environment* env = Environment::createEnvironment(Environment::DEFAULT); <br>
         printf("Environment is Set \n"); <br>
         int ret = 0; <br>
         int i=1; <br>
         try <br>
         { <br>
              printf("Creating the Connection\n"); <br>
              Connection *con = env->createConnection(user, pass, osid); <br>
              printf("\n"); <br>
              cout << "Connection Established - Connected as " << user << "/" << osid << "." << endl; <br>
              cout << "Creating Statement" << endl; <br>
              Statement stmt     = con->createStatement("select from emp"); <br>
              cout << "Executing Query" << endl; <br>
              ResultSet *rs     = stmt->executeQuery(); <br>
              while (rs->next()) <br>
              { <br>
                   emp1[i].ename     = rs->getString(1); <br>
                   emp1[i].age     = rs->getNumber(2); <br>
                   emp1[i].year     = rs->getNumber(3); <br>
                   i++; <br>
              } <br>
              numberofrecords = i; <br>
              printf("Out of while loop \n"); <br>
              stmt->closeResultSet(rs); <br>
              cout << "Closing connection." << endl; <br>
              env->terminateConnection(con); <br>
         } <br>
         catch (SQLException ea) <br>
         { <br>
              cout <<"Inside Exception - OBULA\n"; <br>
              cerr << "Can’t connect: " << ea.what(); <br>
              ret = 1; <br>
         } <br>
         cout << "Before Termination" << endl; <br>
         Environment::terminateEnvironment(env); <br>
         cout <<"Terminated \n"; <br>
    } <br>
    <br>
    void main() <br>
    { <br>
         int j; <br>
         cout << "Calling justlasd \n"; <br>
         empselect(); <br>
         cout<<"Priniting Results\n"; <br>
         for(j=0;j<numberofrecords;j++) <br>
              cout << "emp - "<< emp1[j].ename << "\tage - "<< emp1[j].age << "\t - " << emp1[j].year << endl; <br>
         cout <<"Finished printing"; <br>
    }</b>

    Hey guys try dis code........i too had the same problem soo i hav solved tht in dis way.....
    #ifndef DllExport
    #define DllExport     __declspec( dllexport )
    #endif
    #include <iostream.h>
    #include <occi.h>
    using namespace oracle::occi;
    using namespace std;
    typedef struct DllExport MultisiteTableRecord
    unsigned int ReqID; //will point to table 1
    } MultisiteTableRecord;
    typedef OCCI_STD_NAMESPACE::vector<string> cols;
    typedef struct DllExport RowType : public MultisiteTableRecord
         int id;
    string name;
    } RowList;
    enum
    ID = 1,
    NAME,
    class demo{
    public:
    Environment* env ;     
         Connection* conn;
         Statement* stmt;
         ResultSet *rs;
         list<RowList> row1;
    int main( )
         demo *d = new demo;
         try{          
              d->env = Environment::createEnvironment(Environment::OBJECT);          
              d->conn = d->env->createConnection( "infodba", "infodba","tceng" );          
              cout << "Environment and Connection created" << endl;     
              string sqlQuery = "SELECT id,name FROM demo ";          
              d->stmt = d->conn->createStatement(sqlQuery);
              d->rs = d->stmt->executeQuery ();
              int row =1 ;
              ResultSet::Status status;
              while((status = d->rs->next()) == (ResultSet::DATA_AVAILABLE))
                   RowList r;
                   r.id = d->rs->getInt(ID);
                   r.name = d->rs->getString(2);
                   d->row1.push_back(r);
              list<RowList>::iterator i;
              for (i = d->row1.begin(); i != d->row1.end(); i++){
                        cout<<i->name.c_str()<<endl;
                        cout<<i->id<<endl;
    cout << "we" ;
              d->stmt->closeResultSet(d->rs);//to free resources
         d->conn->terminateStatement(d->stmt);
         d->env->terminateConnection(d->conn);
         Environment::terminateEnvironment(d->env);
              cout << "Closing connection." << endl;
         catch(int error){
    cout << "hi" ;
              cout << error;
              return 0;
    }

  • OCCI ResultSet- getString Linux problem

    Hello,
    On forum I found how the solve problem for OCCI programm witch using MSVC++. May be anybody known how to correct compile and linking OCCI demo on Linux? The demos crashed at ResultSet->getString().

    It is my fault. I use Fedore Core 4 and gcc4.0. By default it linking with libstdc++.6.so, but when I linkint direct with libstdc++.5.so it OK.
    Thank you for support!

  • J2ME problem with threads

    Hi all,
    I would like to ask you for a help. I need to write a small program at my university. I started to write a midlet which function would be to countdown time for sports activities. I woul like to start a new thread - the one that counts down - and at the same time make the main thread sleep. After the "countdown" thread finishes, the main thread wakes up and waits for user input. The problem is that when the "countdown" thread finishes his work, I've got Uncaught exception java/lang/NullPointerException. error and the midlet halts.
    Below you can find the code
    import java.lang.*;
    import java.util.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class intervals extends MIDlet implements CommandListener
    public Display ekran;
    private SweepCanvas sweeper;
    private Form rundy;
    private TextField round0, round1, round2, round3, round4, round5, round6, round7, round8;
    private long czas,x;
    private Command exitCommand;
    private Command addRound;
    private Command delRound;
    private Command start;
    private TextField repeat;
    private Form odliczanie;
    private Alert ostrz;
    Licznik thread;
    String test;
    StringItem test1;
    int parz,i,j,k;
    static int l;
    int ilrund;
    int ilpowt;
    Item sec;
    long sec1;
    public intervals()
        rundy = new Form("Interwa&#322;y sportowe");
        exitCommand = new Command("Wyj&#347;cie", Command.EXIT, 2);
        addRound = new Command("Dodaj","Dodaj rund&#281;", Command.ITEM,1);
        delRound = new Command("Usu&#324;","Usu&#324; ostatni&#261; rund&#281;", Command.ITEM,1);
        start = new Command("Start", Command.ITEM,1);
        odliczanie = new Form("Odliczanie");
        TextField dodaj(TextField kolej)
            kolej=new TextField("Podaj czas (s) rundy "+parz,null, 4, TextField.NUMERIC);//stworzenie nowej instancji do wybierania czasu trwania rundy
            if(rundy.size()==0)
                rundy.insert(rundy.size(),kolej);
                else
                    rundy.insert(rundy.size()-1, kolej);
            return kolej;
        void odliczanie(TextField round)
            monitor m=new monitor();
            k=Integer.parseInt(round.getString());
            ekran.setCurrent(odliczanie);
            thread=new Licznik(k,odliczanie);
            thread.start();
            ekran.setCurrent(rundy);
    public void startApp()// throws MIDletStateChangeException
        rundy.deleteAll();
        repeat = new TextField("Podaj ilo&#347;&#263; powtórze&#324;",null,1,TextField.NUMERIC);
        rundy.addCommand(addRound);
        rundy.addCommand(exitCommand);
        rundy.setCommandListener(this);
        Canvas obrazek = new MyCanvas();
        ekran = Display.getDisplay(this);
        ekran.setCurrent(obrazek);
        czas=System.currentTimeMillis();
        while (System.currentTimeMillis()<czas+1000)
            continue;
        ekran.setCurrent(rundy);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
        notifyDestroyed();
    public void commandAction(Command c, Displayable s)
        if (c == exitCommand)
            destroyApp(false);
            notifyDestroyed();
        else if(c==addRound)
            if(rundy.size()==0)//Sprawdzenie ilo&#347;ci elementów w celu poprawnego wy&#347;wietlania liczby rund w formie
                parz=1;
                else
                parz=rundy.size();
            switch(parz)
                case 1:
                    round0=dodaj(round0);break;
                case 2:
                    round1=dodaj(round1);break;
                case 3:
                   round2= dodaj(round2);break;
                case 4:
                    round3=dodaj(round3);break;
                case 5:
                    round4=dodaj(round4);break;
                default:
                    ostrz=new Alert("Uwaga","Maksymalna liczba rund wynosi 9", null, AlertType.INFO);
                    ostrz.setTimeout(3000);
                    ekran.setCurrent(ostrz);
            if(rundy.size()==1)
                rundy.append(repeat);
                rundy.addCommand(start);
            rundy.addCommand(delRound);
        else if(c==delRound)
            if(rundy.size()!=0)
                rundy.delete(rundy.size()-2);
                if (rundy.size()==1)
                    rundy.deleteAll();
                if(rundy.size()==0)
                    rundy.removeCommand(delRound);
                    rundy.removeCommand(start);
        else if(c==start)
            ilrund=rundy.size()-1;
            if(this.repeat.size()>0)
                ilpowt=Integer.parseInt(this.repeat.getString());
            ekran = Display.getDisplay(this);
            for (i=1; i<=ilpowt;i++)
                odliczanie= new Form("Odliczanie");
                 for (j=0;j<ilrund;j++)
                    switch(j)
                         case 0:
                             odliczanie(round0);
                             break;
                         case 1:
                             odliczanie(round1);
                             break;
                         case 2:
                             odliczanie(round2);
                             break;
                         case 3:
                             odliczanie(round3);
                             break;
                         case 4:
                             odliczanie(round4);
                             break;
                         case 5:
                             odliczanie(round5);
                             break;
                         case 6:
                             odliczanie(round6);
                             break;
                         case 7:
                             odliczanie(round7);
                             break;
                         case 8:
                             odliczanie(round8);
                             break;
    class Licznik extends Thread
        int czas1,k;
        Form forma;
        monitor m;
        public Licznik(int k,Form formap)
            czas1=k;
            forma=formap;
        public synchronized void run()
            while(czas1>0)
                forma.deleteAll();
                forma.append("Czas pozosta&#322;y (s): "+czas1);
                try{Thread.sleep(1000);} catch(InterruptedException e){e.printStackTrace();}
                czas1--;
            if(czas1<=0)
                m.put();
        }and monitor class
    public class monitor
    boolean busy=false;
    synchronized void get()
        if(!busy)
            try
                wait();
            }catch(InterruptedException e){e.printStackTrace();}
        notify();
    synchronized void put()
        if(busy)
            try
            wait();
            }catch(InterruptedException e){e.printStackTrace();}
        busy=true;
        notify();
    }Can anybody help me with this?

    Groovemaker,
    Your Licznik class has a member m of type monitor, which has not been instantiated (in other words is null) hence, when calling m.put() you get NullPointerException. Please also mind, that using Thread.sleep(1000) is not an accurate way of measuring time.
    If I may, please use recommended for Java class naming conventions - some of your names use lower case, while other don't which is confusing to the reader.
    Daniel

  • Installation problem on my debian 2.2.20

    I tryied to install the Appserver 7 on my debian (Linux woody 2.2.20 SMP) without X11 ( ./setup -console ) but i have this error message
    com.iplanet.install.util.wbResource::getString: resource string "appservResources:LinOSCheckPanel-CUI-unsupportedOS-Text" not found
    appservResources:LinOSCheckPanel-CUI-unsupportedOS-Text
    Please, anybody can help me ?
    Excuse my poor english

    fk wrote:
    Hi
    you can try these installation method
    http://wiki.archlinux.org/index.php/Ins … her_distro
      installation work fine..... the problem is the boot from disk after install.
    P.S. i tried installation form ftp but the module of my eth card wont'load  :cry:
    marvell ---> sky2

  • Query update on each iteration problem (MS SQL Sever / ODBC / Native Driver

    Hello,
    I�ve been working to learn some Java and now JDBC over the past 10 or so months.
    I think I have a general understanding of how to perform queries and work with data using JDBC. However, I�ve run into a problem. I�m trying to do a query of a set of data in a database based on the value of a status column. I want to loop over the messages and perform various functions with the data then update their status in the database. It�s preferable to do these 250 to 1000 rows at a time, but no more and no less.
    I�m connecting to MS SQL Server 2000, currently with ODBC. I�ve also tried it with the Java SQL Server 2000 drivers provided by Microsoft with the same results.
    I�ve found that I can do a one table query and loop though it with a while (rs.next()) {�} and run an Update statement with executeUpdate on each iteration without any problems, no matter the number of rows returned in query.
    I have not been able to use the updateString and updateRow inside the while loop. I keep getting errors like this at the line with the updateRow():
    Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Row update failed.
    This occurs no mater how many rows I select, 1 or more.
    The real problem I�ve been having is that the query I need to loop though joins across several tables and returns some rows from some of those tables. This only seems to work when I query for 38 or less selected rows and I use an Update statement with executeUpdate on each iteration. The updateString and updateRow methods never work. Any number of rows selected greater than 38 causes a deadlock where the Update is waiting for the select to compete on the server and the Update can�t proceed until the Select is complete.
    As I stated above I�ve tried both ODBC and the native SQL Server driver with the same results. I have not tried any other databases, but that�s moot as my data is already in MS SQL.
    Questions:
    How can I avoid or get around this 38 row limit without selecting each row, one at a time?
    What am I doing wrong with the updateString and updateRow?
    Is there a better approach that anyone can suggest?
    Here�s some sample code with the problem:
    import java.sql.*;
    public class db1{
         public static void main(String[] args) throws Exception{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              String url = "jdbc:odbc:eBrochure_live";
              Connection con = DriverManager.getConnection(url, "sa", "d3v3l0p");
              Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
              Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://dcm613u2\\dcm613u2_dev:1433", "sa", "d3v3l0p");
              Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
              Statement stmt2 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
              stmt.executeUpdate("USE [myDatabase]");
              stmt2.executeUpdate("USE [myDatabase]");
              String qGetMessages = "SELECT TOP 250 t1.messageUUID, t1.subjectHeader, t2.emailAddress as toAddress " +
              "FROM APP_Messages as t1 JOIN APP_addressBook_contacts as t2 " +
              "     On t1.toContactID = t2.contactID " +
              "WHERE t1.statusID = 'queued'";
              ResultSet rs = stmt.executeQuery(qGetMessages);
              while (rs.next()) {
                   String messageUUID = rs.getString("messageUUID");
                   String subjectHeader = rs.getString("subjectHeader");
                   System.out.println(messageUUID + " " + subjectHeader);
                   String updateString = "UPDATE APP_Messages " +
                        "SET statusID = 'sent' " +
                        "WHERE messageUUID = '" + messageUUID + "' ";
                   stmt2.executeUpdate(updateString);
              con.close();
    Thanks for the help,
    Doug Hughes

    // sorry, ps.close() should be outside of if condition
    String sql = "UPDATE APP_Messages SET statusID = 'sent' WHERE messageUUID = ?";
    Statement statement = con.createStatement();
    PreparedStatement ps = con.prepareStatement(sql);
    ResultSet rs = statement.executeQuery("your select SQL");
    if ( rs.next() )
    ps.clearParameters();
    ps.setString(1, rs.getString("your column name"));
    ps.executeUpdate();
    ps.close();
    rs.close();
    statement.close();

  • Problem Using HTTP Dispatcher -- Could Not able to get the data in JSP

    Hi, I am using HTTP Dispatcher to send my events to particular URL which is a JSP page. I am trying to populate the received event through URL and populate to a oracle data base. But could not able to get the data in Oracle database.
    Code is :
    <h1>JSP Page</h1>
    <%
    long type = 0;
    String tagId = null;
    String timeStr = "0";
    String deviceName = "";
    // Get Event Parameters
    // Available Parameters: id, siteName, deviceName, data, time, type, subtype, sourceName, correlationId
    try
    type = Long.parseLong(request.getParameter("type")); // Get type
    tagId = request.getParameter("id"); // Get tagId
    timeStr = request.getParameter("time"); // Get time
              deviceName = request.getParameter("deviceName");
    catch (Exception e)
    out.println( "Error: "+e.getMessage() );
              // Write into DB.
              try {
              if ((tagId == null) || (type != 200) ){
                   // Do Nothing
                   //return;
              } else {
                   OracleDataSource ods = new OracleDataSource();
                   String URL = "jdbc:oracle:thin:@//3.235.173.16:1525/vislocal";     
                   ods.setURL(URL);
                   ods.setUser("cus");
                   ods.setPassword("cus");
                   Connection myConn = ods.getConnection();     
                   Statement stmt = myConn.createStatement();
                   String selectQuery =
                             "SELECT MAX(rfid_raw_reads_id) as max_id FROM "+
                        "cus.rfid_raw_reads ";
                   ResultSet rs = stmt.executeQuery(selectQuery);
                   String maxId = "1";
                   if (rs.next()) {
                        maxId = rs.getString(1);               
                   String selectMaxTagIDQuery =
                             "SELECT MAX(rfid_raw_reads_id) as max_id FROM "+
                        "cus.rfid_raw_reads WHERE tag_id = '" + tagId + "'" ;
                   stmt = myConn.createStatement();
                   rs = stmt.executeQuery(selectMaxTagIDQuery);
                   String maxTagId = "1";
                   if (rs.next()) {
                        maxTagId = rs.getString(1);               
                   long primaryKey = 1;
                   long tagKey = 1;
                   try {
                        primaryKey = Long.parseLong(maxId) + 1;
                        tagKey = Long.parseLong(maxTagId) + 1;
                   } catch (Exception e) {
                   long currentTime = System.currentTimeMillis();
                   long updateKey = (tagKey - 1);
                   String updateQuery = " UPDATE cus.rfid_raw_reads SET read_end_time = " + currentTime + " WHERE rfid_raw_reads_id = " + updateKey;
                   Statement updateStmt = myConn.createStatement();
                   updateStmt.execute(updateQuery);     
                   String query =
                        "INSERT INTO cus.rfid_raw_reads (rfid_raw_reads_id, tag_id,device_name,read_start_time) VALUES ("+ primaryKey + ",'" + tagId + "'," + deviceName + "'," + System.currentTimeMillis() + " )" ;
                   Statement insertStmt = myConn.createStatement();
                   insertStmt.execute(query);     
                   myConn.commit();
                   myConn.close();
              } catch (Exception e) {
    %>
    <p>For browser debug:
    <%
    out.println( "Type="+type+" ID="+tagId +" time="+timeStr );
    %>
    Kindly suggest where is the problem...
    Thanks and regards
    Mohammad Nasim Akhtar

    HI Prabhat,
    Thanx for your reply, I worked out and able to receive the data in oracle database, Actually there was some problem in insert Query. Now I have tested the same... and able to edit the same in the Database.....
    But I am facing a new problem, Http Dispatcher in SES console is displaying all the Events generated as well as event in Que but there is no events in the Event Send. I guess it is not able to send the events.....?????
    Event statical is showing like this
    Events Received: 0 (0.00/sec)
    Events Generated: 311 (0.19/sec)
    Events Sent: 2 (0.19/sec)
    Queued Events: 309 (0.19/sec)
    Kindly suggest where is the problem, Is it a JSP problem or OSES end problem.....
    Thanks and regards
    Nasim

  • Problems with varchar2 column and a select statement

    Hi to all,
    I am new to ODP...so I would really appreciate your help..
    I am having problems with using the following code:
    con.ConnectionString = "User Id=bla;Password=bla;Data Source=bla;";
    string cmdQuery = "SELECT * from try where data ="+textBox1.Text+"";
    OracleCommand cmd = new OracleCommand(cmdQuery);
    cmd.Connection = con;
    cmd.CommandType = CommandType.Text;
    OracleDataReader reader = cmd.ExecuteReader();
    while (reader.Read())
    MessageBox.Show(reader.GetString(0)+"");
    cmd.Dispose();
    con.Close();
    where:
    data is the name of a field in the table
    textBox1 is the name of a text box where the user inserts the values..
    The error that appears is "Invalid identifier"..
    I hope it makes sense...and please help...

    Hi,
    I'm fairly sure it IS the single quotes actually. Print out the string you're trying to excute, then try it outside odp.net, does it work?
    For example:
    SQL> select * from dual where dummy=foo;
    select * from dual where dummy=foo
    ERROR at line 1:
    ORA-00904: "FOO": invalid identifier
    SQL> select * from dual where dummy='foo';
    no rows selected
    Cheers,
    Greg

  • Problem in java.awt.print

    Hi here is my code .
    I am generating page dynamically and passing to printer.
    Printing Functionalities working file. But I am taking some data from database (Access). And in this code for example i have 4 records in Database and i am generating 4 pages (each page for resord).
    I am getting only 2 records. And for other two records i am getting blank page.
    Reason is My ResultSet object is moving to next record twice.
    I mean if i have 6 records i get only 3 pages.
    If i have 10 records i get only 5 pages and If i have 1 record i dont get any page.
    How shall i solve this problem.
    Thanx in advance.
    import java.awt.*;
    import java.awt.print.*;
    import java.sql.*;
    public class SubbuBook extends Thread implements Printable {
    Connection con;
         Statement stmt;
         static ResultSet rsValue;
         public void run() {
              dataConnection();
              PrinterJob job = PrinterJob.getPrinterJob();
              Book bk = new Book();
              job.setPageable(bk);
              if (job.printDialog()) {
         try {
              bk.append(new SubbuBook(),job.defaultPage(), 4);
              job.print();
              }catch (Exception e) {
              System.out.println("Exception "+e);
         System.exit(0);
    public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
         Font fntHeading = new Font("Helvetica",Font.BOLD,24);
    Font fntRow = new Font("Helvetica",Font.PLAIN,14);
         try{
         if(rsValue.next()) {
              g.setFont(fntHeading);
              g.setColor(Color.red);
              g.drawString("Main Report",200,100);
              g.setColor(Color.blue);
              g.drawLine(100,150,500,150);
              g.drawLine(100,150,100,500);
              g.drawLine(100,500,500,500);
              g.drawLine(500,100,500,500);
              g.drawLine(200,150,200,500);
              g.setFont(fntRow);
              g.setColor(Color.black);
              g.drawString("Program Id",120,200);
              g.drawString(rsValue.getString("prog_id"),250,200);
              g.drawString("Program Name",120,250);
              g.drawString(rsValue.getString("prog_name"),250,250);
              g.drawString("Artist Name",120,300);
              g.drawString(rsValue.getString("Artist"),250,300);
         }catch(Exception ae) {
         System.out.println("Exception inside Paint"+ae);
         return Printable.PAGE_EXISTS;
    private void dataConnection() {
         try{
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         con=DriverManager.getConnection("jdbc:odbc:artist");
         stmt=con.createStatement();
         rsValue=stmt.executeQuery("select * from artist order by Prog_name");
         System.out.println("Connection is Proper");
         }catch(Exception e){
              System.out.println("Exception at Connection"+e);

    I am not sure this..
    Instead of if pls give while and check:
    try{
    while(rsValue.next()) {
    g.setFont(fntHeading);
    g.setColor(Color.red);
    g.drawString("Main Report",200,100);

  • JSP and Java Beans with Database Problem

    hellow, this is my first posting and i hope to help me as fast as you can...
    my problem is simplly i cant get any data from the database (whatever the database it is, i test it with MS Access and MySQL server) when i use a bean, But if i put my connection statement in the JSP file thair is no problem... ???? !!!!
    for example i have a class "Authentication" that have a method to test if the username and password is correct or not and return 1 if true, 0 if false, -1 if thair are some problem in connecting DB.
    now if i create a normal java application that uses this method, it's work and no problems, BUT if i used a JSP page to use this method it's return allways -1

    T1 class:
    package VX;
    import java.sql.*;
    import java.util.*;
    import javax.swing.*;
    public class T1
    //public MBJDBConnection(String driver,String url)
    public T1()
    JDBC_DRIVER = "com.mysql.jdbc.Driver";//driver;
    DATABASE_URL = "jdbc:mysql://localhost:3306/rawafed?user=root;password=0000";//url;
    //=======DB CONNECTION===========================================
    private static String JDBC_DRIVER;
    private static String DATABASE_URL;
    protected Connection connection;
    protected Statement statement;
    //===========End DBC==============================================
    public int update(String sqlUpdate)
         int i=0;
              //connectDB();
              try{
                   i=statement.executeUpdate(""+sqlUpdate);
                   catch(Exception e)
                        System.out.println("Error Inserting Statement Or Connection Not Opened");
              //disconnectDB();
         return i;
    public ResultSet select(String sqlQuery)
              //connectDB();
              ResultSet rs;
              try
              {//open try
              rs=statement.executeQuery(""+sqlQuery);
                   return rs;
              }//end try
              catch(Exception e2)
                   //System.out.println("Error Selecting Statement Or Connection Not Opened");
              }//end catch
              //add to array list
         //return resultList;
         return null;
    //------Methods-------
    public void connectDB()
    //===========================Connection===================
    try
    Class.forName(JDBC_DRIVER);
    catch(Exception e)
    System.out.println("Error : FOR NAME");
    try
    connection = DriverManager.getConnection(DATABASE_URL, "root", "0000");
    catch(Exception e)
    System.out.println("Error : DB URL");
    try
    statement = connection.createStatement();
    catch(Exception e)
    System.out.println("Error : CREATE STATEMENT ERROR");
    public void disconnectDB()
    try
    statement.close();
    connection.close();
    catch(Exception e2)
    System.out.println("Error : CAN'T CLOSE DB");
    T2 Class
    package VX;
    // class Person.
    //Required Class : EDC.EDCDB
    import java.sql.*;
    public class T2
         public T2()
              //initialization
         //........................ Attributes .........................
         private String user;
         private String password;
         private T1 db=new T1();
         private ResultSet rs;
         //......................... Methods .........................
         public String getAdmin(String u,String p)// 0: Failure, 1:Success and he is Administrator, 2: success and he is a regular employee 3: SUCCESS AND HE IS agent
              try
              user=u;
              password=p;
              rs=db.select("SELECT emp_id,password FROM Employee WHERE emp_id="+user+" AND password="+password+" AND Rank_ID=1");
              if(rs.next())
                   return ""+1;
              else
                   rs=db.select("SELECT emp_id,password FROM Employee WHERE emp_id="+user+" AND password="+password+" AND Rank_ID=2");
                   if(rs.next())
                        return ""+2;
                   else
                        rs=db.select("SELECT emp_id,password FROM Employee WHERE emp_id="+user+" AND password="+password+" AND Rank_ID=3");
                        if(rs.next())
                             return ""+3;
                        else return ""+0;
              catch(Exception e){System.out.println("Error \n"+e.getMessage());return ""+e.getMessage()+"\n"+(-1);}
         public int getCard(String u,String p)// 0: Failure, 1:Success and he is Administrator, 2: success
              user=u;
              password=p;
              try
              db.connectDB();
              rs=db.select("SELECT Card_ID,password FROM Card WHERE Card_ID='"+user+"' AND password='"+password+"'");
              if(rs.next())
                   return 1;
              return 0;
              catch(Exception w)
                   return -1;
              finally
                   //System.out.println("Done");
                   db.disconnectDB();
         public int getAny()
              return 1;
    }//end class
    This is a tested class and it's work OK
    import VX.T2;
    public class T3
         public static void main(String [] args)
              System.out.println("System Started...");
              try
                   T2 t2=new T2();
                   System.out.println(t2.getCard("1","a"));
              catch(Exception e)
                   System.out.println("Opsssss ...");
    Now this is the JSP Code that OK and Run without any problems
    <%@ page contentType="text/html; charset=windows-1256" language="java" import="java.sql.*" errorPage="" %>
    <!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=windows-1256" />
    <title>test</title>
    </head>
    <body>
    <%
    //Mazin B. Jabarin 20210464
    //Testing JSP - MySQL Server Driver
    String connectionURL = "jdbc:mysql://localhost:3306/EDCDB?user=root;password=0000";
    Connection connection = null;
    Statement statement = null;
    ResultSet rs = null;
    %>
    <%
    try{
    Class.forName("com.mysql.jdbc.Driver");
    connection = DriverManager.getConnection(connectionURL, "root", "0000");
    statement = connection.createStatement();
    rs = statement.executeQuery("SELECT * FROM a");
    while (rs.next()) {
    out.println(rs.getString("id")+"<br>");
    rs.close();
    catch(Exception e)
    out.print("Error : "+e.getMessage());
    %>
    </body>
    </html>
    Now this JSP File always returns (-1) ???? !!!!!!!
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" import="VX.T2" import="java.util.*" errorPage="" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <%
    try
    T2 t2=new T2();
    out.println("Result Still : "+t2.getCard("1","a"));
    catch(Exception w)
    out.println("<BR> Error In Execution ??? "+w.getMessage());
    %>
    </body>
    </html>
    ++++++++++++++++++++++++++++
    any one can help me please :(
    i use tomcat as web-application
    and i install jdk 1.5
    also JBulder 7
    (now i supposed that the JBulder make some conflict, so i uninstalled it but still Not Working) ...
    before one year i was working just like this way and it was working
    but now i dont know what is the problem
    i am really need help.

  • Problem in web application deployment in weblogic 8.1

    hiiiiiiiii freinds!
    i am a newcomer in the field of servlets and JSPs.Me and my freinds are developing a client/server chat application but i am facing a problem in transferring the control from one JSP to another JSP.I am using Oracle 10g and weblogic 8.1upon clicking the submit button at login.jsp i am seeing following message at web browser.
    /loginhandler.jsp(4): class 'com.mycompany.login.Login' could not be loaded
    probably occurred due to an error in /loginhandler.jsp line 4:
    <jsp:useBean id="idHandler" class="com.mycompany.login.Login" scope="request" />
    codes for JSPs and bean class aregiven below-
    login.jsp
       1. <html> 
       2. <head><title></title> 
       3. <script language="javascript"> 
       4. function Validate(){ 
       5. var name=document.frm.userName 
       6. var password=document.frm.passWord 
       7.  
       8. if ((name.value==null)||(password.value=="")){ 
       9. alert("Please Enter user name") 
      10. user.focus() 
      11. return false 
      12. } 
      13. if ((name.value==null)||(password.value=="")){ 
      14. alert("Please Enter password") 
      15. pass.focus() 
      16. return false 
      17. } 
      18. return true 
      19. } 
      20. </script> 
      21. </head> 
      22. <body> 
      23. <form method="post" action="loginhandler.jsp"> 
      24. username - <input type="text" name="userName"><br> 
      25. password - <input type="password" name="passWord"><br> 
      26. <input type="submit" value="Submit"> 
      27. <input type="reset" value="Reset"> 
      28. </form> 
      29. <jsp:include page="showformat.jsp"/> 
      30. </body> 
      31. </html>  loginhandler.jsp
       1. <%@page contentType="text/html"%> 
       2. <%@page pageEncoding="UTF-8"%> 
       3. <%@page import="java.util.*" %> 
       4. <jsp:useBean id="idHandler" class="com.mycompany.login.Login" scope="request" /> 
       5. <jsp:setProperty name="idHandler" property="*" /> 
       6. </jsp:useBean> 
       7. <html> 
       8. <head><title></title></head> 
       9. <body> 
      10. <% 
      11. String userName = request.getParameter("userName"); 
      12. String passWord = request.getParameter("passWord"); 
      13. if (idHandler.authenticate(userName, passWord)){ 
      14. response.sendRedirect("welcome.jsp"); 
      15. } else { 
      16. response.sendRedirect("loginfailed.html"); 
      17. } 
      18. %> 
      19. </body> 
      20. </html>  welcome.jsp
       1. <html> 
       2. <head><title>welcome!!!!!!</title></head> 
       3. <body> 
       4. <% 
       5. String name=(String)request.getAttribute("userName"); 
       6. out.println("Welcome" +name); 
       7. %> 
       8. </body> 
       9. </html>  login.java
       1. package com.mycompany.login; 
       2. import java.sql.*; 
       3. import java.io.*; 
       4.  
       5. public class Login  
       6. { 
       7. //default constructor 
       8. public Login(){} 
       9. //method for the database connection 
      10. public Connection getConnection() 
      11. throws IOException{ 
      12. Connection conn = null; 
      13. try{ 
      14. Class.forName("oracle.jdbc.driver.OracleDriver"); 
      15. conn = DriverManager.getConnection( 
      16. "jdbc:oracle:thin:@localhost:1521:xe", 
      17. "system", 
      18. "abcdefgh"); 
      19. } 
      20. catch(SQLException e) 
      21. { 
      22. System.out.println("SQLException: " + e.getMessage()); 
      23. while((e = e.getNextException()) != null) 
      24. System.out.println(e.getMessage()); 
      25. } 
      26. catch(ClassNotFoundException e) 
      27. { 
      28. System.out.println("ClassNotFoundException: " + e.getMessage()); 
      29. } 
      30. return conn; 
      31. } 
      32. //method that is called from validateuser.jsp and this checks for the authentic user and 
      33. public boolean authenticate(String user, String pass) 
      34. throws SQLException, IOException{ 
      35. String Username = null, Password = null; 
      36. Login dbconn = new Login(); 
      37. Statement stmt = dbconn.getConnection().createStatement(); 
      38. String sql = "SELECT USER_NAME, PASS_WORD FROM LOGINDETAILS WHERE USER_NAME='" + user + "'" + "AND PASS_WORD='" + pass + "'"; 
      39. ResultSet rs = stmt.executeQuery(sql); 
      40. if(rs.next()){ 
      41. Username = rs.getString("USER_NAME"); 
      42. Password = rs.getString("PASS_WORD"); 
      43. } 
      44. if(Username != null && Password != null && user.equals(Username) && pass.equals(Password)){ 
      45. return true; 
      46. } 
      47. else return false; 
      48. } 
      49. }  it is requested that please don't neglect or ignore any programming error in pages as i am a newcomer in the field of web development.also suggest some good content and study material for developing interactive and user freindly chat client/server web application.reply as soon as possible!

    ya i have done it and i have put it under the sub directories of classes directory and also included the import also i have modified the codes but problem is same.
    login.jsp
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.util.*, java.text.*" errorPage="" %>
    <!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><title></title>
    <script language="javascript">
    function Validate(){
    var name=document.frm.userName
    var password=document.frm.passWord
    if ((name.value==null)||(password.value=="")){
    alert("Please Enter user name")
    user.focus()
    return false
    if ((name.value==null)||(password.value=="")){
    alert("Please Enter password")
    pass.focus()
    return false
    return true
    </script>
    </head>
    <body>
    <form method="post" action="loginhandler.jsp">
    username - <input type="text" name="userName"><br>
    password - <input type="password" name="passWord"><br>
    <input type="submit" value="Submit">
    <input type="reset" value="Reset">
    </form>
    <br><br><br><br><br><br><br>  &nbsp
    </form>
    <jsp:include page="showformat.jsp"/>
    </body>
    </html>loginhandler.jsp
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"><%@page contentType="text/html"%>
    <%@ page pageEncoding="UTF-8"%>
    <%@ page import="java.util.*" %>
    <%@ page import="com.mycompany.login" %>
    <jsp:useBean id="idHandler" class="com.mycompany.login.Login" scope="session">
    <jsp:setProperty name="idHandler" property="userName" />
    <jsp:setProperty name="idHandler" property="passWord" />
    </jsp:useBean>
    <html>
    <head><title></title></head>
    <%
    String userName = request.getParameter("userName");
    String passWord = request.getParameter("passWord");
    if(userName == null)
    userName = "";
    if(passWord == null)
    passWord = "";
    if(!userName.equals("") && !password.equals("")){
    session.setAttribute("User", userName);
    session.setAttribute("Password", passWord);
    if (idHandler.authenticate(userName, passWord)){
    response.sendRedirect("welcome.jsp");
    } else {
    response.sendRedirect("loginfailed.html");
    %>
    <body></body>
    </html>welcome.jsp
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*, java.io.*, java.util.*, java.text.*" errorPage="" %>
    <%@ page import="com.mycompany.login" %>
    <jsp:getProperty name="idHandler" property="*">
    <!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><title>welcome!!!!!!</title></head>
    <body>
    <%
    String name=(String)session.getAttribute("User");
    out.println("Welcome" +name);
    %>
    </body>
    </html>
    (code)
    login.javapackage com.mycompany.login;
    import java.sql.*;
    import java.io.*;
    public class Login {
    String Username = null, Password = null;
    //default constructor
    public Login(){}
    //method for the database connection
    public Connection getConnection()
    throws IOException{
    Connection conn = null;
    try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@localhost:1521:xe",
    "system",
    "abcdefgh");
    catch(SQLException e)
    System.out.println("SQLException: " + e.getMessage());
    while((e = e.getNextException()) != null)
    System.out.println(e.getMessage());
    catch(ClassNotFoundException e)
    System.out.println("ClassNotFoundException: " + e.getMessage());
    return conn;
    //method that is called from loginhandler.jsp and this checks for the authentic user and
    public boolean authenticate(String user, String pass)
    throws SQLException, IOException{
    Login dbconn = new Login();
    Statement stmt = dbconn.getConnection().createStatement();
    String sql = "SELECT USER_NAME, PASS_WORD FROM LOGINDETAILS WHERE USER_NAME='" + user + "'" + "AND PASS_WORD='" + pass + "'";
    ResultSet rs = stmt.executeQuery(sql);
    if(rs.next()){
    Username = rs.getString("USER_NAME");
    Password = rs.getString("PASS_WORD");
    if(Username != null && Password != null && user.equals(Username) && pass.equals(Password)){
    return true;
    else return false;
    public void setUsername(String name)
    Username=name;
    public String getUsername()
    return Username;
    public void setPassword(String password)
    Password=password;
    public String getPassword()
    return Password;

  • FILE UPLOAD PROBLEM SHOWING THE CONTENTS IN THE SAME BROWSER WINDOW

    Hi,
    This is amit Joshi
    I have uploaded content using input tag of type file and posted to jsp as multipart/form-data type
    in that jsp i am using following code to display the content in browser but only first content is displayed How can i modify it to show all content in the file ..
    <html>
    <head>
    <title>File Upload Display</title>
    </head>
    <body>
    <%
    //ServletOutputStream sout=response.getOutputStream();
    StringBuilder strBuilder = new StringBuilder();
    int count=0;
    String f;
    f=request.getParameter("filedb");
    DBManager dbm = new DBManager();
    //dbm.createTable("mms3");
    //log.info("In JSP : "+ f);
    //dbm.insert_data(f,"mms3");
    %>
    <%
    if (ServletFileUpload.isMultipartContent(request)){
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
    String optionalFileName = "";
    FileItem fileItem = null;
    Iterator it = fileItemsList.iterator();
    ServletOutputStream outputStream=null;
    while (it.hasNext()){
    FileItem fileItemTemp = (FileItem)it.next();
    if (fileItemTemp.isFormField()){
    %>
    <b>Name-value Pair Info:</b>
    Field name: <%= fileItemTemp.getFieldName() %>
    Field value: <%= fileItemTemp.getString() %>
    <%
    if (fileItemTemp.getFieldName().equals("filename"))
    optionalFileName = fileItemTemp.getString();
    else
    fileItem = fileItemTemp;
    if (fileItem!=null){
    String fileName = fileItem.getName();
    %>
    <b>Uploaded File Info:</b>
    Content type: <%= fileItem.getContentType() %>
    Field name: <%= fileItem.getFieldName() %>
    File name: <%= fileName %>
    <%
    if(fileItem.getContentType().equals("image/jpeg")) { %>
    File : <p><%
         //response.setContentType("image/gif");
         byte[] bArray=fileItem.get();
         response.setContentType("image/jpeg");
         outputStream=null;
         outputStream= response.getOutputStream();
         outputStream.write(bArray);
         outputStream.flush();
         outputStream.close();
    else if(fileItem.getContentType().equals("text/plain"))
         %> File : <%= fileItem.getString() %>
    <%
    byte[] bArray=fileItem.get();
    response.setContentType("text/plain");
         outputStream = response.getOutputStream();
         out.println();
         outputStream.write(bArray);
         outputStream.flush();
         outputStream.close();
    %> </p> <%
    %>
    </body>
    </html>
    Edited by: Amit_Joshi on Nov 13, 2007 10:58 PM

    Well Well Well..
    That would not work...
    What you have to do is save the uploaded file content on to a location and then pass the fileName as a request parameter to a deidicated which displays the contents of that file.
    Just as an example
    <html>
    <head>
    <title>File Upload Display</title>
    </head>
    <body>
    <%
    //ServletOutputStream sout=response.getOutputStream();
    StringBuilder strBuilder = new StringBuilder();
    int count=0;
    String f;
    f=request.getParameter("filedb");
    DBManager dbm = new DBManager();
    //dbm.createTable("mms3");
    //log.info("In JSP : "+ f);
    //dbm.insert_data(f,"mms3");
    %>
    <%
    if (ServletFileUpload.isMultipartContent(request)){
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
    String optionalFileName = "";
    FileItem fileItem = null;
    Iterator it = fileItemsList.iterator();
    ServletOutputStream outputStream=null;
    while (it.hasNext()){
       FileItem fileItemTemp = (FileItem)it.next();
    %>
    Name-value Pair Info:
    Field name: <%= fileItemTemp.getFieldName() %><br/>
    Field value: <%= fileItemTemp.getString() %><br/>
    <%
    if (fileItemTemp.getFieldName().equals("filename"))
        optionalFileName = fileItemTemp.getString();
    if(!fileTempItem.isFormFiled()){
       String fileName = fileItem.getName();
       fileItem.write(optionalFileName);
    %>
    Uploaded File Info:
    Content type: <%= fileItem.getContentType() %><br/>
    Field name: <%= fileItem.getFieldName() %><br/>
    File name: <%= fileName %><br/>
    <%
    if(fileItem.getContentType().equals("image/jpeg") || fileItem.getContentType().equals("image/pjeg")) {
    %>
      <img src="FileServlet?fileName=<%=optionalFileName%>"   
    <%
    %>
    </body>
    </html>a sample code snippet for FileServlet.
    String fileName =  request.getParameter(fileName);
      File file = new File(fileName);
       if(!file.exists())
         return;
      // If JSP
      String mimeType = application.getMimeType("fileName");
           If you are using servlet
           String mimeType = this.getServletContext().getMimeType(fileName);
         response.setContentType(mimeType);  
         response.setHeader("Content-Disposition","inline;filename=\\"+fileName+"\\");
      BufferedOutputStream out1 = null;
      InputStream in = null;
      if(mimeType == null)
         mimeType = "application/octet-stream";
      try{
         in = new FileInputStream(f);
         response.setContentLength(in.available());
         BufferedOutputStream out1 = new BufferedOutputStream(response.getOutputStream(),1024);
         int size = 0;
         byte[] b = new byte[1024];
         while ((size = in.read(b, 0, 1024)) > 0)
            out1.write(b, 0, size);
      }catch(Exception exp){
      }finally{
          if(out1 != null){
             try{
                out1.flush();               
                out1.close();
             }catch(Exception e){}
          if(in != null){
            try{in.close();}catch(Exception e){}
      } Hope that might answer your question :)
    However,this is not the recommended way of doing this make use of MVC pattern.Would be a better approach.
    you might think of googling on this and can findout what is the best practise followed for problems of this sort
    REGARDS,
    RaHuL

  • Problem reading RFC values from IRecordSet !!!!

    Hi All,
    I am having some problem reading values from IRecordSet. Can not seem to parse the output structure from RFC. AM using connector gateway service to execute BAPI_EXCHRATE_GETCURRENTRATES.
    Here is the code,
    MappedRecord input = rf.createMappedRecord("input");
    input.put("DATE",new String("01011990"));
    input.put("DATE_TYPE", new String("V"));
    input.put("RATE_TYPE", new String("M"));
    MappedRecord output = (MappedRecord) ix.execute(ixspec, input);
    Object rs = null;
    IRecordSet recSet = null;
    Object result = output.get("EXCH_RATE_LIST");
    if (result == null) {
    response.write("<BR>null");
    rs = new String(" ");
    } else if (result instanceof IRecordSet) {
    IRecordSet irs = (IRecordSet) result;
    response.write("<BR>Got some dataaa");
    IRecordMetaData rsmd = null;
    rsmd = irs.retrieveMetaData();
    irs.beforeFirst();
    while(irs.next()){
    response.write("Row::"+irs.getString("RATE_TYPE")+" "+irs.getString("FROM_CURR")+" "+irs.getString("EXCH_RATE"));
    Am getting the pritn statement, Got Some Data on the PDK component.
    But somehow not able to read the values from IRecordSet
    What is the mistake here?
    Pls help
    Edited by: Aakash Jain on Oct 11, 2008 12:22 AM

    Hi
    Try in this way.
    IRecordSet resultTable = (IRecordSet)outputParams.get("TABLE_NAME");
    for(resultTable.beforeFirst(); resultTable.next(); ) {
    response.write(resultTable.getString(0));
    response.write(resultTable.getString(1));
    Thanks

  • I am facing problem while reading values from properties file ...i am getting null pointer exception earlier i was using jdeveloper10g now i am using 11g

    i am facing problem while reading values from properties file ...i am getting null pointer exception earlier i was using jdeveloper10g now i am using 11g

    hi TimoHahn,
    i am getting following exception in JDeveloper(11g release 2) Studio Edition Version 11.1.2.4.0 but it works perfectly fine in JDeveloper 10.1.2.1.0
    Root cause of ServletException.
    java.lang.NullPointerException
    at java.util.PropertyResourceBundle.handleGetObject(PropertyResourceBundle.java:136)
    at java.util.ResourceBundle.getObject(ResourceBundle.java:368)
    at java.util.ResourceBundle.getString(ResourceBundle.java:334)
    at org.rbi.cefa.master.actionclass.UserAction.execute(UserAction.java:163)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

Maybe you are looking for

  • Ease of use from ver 2 to ver 8

    A long time ago I bought Elements Ver 2 and could not understand it all and returned it.  I am looking for a program to edit photos like fun stuff,,adding people to other picts, changing picture sizes for a group of  picts (pixels/size/names/etc), ch

  • [Solved] System with Linux 3.14 (intel_pstate) noticeable less...

    ... responsive and significantly slower (some numbers below) under light/medium workload, even when compared with ondemand (up_threshold 95). What happened to that famous race to idle concept? Relevant bug report https://bugzilla.kernel.org/show_bug.

  • App submission problem

    i get this message when i click"app submission": You do not have access to this resource based on your membership. Access to technical resources such as pre-release software and associated documentation, and information related to distributing iOS or

  • Settings password

    There is a "sign in" at the bottom left of the printer's control panel screen. When I press it, it asks for a password. I just set up the printer and it did not prompt me to set a password. I have tried entering nothing, and also have entered my hp p

  • Print pdf fill in larger format

    tried Enlarging printer format print and pdf fill in larger format but only print in small format. Can anyone help .please.Alo on another subject what is fixed strings there on the joining page in yellow box. Many thanks from Teenyb