while(rs.next()) is fine and pretty standard way to go through.

I'm confused by how you are adding the data to the ArrayList though.
You get your resultSet which judging by your query should be
TableNames, which I assume are Strings?. But you're getting it out as
an INT then converting to a String. You could just do rs.getString
(1) . That might be a problem. I'm not sure what happens when you
say .getInt() on a String Field. Also, since you know the column name,
"SourceTableName", you could do rs.getString("SourceTableName") as
well.

Hope that's of some help.

On Jul 15, 10: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
-~----------~----~----~----~------~----~------~--~---

Reply via email to