Skip to main content

java.sql.Date and java.sql.Timestamp

4 replies [Last post]
hmorris1970
Offline
Joined: 2007-03-02
Points: 0

I am new to jax-ws and I am attempting to convert some exsisting software into web services. My question, is it possible to use java.sql.Date and java.sql.Timestamp? When I run wsgen I get the following error:

error: java.sql.Timestamp does not have a no-arg default constructor.

or

error: java.sql.Date does not have a no-arg default constructor.

How can I work around this without changing all of the source code?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rstaubit
Offline
Joined: 2006-10-24
Points: 0

Hi I am having same problem from NetBeans 5.5

error: java.sql.Timestamp does not have a no-arg default constructor.
this problem is related to the following location:
at java.sql.Timestamp (Unknown Source)

Did u ever find a workaround ?

thx

hmorris1970
Offline
Joined: 2007-03-02
Points: 0

Yes I did find a work around. After reading the following article

http://weblogs.java.net/blog/kohsuke/archive/2005/09/using_jaxb_20s.html

I created an XmlJavaTypeAdapter which I then used to convert my dates to a string.

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Those types are not supported out of the box. Given that they are in JavaSE, we should probably consider supporting it.

In the mean time, use @XmlJavaTypeAdapter.

migueldejuana
Offline
Joined: 2011-11-22
Points: 0

Is java.sql.Date still unsupported? I have a class with a lot of java.sql.Date and I can't change them.

I'm trying to use @XmlJavaTypeAdapter, but I can't make it work. Could somebody show me a more explicit example?

This is the ant task I used:

<wsgen

verbose="true"

xendorsed="true"

destdir="../service"

resourcedestdir="../service/wsdl"

genwsdl="true"

sei="com.mkyong.ws.HelloWorldWS"

classpath="{myClassesPath};" >

</wsgen>

It doesn't work with both java.sql.Date and @XmlJavaTypeAdapter.

Thanks!