Hi Sean,
Thanks for replying.
I understood what you are trying to say.

@Chad can you elborate on "Your code would only work if the
SourceTableName column in the
SourceTables table is of an integer type. " My column name is
presently an varchar type

On Jul 15, 11:49 am, Rahul <[email protected]> wrote:
> Hi,
> Thanks for replying
> I am getting the following error
>
> [ERROR] Uncaught exception escaped
> java.lang.ClassCastException: java.util.ArrayList cannot be cast to
> java.lang.String
>         at com.example.test7.client.Test7$1MyHandler$1.onSuccess(Test7.java:
> 1)
>         at
> com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived
> (RequestCallbackAdapter.java:215)
>         at com.google.gwt.http.client.Request.fireOnResponseReceivedImpl
> (Request.java:264)
>         at com.google.gwt.http.client.Request.fireOnResponseReceivedAndCatch
> (Request.java:236)
>         at com.google.gwt.http.client.Request.fireOnResponseReceived
> (Request.java:227)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>         at java.lang.reflect.Method.invoke(Unknown Source)
>         at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
> 103)
>         at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod
> (IDispatchImpl.java:126)
>         at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke
> (IDispatchProxy.java:155)
>         at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke
> (IDispatchImpl.java:294)
>         at com.google.gwt.dev.shell.ie.IDispatchImpl.method6
> (IDispatchImpl.java:194)
>         at org.eclipse.swt.internal.ole.win32.COMObject.callback6
> (COMObject.java:117)
>         at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
>         at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
>         at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
>         at com.google.gwt.dev.SwtHostedModeBase.processEvents
> (SwtHostedModeBase.java:235)
>         at com.google.gwt.dev.HostedModeBase.pumpEventLoop
> (HostedModeBase.java:558)
>         at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
>         at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)
>
> any suggestions where am i going wrong ?
>
> On Jul 15, 11:44 am, Chad <[email protected]> wrote:
>
> > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to