While(RS.next())?

hi
really need some help here for a school project
i have the below coding in one of my jsp files:
ResultSet RS4 = statement.executeQuery("SELECT item_no, temp_qty FROM sales_temp");
while (RS4.next())
     String item_no2 = RS4.getString(1);
     String temp_qty2 = RS4.getString(2);
ResultSet RS5 = statement.executeQuery("UPDATE store SET Qty_in_shop = Qty_in_shop - "+temp_qty2+" WHERE Item_No = '"+item_no2+"'");
by right, whenever RS4 keeps gets results from sales_temp table, the RS5 should also repeat updating as it is a while right? however, it doesn't work in this case. it only updates the 1st values it gets and ignores the rest.
i removed RS5 and displayed <%=item_no2%> and <%=temp_qty2%> and it shows all. so i have no idea what's wrong.
is there any way i can do to rectify this problem?
thank you!!!

Do you need to have the RS5 variable?
You could try using
statement.executeUpdate("UPDATE store SET Qty_in_shop = Qty_in_shop - "+temp_qty2+" WHERE Item_No = '"+item_no2+"'")You need also to check if your database has autocommit switched on or off.
If not you must perform a .commit() on you connection.
Good luck.

Similar Messages

  • While(rs.next()) HELP PLEASE

    I have the while loop bellow. It only works once, and then show a SQL exception error. What I want from the loop is that it goes through and inserts data matched and found into the table UntiedAutoSearch and many as the loop finds.
    Please let me know why. I will very appreciate you help.
    while(rs.next()) {
    carManufacture = rs.getString("CarManufacture");
    pin = rs.getString("Pin");
    year = rs.getString("Year");
    milage = rs.getString("Milage");
    description = rs.getString("Description");
    if((carManufacture.equalsIgnoreCase(carManufactures)) && (year.equalsIgnoreCase(years))) {
    stmt.executeUpdate("INSERT INTO UnitedAutoSearch VALUES ('"+carManufacture+"', '"+pin+"', '"+year+"', '"+milage+"', '"+description+"')");
    System.out.println("\n\t" + carManufacture + " was found from the \"UnitedAuto\" table.");

    Sorry, here it is again
    package unitedAuto;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import sun.jdbc.odbc.*;
    import java.text.*;
    public class SearchCar extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    try{
         //Create Print Writer
         PrintWriter out = response.getWriter();
         String sql;
         String carManufactures = request.getParameter("carManufactures");
         String years = request.getParameter("years");
         ResultSet rs;
         //Load drivers
    new JdbcOdbcDriver();
    String url = "jdbc:odbc:Tables";
    //Connect to database
    String user = "";
    String password = "";
    Connection con = DriverManager.getConnection(url, user, password);
    Statement stmt = con.createStatement();
         //Create DatabaseMetaData object
         DatabaseMetaData dbMetaData = con.getMetaData();
         String[] tables ={"TABLE"};
         rs = dbMetaData.getTables(null,null,"%",tables);
         int i =0;
         String [] tb = new String[10];
         while(rs.next())
              tb=rs.getString("TABLE_NAME");
         if (tb[i].equals("UnitedAutoSearch")) {
              sql = "DROP TABLE UnitedAutoSearch"; stmt.executeUpdate(sql);}
    stmt.executeUpdate("CREATE TABLE UnitedAutoSearch (CarManufacture VARCHAR(20), Pin VARCHAR(20), Year VARCHAR(4), Milage VARCHAR(6), Description VARCHAR(100))");
         sql = "SELECT * FROM UnitedAuto";     rs = stmt.executeQuery(sql);
         String carManufacture =""; String pin =""; String year =""; String milage =""; String description ="";
         while(rs.next()) {
              carManufacture = rs.getString("CarManufacture");
              pin = rs.getString("Pin");
              year = rs.getString("Year");
              milage = rs.getString("Milage");
              description = rs.getString("Description");
              if((carManufacture.equalsIgnoreCase(carManufactures)) && (year.equalsIgnoreCase(years))) {
                   stmt.executeUpdate("INSERT INTO UnitedAutoSearch VALUES ('"+carManufacture+"', '"+pin+"', '"+year+"', '"+milage+"', '"+description+"')");
                   System.out.println("\n\t" + carManufacture + " was found from the \"UnitedAuto\" table.");
         stmt.close(); con.close();
         callJsp("/unitedAuto/search.jsp", request, response);
    }catch (SQLException se){System.out.println("SQL exception in SearchCar.java" + se); }
    catch (Exception e) {e.printStackTrace();}
    public void callJsp(String jsp,
    HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    RequestDispatcher dispatcher =
    getServletContext().getRequestDispatcher(jsp);
    dispatcher.forward(request, response);

  • Thousands of individual .txt files being created while using "next available file name" option in Save to ASCII step

    I'm using Signal Express to record Load vs Displacement data and export it to a format our engineers can work with (in this case ASCII is okay). It would seem that by selecting the Next Available File Name from the drop down arrow it would do just that. For instance a typical save path for me would look like C:\....Desktop\Project Number and Description\Run_1.txt within that Run1.txt file would be all the data points for that run. When I hit record again Signal Express would (SHOULD) create a Run_2 since it's the Next Available File Name.
    But instead what it does is creates a single txt file for every single sample point being read. Needless to say, If I'm recording 6 second of data at 1khz I end up with thousands of txt files!
    The first thing that comes to mind is, why would anyone want this?
    Second is how can I record multiple individal runs for the same project and have the file name increment?
    SCXI- 1000 Chassis w/ 1346 adapter
    PCI 6281 DAQ card
    SCXI- 1520 Bridge Board w/ 1314 Terminal Block (x2)
    SCXI- 1180 Feedthrough Panel w/ 1302 Block
    Signal Express 2014.
    Win7 Enterprise

    ...and more attachments of the ASCII save path, before and after acquiring 4 seconds of data along with one of the files from that folder.
    Again, this is 4 seconds of two-channel spring  plot data at 100 Samples to Read @ 1k Rate (Start Run.... wait 4 seconds or two full test sample cycles... Stop Run).
    ~EDIT~
    The .txt file would not attach (I think it's too small). Here's what it looks like if you were to open it:
    Load vs Displ - Displ (inches)    Load vs Displ - Load (lbs)
    3.736323                              273.751906
    Also, for some reason it won't let me attach my project file. It's a .seproj extension but the forum thinks it's 1k in size and "empty"
    Message Edited by OKors on 06-05-2009 05:57 PM
    SCXI- 1000 Chassis w/ 1346 adapter
    PCI 6281 DAQ card
    SCXI- 1520 Bridge Board w/ 1314 Terminal Block (x2)
    SCXI- 1180 Feedthrough Panel w/ 1302 Block
    Signal Express 2014.
    Win7 Enterprise
    Attachments:
    FolderBeforeSave.JPG ‏39 KB
    FolderAfterSave.JPG ‏239 KB

  • Weak signal while right next to router with ipad 4

    I recently got an ipad 4 and the wifi signal it is receiving is very weak unless I am 5 feet from the router. All of my other devices and computers work fine from long distances. This is defeating me, if anyone has an answer, I give a pretty mean hug. <3

    The first step to troubleshooting is always to reboot the devices. This will solve more problems than any other step to try, so first off, let's power down the iPad and any other devices we are connecting to the network. While they are powered down, let's reboot the router. Leave the router off for a few seconds before powering it back on and wait until all of the lights come back on before powering up the iPad and other devices.
    If you have a wireless phone or any other wireless technology near the router, try moving it somewhere else. Wireless phones can sometimes use the same frequency as a wireless router, which can cause the signal strength to degrade as it weeds out the interference. This can also be true of other wireless devices like baby monitors, so make sure the area around the router is clear of these devices.
    Just as it is important to keep your iPad's software up to date, it can be important to keep your router's firmware updated. The firmware is what runs the router, and as we add newer devices (like the iPad), older firmware can run into problems.
    You'll need to log in to your router to update the firmware. You can log into the router from a web browser on your PC or your iPad, but you need to know the right address, the username and the password. These might be located in the manual or on a sticker on the router itself.
    The standard address for logging into a router is http://192.168.0.1, but some routers use http://192.168.1.1 and a few use http://192.168.2.1.
    If you don't know the username and password, try "admin" as a username and "admin" or "password" as the password. You can even try leaving the password blank. If those don't work, you will need oohbm70 to find the correct username/password combo or refer to your particular brand of router on how to do a hard reset (if possible kit).
    If you are still having problems with multiple devices, you may have a hardware problem. But before you go out and replace your router, you can try buying an external antenna. Make sure that your router supports connecting an external antenna before you run down to Best Buy.
    There are two types of Wi-Fi antenna: omnidirectional and high gain. A high gain antenna broadcasts the signal in only a single direction, but the signal itself is much stronger. This is great if your router is on one side of the house, but if your router is in the middle of your house, you'll probably want an omnidirectional antenna.
    Also, make sure you buy the antenna from a store that allows returns for any reason. We're basically troubleshooting the router's antenna, and if the problem is with the router itself, hooking up an external antenna won't fix the problem

  • Ip3g random reduction of wifi signal while next to AEBS

    Just got the iphone. I have an AEBS in my house (the 2007 version). I do have the AEBS set to n (but g compatable). I have noticed from time to time in my house, the bars on the iphone drop to two waves...even while right next to the AEBS. Then, after a bit, they come back to three bars. Odd that the signal wouldn't be full strength all the time..especially when right next to the AEBS.

    Apple Store checked my phone: wifi was not picking up as it should. They replaced.

  • What's wrong with this while loop?

    Hi, folks. for the code fragment blow, resultSetArray holds two objects of type ResultSet. From those println statement, i can see the whole while loop(the most outter one) process goes alrite the first time right from begining to the end. However, when variable j increases from 0 to 1, the code stops executing at the the line while(rs.next). I just couldnt figure out what causes the problem while i've been fighting with it for several hours. Could someone plz throw me some lights? With your help, i could possibly go to bed before sun rises...
            while(j<resultSetArray.length)
              //for(int j=0; j<resultSetArray.length; j++)
    System.out.println("show me j is called twice " + j);
                   ResultSet rs = resultSetArray[j];
    System.out.println("the converting rs object is called twice and it is not null " + rs);
                  int numWantedColumns = wantedColumnNames.size();
                  //if it's about go or single trip
                  if(j==0 && rs != null)
                      go = new Element("Go");
                       //go.setText("go");
                       //result.addContent(go);
                  //if it's about return trip
                  else if(j==1 && rs != null)
                      back = new Element("Back");
                       //back.setText("back");
                       //result.addContent(back);
                  if(rs!= null)
    System.out.println("this hell is called twice coz it's not null");
                   while(rs.next())
    System.out.println("what about here?");
                        Element flightInfo = new Element("FlightInfo");
         System.out.println("while rs.next() is called");
                        for (int i = 0; i < numWantedColumns; i++)
                           String columnName   = (String)wantedColumnNames.get(i);
         System.out.println("column name is " + columnName);
                           String value = rs.getString(columnName);
          System.out.println("column value is " + value);
                           flightInfo.addContent(new Element(columnName).setText(value));
                        if(j==0)
                           go.addContent(flightInfo);
                        else if(j==1)
                             back.addContent(flightInfo);
                   else if(rs == null)
                        break;
                   j++;
             }

    i've got the problem sort out, eventually. there was actually nothing wrong with the while loop. it was caused by a typo in databse, instead of having Brisbane, i typed Bisbane. The single letter r cost me more than 6 hours to figure it out. it was such a painful feeling while i realized i made a such stupid mistake.
    by the way, as jnw777 mentioned, output rs.next() info instead of the test line. i did try it, however i didnt realize even System.out.println(rs.next()) would cause the cursor move down one row from its current position. so, plus the original while(rs.next()) statement, it was moving the cursor two rows down at a time! And i just couldnt think of this caused me the fact i was only getting the even number row of the ResultSet while i was sniffing the bug from a class with 700+ lines of code. I was so excited and just couldnt stop yelling at the moment i got over it! That was a damn execiting moment...
    now, i am wondering if anyone in this wonderland would like to share his/her stories.

  • Noclassfound error while connecting java with oracle database

    hi all
    the source code metioned below gets compiled. but when it is run
    it gives thefollowing error.
    ClassNotFoundException: jdbc.driver.OracleDriver
    Exception in thread "main" java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getConnection(DriverManager.java:532)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)
    at pract.main(pract.java:16)
    import java.sql.*;
    class pract
    public static void main (String args []) throws SQLException
         try
              Class.forName("jdbc.driver.OracleDriver");
              catch(java.lang.ClassNotFoundException e)
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
              Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@anant:1521:student", "scott", "tiger");
    // @machineName:port:SID, userid, pas
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("select * from emp");
    while (rset.next())
    System.out.println (rset.getString(1)); // Print col 1
    stmt.close();
    i have included the following driver classes in the classpath
    ojdbc.jar,
    ojdbc_g.jar,
    classes111.jar
    but still im unable to connect.
    can anyone help me in solving this simple problem.

    hi ,
    you hav not stated which oracle ur using...still if u r using oracle 9i then u hav to include classes12.jar file in ur lib build classpath and then tryout following changes in code....
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    conn = DriverManager.getConnection("jdbc:oracle:thin:@<host>:<port>:<sid>","scott","tiger");
    hope this ll help....

  • How to print contionus data in next page

    Hi! All
    I'm displaying data using classic list display.
    my requirement is if my total no. of records is 10 need to display first 5 records in 1st page and the next 5 in next page along with these records i'm displaying other details which are like header details for the document. thus while printing next 5 records in next page need to print along with those hedar details .
    how to print it.
    Regards
    Kv

    hiiii  Kv
    the complete information on printing ALVs  has been given in the following ...link
    go through it
    http://help.sap.com/saphelp_sm32/helpdata/en/a6/6dee408a63732ae10000000a155106/content.htm

  • How to make for loop pass only once in a next() method

    Good Day!
    Can anyone help me or suggest any idea to resolve my problem with the below code, wherein it will only pass the for loop only once. I already tried inserting the for loop in side the if (sqlset4.isFirst()) condition but the problem is it only retrieved the first row of the resultset.
    Cheers!
                   Statement sOutput = consrc.createStatement();
                            ResultSet sqlset4 = sOutput.executeQuery(xquery);
                            ResultSetMetaData rsMetaData = sqlset4.getMetaData();
                            int numberOfColumns = rsMetaData.getColumnCount();
                            String writefld = "";
                            while (sqlset4.next()) {
                                 writefld = "";
                                 for (int i = 1; i <= numberOfColumns; i++) {
                                     if (xxformatid.equals("1") || xxformatid.equals("3")) {
                                         writefld = writefld + "sqlset4.getString(" + i + ").trim()" + "|";
                                writefld = writefld.substring(0, writefld.length() - 1) + ")";
                                output.write("\r\n");
                                output.write(writefld);
                            output.close();I am using Netbean IDE 6.8
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi

    Hi everyone!
    What I actually trying to do is that I have a multiple tables and from these tables I'm going to write each of it into a flatfile that is a pipe delimeted that is why I have to make a loop to know how many fields I am going to write. The code that was attached are actually working, my only concern is that it will take a longer time of processing cause every record of a table it will pass to the for loop(checking how many column) wherein number of column/ were already known on the first loop.
    Hi kajbj,
    I think what your trying to explain is almost the same with below code which i had already tried. The problem with this is that the every loop of the outer loop data retrieve is only the data of the first record.
                   Statement sOutput = consrc.createStatement();
                            ResultSet sqlset4 = sOutput.executeQuery(xquery);
                            ResultSetMetaData rsMetaData = sqlset4.getMetaData();
                            int numberOfColumns = rsMetaData.getColumnCount();
                            String writefld = "";
                            while (sqlset4.next()) {
                                 writefld = "";
                                 if (sqlset4.isFirst()) {
                                    for (int i = 1; i <= numberOfColumns; i++) {
                                        if (xxformatid.equals("1") || xxformatid.equals("3")) {
                                            writefld = writefld + "sqlset4.getString(" + i + ").trim()" + "|";
                                writefld = writefld.substring(0, writefld.length() - 1) ;
                                output.write("\r\n");
                                output.write(writefld);
                            output.close();

  • Problems while writing to file

    Hi,
    I'm trying to query my test database (mysql) and to write these results to a file, I manage to get the results out of the database, but when I try to write for instance an int to a file, the file replaces the int by a square. What can be wrong?? The file is created successfully and I've writen the int to the standard out before writing it to the file; in the standard out the int is correct.
    code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class getData extends HttpServlet {
    FileWriter fw;
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    } catch(Exception e){
    System.err.println("Database driverclass not found");
    Connection conn;
         //insert values into DB
    try {
         conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=admin12&password=adm12");
    Statement stmt = conn.createStatement();
    String slq = "Select * from feedback";
    ResultSet rs = stmt.executeQuery(slq);
    if (rs==null){System.out.println("nOT OK");}
    else{
    try{
    File f = new File("D:\\mysql\\Data.txt");
    fw = new FileWriter(f);
    while(rs.next())
    writeToFile(rs.getString(1));
    writeToFile(rs.getString(2));
    writeToFile(rs.getInt(3));
    writeToFile(rs.getInt(4));
    writeToFile(rs.getString(5));
    writeToFile(rs.getInt(6));
    catch(IOException e)
    System.out.println("Error occured while writing to file");
    stmt.close();
         conn.close();
    } catch(SQLException sqle){
    System.err.println("A SQL error has occured: " + sqle.getMessage());          
    /* output your page here*/
    out.println("<html>");
    out.println("<head>");
    out.println("<title>getDataServlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h2>Data recovered</h2>");
    out.println("</body>");
    out.println("</html>");
    out.close();
    fw.flush();
    fw.close();
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    private void writeToFile(int i)
    try{
    System.out.println("test: "+i);
    fw.write(i);
    fw.write(";");
    }catch(IOException e1)
    private void writeToFile(String str)
    try{
    if (str!=null&&(str.equals("null")==false)){
    fw.write(str);
    fw.write(";");
    }catch(IOException e2)

    I would imagine that FileWriter is writing the byte value to the file. Just change your SQL get to this writeToFile(rs.getString(6)); and write it as a String instead of an int.
    DesQuite

  • Ai read in while loop

    I am acquiring data from a DAQ e series card. i intialized the daq by using AI config out side while loop . i used AI start and AI read in while loop . iam acquiring data from 5 channels. the buffer size ia 1000 and so is the scan rate in AI start.I want to save the acquired data in the file. i am also displaying data o n chart. every thing is working fine. my problem is i want to save 500 points in one seconds. for this i changed the while loop execution time by using waint until multiple sec VI and assign it 10  i was expecting that now iwll save more data point in file as now loop will execute more fast but it does not happen like this. is there any way to minimize the executing time of whil loop.i checked if i deleted AI start and AI read then loop execute very very quickly. should i place AI start and AI read out side loop but then how will it acquire data contiously. I m attaching gif file of the protion of my VI .any suggestion?
    Attachments:
    myVi.GIF ‏72 KB

    I was working quickly, and from memory, so my apologies for errors or non-clarity in my previous post. :-(
    The AI START VI, should be used OUTSIDE the loop, since you only want to START the task ONCE.
    When the task is complete (your WHILE loop is done), then call the AI CLEAR task to clean up (ONCE).
    If you set the NUMBER OF SCANS TO ACQUIRE input to AI START to zero, that has a special meaning: acquire data indefinitely. It will not stop on it's own (assuming no errors occur), you have to explicitly stop it.
    If you do this, you have to read the data often enough to avoid buffer overflow, which means the incoming data is filling up the buffer faster than you're emptying it.
    I have attached a picture of the general idea. If you really want to use the CPU efficiently, then consider the shift-register idea in the picture - you process on batch of data WHILE the next batch is coming in. If you want a simpler solution, forget the shift-reg, and process it directly after reading it. If your buffer is twice the size of your processing size, you'll be OK.
    Message Edited by CoastalMaineBird on 09-14-2005 07:45 PM
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks
    Attachments:
    DAQExample.png ‏16 KB

  • Heap space error while creating XML document from Resultset

    I am getting Heap space error while creating XML document from Resultset.
    It was working fine from small result set object but when the size of resultset was more than 25,000, heap space error
    I am already using -Xms32m -Xmx1024m
    Is there a way to directly write to xml file from resultset instead of creating the whole document first and then writing it to file? Code examples please?
    here is my code:
    stmt = conn.prepareStatement(sql);
    result = stmt.executeQuery();
    result.setFetchSize(999);
    Document doc = JDBCUtil.toDocument(result, Application.BANK_ID, interfaceType, Application.VERSION);
    JDBCUtil.write(doc, fileName);
    public static Document toDocument(ResultSet rs, String bankId, String interfaceFileType, String version)
        throws ParserConfigurationException, SQLException {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document doc = builder.newDocument();
            Element results = doc.createElement("sims");
            results.setAttribute("bank", bankId);
            results.setAttribute("record_type", "HEADER");
            results.setAttribute("file_type", interfaceFileType);
            results.setAttribute("version", version);
            doc.appendChild(results);
            ResultSetMetaData rsmd = rs.getMetaData();
            int colCount = rsmd.getColumnCount();
            String columnName="";
            Object value;
            while (rs.next()) {
                Element row = doc.createElement("rec");
                results.appendChild(row);
                for (int i = 1; i <= colCount; i++) {
                    columnName = rsmd.getColumnLabel(i);
                    value = rs.getObject(i);
                    Element node = doc.createElement(columnName);
                    if(value != null)
                        node.appendChild(doc.createTextNode(value.toString()));
                    else
                        node.appendChild(doc.createTextNode(""));
                    row.appendChild(node);
            return doc;
    public static void write(Document document, String filename) {
            //long start = System.currentTimeMillis();
            // lets write to a file
            OutputFormat format = new OutputFormat(document); // Serialize DOM
            format.setIndent(2);
            format.setLineSeparator(System.getProperty("line.separator"));
            format.setLineWidth(80);
            try {
                FileWriter writer = new FileWriter(filename);
                BufferedWriter buf = new BufferedWriter(writer);
                XMLSerializer FileSerial = new XMLSerializer(writer, format);
                FileSerial.asDOMSerializer(); // As a DOM Serializer
                FileSerial.serialize(document);
                writer.close();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            //long end = System.currentTimeMillis();
            //System.err.println("W3C File write time :" + (end - start) + "  " + filename);
        }

    you can increase your heap size..... try setting this as your environment variable.....
    variable: JAVA_OPTS
    value: -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m

  • Getting Error while creating ResultSetDynaClass

    Hi,
    I am getting 'Cannot load column class 'java.lang.String': java.lang.NullPointerException ' while executing the below code
    ResultSetDynaClass rsdc = new ResultSetDynaClass(resultSet,true);. I have displayed the resultset and am able to get the data from database. This is the class i used,
    package bean;
    import java.io.*;
    import java.lang.reflect.*;
    import java.sql.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.apache.commons.beanutils.*;
    public class ControllerServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    // Define the connection
    Connection con = null;
    try {
         // Check that the DB2Driver class is available
              Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
    // Attempt to connect to the Database
    con = DriverManager.getConnection("jdbc:db2:testdb","db2admin","ameena");
    Statement statement =con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    String sql2 = "SELECT name, age FROM user3";
    ResultSet resultSet = statement.executeQuery(sql2);
    //out.println(resultSet.first());
    while (resultSet.next()) {
    out.println(resultSet.getString("name") + "|" + resultSet.getString(2) );
    ArrayList results = new ArrayList(); // To hold copied list
    resultSet.beforeFirst();
    ResultSetDynaClass rsdc = new ResultSetDynaClass(resultSet,true);
    DynaProperty properties[] = rsdc.getDynaProperties();
    BasicDynaClass bdc =
    new BasicDynaClass("UserData", BasicDynaBean.class,
    rsdc.getDynaProperties());
    Iterator rows = rsdc.iterator();
    while (rows.hasNext()) {
    DynaBean oldRow = (DynaBean) rows.next();
    DynaBean newRow = bdc.newInstance();
    PropertyUtils.copyProperties(newRow, oldRow);
    results.add(newRow);
    resultSet.close();
    statement.close();
    con.close();
    catch (ClassNotFoundException e1) {
              e1.printStackTrace();
              out.println(e1.getMessage());
    // Make sure to catch any exceptions
    catch (SQLException e) {
    out.println(e.getMessage());
    e.printStackTrace();
    } catch (IllegalAccessException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              out.println(e.getMessage());
         } catch (InstantiationException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              out.println(e.getMessage());
         } catch (InvocationTargetException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              out.println(e.getMessage());
         } catch (NoSuchMethodException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              out.println(e.getMessage());
    The printstacktrace that i got is
    java.sql.SQLException: Cannot load column class 'java.lang.String': java.lang.NullPointerException
         at org.apache.commons.beanutils.ResultSetDynaClass.loadClass(ResultSetDynaClass.java:196)
         at org.apache.commons.beanutils.JDBCDynaClass.createDynaProperty(JDBCDynaClass.java:175)
         at org.apache.commons.beanutils.JDBCDynaClass.introspect(JDBCDynaClass.java:199)
         at org.apache.commons.beanutils.ResultSetDynaClass.<init>(ResultSetDynaClass.java:138)
         at bean.ControllerServlet.doGet(ControllerServlet.java:47)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         at java.lang.Thread.run(Thread.java:595)
    Please help me to resolve this. I am unable to proceed

    Try the following in the ERP backend system:
    Standard Hierarchy Inconsistencies
    Issue: one Cost Center is repeating in more than one node in Cost Center Standard Hierarchy.
    Update from SAP Global support, the following was the email received:
    in transaction KSH3 please run both the ambiguity and completeness check(Menu -> Extras -> Check and Help functions).
    If you think that your standard hierarchy is inconsistent you can check that as following:
    Run transaction Extras -> Hierarchy - Master data -> Test. The result shows you if there are in consistencies. If that is the case run also Extras -> Hierarchy - Master data -> Comparison.
    Alternatively, you can run the report 'RKCORRH1' (TN SE38).
    Run both the Hierarchy->Master data->test and the
    Hierarchy->Master data->comparison.
    As stated above inconsistency message showed after Test. Run the comparison and you get a similar message.
    Once the above two are run, again when you go to test, the inconsistency disappears.

  • Error while running ejbc - Deployment time

    Whilst trying to deploy my WSE through J2EE deploy tool i get the follwoing error:
    Deployment failed on target Server localhost:4848 : Deployment Error -- Error while running ejbc -- Fatal Error from EJB Compiler -- jaxrpc compilation exception
    I am not using ejb as far as I'm aware. I have succesfully buit my WSE using asant with no compilation errors.
    Here is copy of the code
    package rcews;
    import java.rmi.RemoteException;
    import java.util.Vector;
    import java.sql.*;
    import javax.sql.DataSource;
    //import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.xml.rpc.server.ServletEndpointContext;
    import javax.xml.rpc.server.ServiceLifecycle;
    import javax.xml.rpc.ServiceException;
    public class RceWSImplementation implements RceWSInterface, ServiceLifecycle {
         private DataSource ds;
         ServletEndpointContext endPtCntxt;
         public void init(Object context) throws ServiceException {
              try {
                   endPtCntxt = (ServletEndpointContext) context;
                   InitialContext ic = new InitialContext();
                   // Specify the logical name of the database
                   // Obtain the DataSource object associated with the logical name
                   ds = (DataSource) ic.lookup("java:comp/env/jdbc/rcedstar");
                   ic.close();
              } catch(NamingException ne) {
                   ne.printStackTrace();
                   throw new ServiceException("\nCannot initialise JNDI ENC\n", ne);
         public String [] getSignals() throws RemoteException {
              Statement sqlStmnt;
              ResultSet rs;
              String countQuery = "SELECT COUNT(DISTINCT signal_ref) FROM tblSignals";
              String query = "SELECT DISTINCT signal_ref FROM tblSignals ORDER BY signal_ref";
              String[] signals = null;
              int count = 0;
              try {
                   // Establish connection with the database and return a Connection object
                   Connection con = ds.getConnection();
                   System.out.println("Connection made Successfully");
                   // Create and execute SQL statement
                   sqlStmnt = con.createStatement();
                   rs = sqlStmnt.executeQuery(countQuery);
                   if(rs.next()) {
                        int size = rs.getInt(0);
                        signals = new String[size];
                   rs = sqlStmnt.executeQuery(query);
                   // Move through ResultSet and pull singal reference information
                   while(rs.next()) {
                        signals[count] = rs.getString("signal_ref");
                        count++;
                   con.close();
              } catch (Exception e) {
                   e.printStackTrace();
              return signals;
         public Vector getLampDurations(String[] signal_refs, String[] lamps, int hours) throws RemoteException {
              // Varaible Declarations
              Vector details = null;
              String signals, lamp_colours;
              PreparedStatement psqlStmt;
              ResultSet rs;
              String query = "SELECT signal_ref, light, SUM(duration), SUM(on_count) FROM tblsignals, tblsignal_events " +
                        "WHERE tblSignals.id = tblSignal_Events.id AND tblSignals.signal_ref IN (?) AND tblSignals.light IN (?) " +
                        "GROUP BY signal_ref, light" +
                        "HAVING SUM(duration) > ?";
              StringBuffer sbSignals = new StringBuffer(50);
              StringBuffer sbLamps = new StringBuffer(31);
              // Build Strings for use in Prepared SQL statements
              for(int i=0;i<signal_refs.length-1;i++) {
                   sbSignals.append("'" + signal_refs[i] + "'");
                   sbLamps.append("'" + lamps[i] + "'");
                   if (i <= signal_refs.length - 2) {
                        sbSignals.append(",");
                        sbLamps.append(",");
              signals = new String(sbSignals);
              lamp_colours = new String(sbLamps);
              try {
                   // Establish connection with the database and return a Connection object
                   Connection con = ds.getConnection();
                   System.out.println("Connection made Successfully");
                   // Apply strings to statement
                   psqlStmt = con.prepareStatement(query);
                   psqlStmt.setString(1, signals);
                   psqlStmt.setString(2, lamp_colours);
                   psqlStmt.setInt(3, hours);
                   // Obtain data from DB
                   details = new Vector(4);
                   String[] results = new String[4];
                   rs = psqlStmt.executeQuery();
                   while(rs.next()) {
                        // Copy contents of the ResultSet into a String Array for each record
                        int i = 0;
                        results[i]   = rs.getString(1);               //Signal Reference
                        results[i++] = rs.getString(2);               //Lamp (i.e colour)
                        double seconds  = rs.getDouble(3);          //Duration
                        seconds = seconds / (60*60);               //Convert Seconds to Hours - would be nice to convert to Hours:mins:secs
                        results[i++] = String.valueOf(seconds);
                        results[i++] = String.valueOf(rs.getInt(4));     //Number of Times lamp has been switched on
                        // Append the string Array to a Vector
                        details.addElement(results);
                   if (psqlStmt != null) { psqlStmt.close(); }
                   if (con != null) { con.close(); }
              } catch (Exception e) {
                   e.printStackTrace();
              return details;
         public void destroy() {
              ds = null;
    }

    Have since found this from the server log but I have no idea about how to solve this!
    [#|2004-03-10T15:08:04.574+0000|INFO|j2ee-appserver1.4|javax.enterprise.system.tools.deployment|_ThreadID=13;|DPL5109: EJBC - START of EJBC for [RCE-WebService]|#]
    Remote message: Processing beans ....
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\RCE-WebService\WEB-INF\classes\rcews\RceWSInterface_Tie.java:32: '(' or '[' expected
    super(new rcews.RCE-WebService_SerializerRegistry().getRegistry());
    ^
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\RCE-WebService\WEB-INF\classes\rcews\RceWSInterface_Tie.java:32: ')' expected
    super(new rcews.RCE-WebService_SerializerRegistry().getRegistry());
    ^
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\RCE-WebService\WEB-INF\classes\rcews\RCE-WebService_SerializerRegistry.java:18: '{' expected
    public class RCE-WebService_SerializerRegistry implements SerializerConstants {
    ^
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\RCE-WebService\WEB-INF\classes\rcews\RCE-WebService_SerializerRegistry.java:33: <identifier> expected
    registerSerializer(mapping,rcews.RceWSInterface_getLampDurations_RequestStruct.class, type, serializer);
    ^
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\RCE-WebService\WEB-INF\classes\rcews\RCE-WebService_SerializerRegistry.java:33: '{' expected
    registerSerializer(mapping,rcews.RceWSInterface_getLampDurations_RequestStruct.class, type, serializer);
    ^
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\RCE-WebService\WEB-INF\classes\rcews\RCE-WebService_SerializerRegistry.java:65: illegal start of type
    return registry;
    ^
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\RCE-WebService\WEB-INF\classes\rcews\RCE-WebService_SerializerRegistry.java:65: <identifier> expected
    return registry;
    ^
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\RCE-WebService\WEB-INF\classes\rcews\RCE-WebService_SerializerRegistry.java:68: 'class' or 'interface' expected
    private static void registerSerializer(TypeMapping mapping, Class javaType, QName xmlType,
    ^
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\RCE-WebService\WEB-INF\classes\rcews\RCE-WebService_SerializerRegistry.java:74: 'class' or 'interface' expected
    ^
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\RCE-WebService\WEB-INF\classes\rcews\RCE-WebService_SerializerRegistry.java:75: 'class' or 'interface' expected
    ^
    10 errors

  • Error while running survlet: http status 505

    Hii all,
    I have a problem in running servlet from my Firefox and I am using Tomcat 5.5.25. I having a problem in deploying the servlet.
    I ran my servlet as:http://localhost:8085/log?user_name=******&password=*****
    Servlet Maping looks like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements. See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License. You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    -->
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
    <display-name>Welcome to Tomcat</display-name>
    <description>
    Welcome to Tomcat
    </description>
    <servlet>
         <servlet-name>Aboutus</servlet-name>
         <servlet-class>AboutusServlet</servlet-class>
    </servlet>
    <servlet>
         <servlet-name>Login</servlet-name>
         <servlet-class>LoginServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Aboutus</servlet-name>
         <url-pattern>/aboutus</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
         <servlet-name>Login</servlet-name>
         <url-pattern>/log</url-pattern>
    </servlet-mapping>
    </web-app>
    Below is my servlet code looks like,
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class LoginServlet extends HttpServlet
         ServletOutputStream sos;
         Connection con;
         Statement st,st1,st2;
         ResultSet rs,rs1,rs2;
         public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
              String logvalid="";
         String medicine="";
    //String destination="";
         try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con=DriverManager.getConnection("jdbc:odbc:health","scott","tiger");
                   System.out.println("Connection Successfull");
                   String user_id=req.getParameter("user_id");
                   String pass=req.getParameter("pass");
                   res.setContentType("text/html");
                   sos=res.getOutputStream();     
                   System.out.println("username:"+user_id+"pass:"+pass);
                   String query="select user_id,pass from newuser where user_id='"+user_id+"' and pass='"+pass+"'";
                                  System.out.println(query);
                   st=con.createStatement();
                   rs=st.executeQuery(query);
                   ResultSetMetaData rsmd= rs.getMetaData();
              /*     int count=rsmd.getColumnCount();
                   System.out.println("$$$$$$$$$$$$$$$$"+count);*/
                   System.out.println("value of rs="+rs);
                   if(rs!=null)
                        System.out.println("rs not null");
                   if(rs.next())
                        System.out.println("inside while");
                        if(user_id.equals(rs.getString(1)) && pass.equals(rs.getString(2)))
                             System.out.println("inside if");
                             logvalid="Valid";
                             System.out.println("valid");
    String query1="select distinct medicine from prescription";
                             System.out.println(query1);
                             st1=con.createStatement();
                             rs1=st1.executeQuery(query1);
                        while(rs1.next())
                             source=source+rs1.getString(1)+"$";
                        //String query2="select distinct destination from route";
                        //System.out.println(query2);
                   //st2=con.createStatement();
                   //rs2=st2.executeQuery(query2);
                             //     System.out.println(query2);
                   /*while(rs2.next())
    destination=destination+rs2.getString(1)+"$";
              }     // if loop for checking user id
         }     // end of if for rs.next()
         sos.println(logvalid+":"+medicine);
                   }// // end of if for rs!=null
         if(rs==null)
              System.out.println("rs=null");
    catch(Exception e)
                   System.out.println(e);
         public void destroy()
              try
                   con.close();
                   sos.close();
                   rs.close();
                   st.close();
                   catch(Exception e)
                        System.out.println(e);
    Here is the error report:
    HTTP Status 500 -

    Hi all,
    The issue is solved now.It was an silly mistake in the source code. I haven't extend the class.
    Thanks,
    Senthil.

Maybe you are looking for

  • Why do I get the error message saying "connection was reset"?

    I get this message every once in a while. I have to restart my computer to fix this issue, temporarily. I says "'''The connection was reset'' The connection to the server was reset while page was loading. I have no know ISP issues.

  • Unable to Open .cfg file in NVRAM or Flash in Cisco GNS3 Router

    Hello Cisco Community A program that I'm using to manage cisco devices has created a .cfg file in nvram in a gns3 router. When the program tries to access the I get the following error message: 'Could not open policy cfg file' The file is a Tcl file.

  • Audio Card cannot be found

    Audio Card cannot be foundi I just realized that I have lost all audio. I could use some help trouble shooting the issue. I have a Dell Dimension 900 w/ a Creative SB Audigy 2 ZS audio card. I run Vista Home Premium w/ SP2. There have been no recent

  • I want timestamp instead of number or bullets in TextEdit

    In making a list, I want to be able to use a timestamp (which includes date and exact time) instead of number or bullets. When making a list, I hit enter and the cursor goes to the next line with a bullet (or a number) already appearing before the cu

  • Update time out -1001

    hi im in australia and im trying to update my Osx. i get the sorry timeout error -1001 message everytime. can anybody help me?