File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes MS SQL Server and alue can not be converted to requested type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MS SQL Server and alue can not be converted to requested type" Watch "MS SQL Server and alue can not be converted to requested type" New topic
Author

MS SQL Server and alue can not be converted to requested type

Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 230
Hello.
I'm using Jboss 3.2.3, Microsoft SQL Server 2000 and Microsoft JDBC driver (SP2). I'm using CMP Beans.
I'm getting this very wierd error:

If I use HypersoniqSQL everything works fine!
Anyone?


SCJP 5.0, SCJD URLyBird 1.3.3, OCMJEA 5 (SCEA) Factory Homes
Dmitry Melnik
Ranch Hand

Joined: Dec 18, 2003
Posts: 328
Are you using the similar db schemas with MS SQL and HypersoniqSQL?
Check your in code if you insert/update with string values the columns of types other than varchar/char (like dates, numbets, etc). The conversion of strings to other types might work differently on different kinds of DB servers.
Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 230
I use Xdoclet, so everything is same.
I'm only changing datasource.
Dmitry Melnik
Ranch Hand

Joined: Dec 18, 2003
Posts: 328
I use Xdoclet, so everything is same.
OK, you use XDcolet to generate the DB schema, right?
Back to my point. Lets assume I have a table Table1 which has a column date1 of type "datetime" (or similar). If I execute a piece of code like this:

It might work on certain SQL servers (configured in a certain ways), and it might not work on others (or even the same one but configured differently). And the result depends on the ability of the server to convert the string to the targer data type.
If I use the following code, it will work more often:

My suggestion was to make sure that your code did not do the thing my first example did.
Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 230
Thank you for tip.
But, i'm using EJB CMP. I'm making simple RMI call using ServiceLocator (J2EE Design pattern). Then i'm simply askin value from CMP Bean.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MS SQL Server and alue can not be converted to requested type
 
Similar Threads
Strange SQLException
Unhandled token type: ROW
struts connection pooling with sql server 2000
SQL Server and real data type
Websphere 6.0 DataSource and Microsoft's JDBC driver