Rahul,
Based on your query (select SourceTableName from SourceTables), I
would guess that your result set would contain a single column with
string data (char or varchar in SQL). If that's correct, then your
loop should look more like this:
while (rs.next()) {
rowArray.add(rs.getString(1));
}
You can also use the column name, as in:
while (rs.next()) {
rowArray.add(rs.getString("SourceTableName"));
}
Your code would only work if the SourceTableName column in the
SourceTables table is of an integer type.
HTH,
Chad
On Jul 15, 9:58 am, Rahul <[email protected]> wrote:
> Hi,
> I apologize because this topic is again n again asked on the forum,
> but after reading the topics I was not able to get an answer to my
> problem.
>
> I am connecting to a server and trying to display an sql query on the
> browser. Here is my server side code:
>
> public class GreetingServiceImpl extends RemoteServiceServlet
> implements
> GreetingService {
> private Connection conn = null;
> private String status;
> private String connString = "Initial value";
> private String url = "jdbc:sqlserver:;database";
> private String user = "";
> private String pass = "";
> public ResultSet rs;
> public Statement stm;
> ArrayList rowArray = new ArrayList();
> String name;
> public ArrayList greetServer(String input) {
> String serverInfo = getServletContext().getServerInfo();
> String userAgent =
> getThreadLocalRequest().getHeader("User-Agent");
> // String s1 = "Select * from Patient";
> try {
> Class.forName
> ("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
> // conn = DriverManager.getConnection(url,user,pass);
> conn = DriverManager.getConnection
> ("jdbc:sqlserver:;database","username","password");
> connString = "We connected";
> stm = conn.createStatement();
> String query1;
> rs = stm.executeQuery("select SourceTableName from
> SourceTables");
>
> while (rs.next()) {
> rowArray.add(String.valueOf(rs.getInt(1)));
>
> }
>
> } catch (Exception e) { connString = e.getMessage();}
>
> // if (conn != null)
> // connString = "We connected";
> // else
> // connString = "We failed to connect";
>
> return rowArray;
> }
>
> }
>
> I am confused in the following areas:
> 1) My sql query contains 4 values (string) is while(rs.next()) loop
> the correct way to copy into from ResultSet to Arraylist?
> 2) I have made my return type to Arraylist, so in the default gwt
> application when the user clicks the send button would it show the
> four values of my sql query or not?
>
> If anyone has some tutorials over how to do this plz tell the links
> that would be very helpful
> thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---