Home » Developer & Programmer » JDeveloper, Java & XML » how i pass recordset value to string variable
how i pass recordset value to string variable [message #209835] Mon, 18 December 2006 01:17 Go to next message
Messages: 210
Registered: February 2006
Location: karachi
Senior Member
Hi Master,

How do I pass a table column value into string variable. See my code below:

import java.sql.*;
public class Waheed {
    public Waheed() {
     public static void main (String args [])
   String s = "9 23 45.4 56.7";

      System.out.println ("going for connection");
       // DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
       Connection conn = 

        Statement stmt = conn.createStatement();
        ResultSet rset = stmt.executeQuery("select accid from accbal");
         System.out.println ("going for connection");
        while (rset.next())

            s= rset.getString("accid");  this line give me error

            System.out.println (rset.getString("accid"));
         System.out.println (s);
      catch(Exception e){

This line give me an error:

s= rset.getString("accid");
s is string variable

Plese give me an idea how I can pass accid in s variable.


Re: how i pass recordset value to string variable [message #211514 is a reply to message #209835] Fri, 29 December 2006 01:27 Go to previous message
Messages: 173
Registered: January 2006
Senior Member
You have missed putting braces around the while-loop block, so only the statement
s= rset.getString("accid");
is executed in the loop. The print statements gets executed after the result set is exhausted - therefore the error.

Place the print statements (and any other processing you want to do with the result set) within the while-loop - it'll work fine!
Previous Topic: pagepanel visual editor activation
Next Topic: loadjava error resolving third-party class library
Goto Forum:

Current Time: Mon Oct 24 09:55:41 CDT 2016

Total time taken to generate the page: 0.06883 seconds