• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing database result set from server to client

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I rebuild the code and restarted the server too
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Eclipse
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no clue how come a complete different code giving same error? If you search with Priti with this new code what error does it show?
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you trying to get data from a column called Priti?
Priti is your search value, not a column name.

Also, can I suggest you use a PreparedStatement. You shouldn't be concatenating your SQL together like that.
It is prone to errors.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is giving same error which i had posted earlier. Even I am not able to figure it out what is happening in this. Its weird.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But then how come when commenting the code it was working fine..I am searching uavname only which i am giving as Priti so its a value and not a column name.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right Dave. PreparedStatement is always a better options. However if you could please at the last code I posted, I am no where using column label, rather I am using columnindex then how come she is getting the same error.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at this part once again

 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I try to print uavname after rs is got it is not printing. I mean to say..

uavsearch.setUAVname(rs.getString(uavname));
System.out.println(uavname);
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think you have made any change I suggested. you still have the same code.

; ???

and that's what is leading to same error. look at the api specification of getString of resultset it has two formats using columnindex or using column label. Think what is happening with your code. I enter a value priti that is stored in variable uavname now how does the function evaluates

uavsearch.setUAVname(rs.getString(Priti))[/code]

in table you have no column called Priti, but the field name is uavname


now see what happens
;
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops I am really very sorry for inconvience caused.

It is working now when i changed to column index from 1 to 7 numbers..
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No need to feel sorry in this profession inconvenience is always caused.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now how to fetch this json array on client side and print it in tabular form in html in jsp page...
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It might have worked with Priti. But you are still likely to get an error with the other data you have that has a single quote I am not remembering the name, check it once.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes true its not working with UAVAlpha's.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before that String String sql , include this line.

 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But it's always better to use PreparedStatement, less prone to errors and faster too.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:You are right Dave. PreparedStatement is always a better options. However if you could please at the last code I posted, I am no where using column label, rather I am using columnindex then how come she is getting the same error.



It wasn't your code, it was this bit in Priti's:



The given search criteria (uavname) was being used as the column name in the result set...hence the error.

Anyway, you spotted that bit...

So, again, my suggestion is:
Part 1
Change to a PreparedStatement, and bind the uavname variable in properly (so avoiding the whole apostrophe issue).

Part 2
Use column names.
There's little performance gain in indices and it reads a lot better.

Part 3
When (and only when) the query is working properly for all your test cases, and you have a List to convert, write the Json conversion code...preferably in a different method.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes its working for apotrosphe strings also.

Now how to pass this json object to client which is my different project. Please help..
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This code is not working for giving json string to client. please help
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am not able to figure out where I need to save this json string in file i.e location of the file.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you have posted all this in the Web Services forum, I assume this is supposed to be a web service? In that case, the JSON would be sent as a response to an HTTP request.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it is web service only..
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code is creating the json string not sending the response.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then how to send json string to client..
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you have done so far is sort a helper method to generate the required output. Next you need to create a web service that will send this generated output to client.

Look at the following link that might help you to figure out how to create a web service.

http://www.eclipse.org/webtools/community/education/web/t320/Implementing_a_Simple_Web_Service.pdf
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I have removed the code for helper method. My code looks like this. Should I do the process of rightclick/new/other/webaservice on this file?
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My project structure is like this..
ps.png
[Thumbnail for ps.png]
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have made client by coding and making a new dynamic web project. I think according to your link we dont need to prepare client just do the steps for wizard and complete it.

Please correct me if I am wrong..
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you follow the given steps it should create the required things for you.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But as per you link I have not done as wizard. I have created as I have server dynamic web project. Same way I created Client dynamic web project.

I havnot perform those steps as shown in link.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are you getting the wsdl?
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope I am not getting the wsdl. Also in your link on page 7 where selection of Axis2 webservices is being seen is not coming in my eclipse.

I think eclipse version is different..
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They are using AXIS as en example, you can use JAX-WS.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not getting the dialog box only in wizard so i think by default it would be JAX-WS..

What if we want to use REstful webservices it should be JAX-RS? So when making dynamic project what it would make WS or RS?
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more question then the jsp pages which i had prepared on client side like Homepage.jsp , login.jsp etc should be made on server?
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I remember for restful it's jax-rs. Jsp of course yes, they are server side components.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My by default is WS web services. I hope its ok..
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.. I guess.
 
Priti Mehta
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My helloclient is not being generated. how come?
 
I am Arthur, King of the Britons. And this is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic