I have to create a Web service which accesses a database query. I'm a newbie with web services and I created my first one using Netbeans 6.8 and tomcat 6 (with no db connection) and it worked really fine and I felt myself happy because I thought my job could be easy, so I said to my boss "I will do it soon!". Now when I attemp to deploy it accessin a DB the following error appears:
I have two packages one for the data the web servicies returns ans onother one for making the connection. To be honest I don´t understand the problem...
The web method is
The Web Service return an objeto of the class DatosAfiliado which has the following attributes:
The class DatoGrupo
What does "java.sql.Connection is an interface, and JAXB can't handle interfaces" mean? I do need to establish a connection to a DB...whe working with web services how should I do the connection?
Thanks a lot for your kindly help ... I need it ... I feel like I'm in the middle of the night ... no clues no lights.
I don't see it in your code, but from the exceptions it looks like you are trying to marshall JDBC objects (ResultSet, Connection etc etc) to XML.
An advice is not to let such objects "leak" out of the data layer - even in small applications.
Thus, write your code in such a way that you can temporarily replace the data layer with a dummy that returns fixed results and you will probably solve your problem at the same time.
This is my first web service I’m trying to do in my lifetime. Before using a DB connection I used fixed data and it works perfectly. So, since my mother tongue is not English, let me see if I understood what you wrote: I shouldn’t execute the query directly in the webmethod but in a separate class?
Joined: Oct 04, 2006
The usual procedure is to implement database-related code in a data layer, for instance using DAOs (data access objects).
Reference: http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html A DAO contains queries that fetches data from the database and stores that data in some kind of object. This latter part is crucial in your case. The data must be extracted from the ResultSet obtained when querying the database and inserted into some other POJO that you have written.
The POJO class may also be used as a return-type in method(s) implementing web service operations.
Please do not hesitate to ask if you need further clarification!
Joined: Jul 30, 2005
Hi once again Ivan:
I think I got your idea. I keep on trying ... wait for news soon.
Thank you very much for your patience and good advice.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Unable to create JAXBContext - Don't know why