Strange value output when using MS SQL

Basically I have a table with the column A with type int in it.  

Say when I do this in SQL Query: select value1 from A, I get 21.

Here is the strange thing, I have the JSP that does the same thing, use ODBC driver to connect to the database.  But instead of 21, I get 21.0.

Is there a configuration to turn this off? I know I can do Right(21.0 , 1) to get 21, but that is a hack approach.

This works fine when I use MySQL and JDBC driver, so my guess is it could be the ODBC driver.... any experts have any information about this?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

actonwangConnect With a Mentor Commented:
>>I think I should not have to use resultSet.getInt(column)  if my column is allready type int.
     ok. how do you get the data then? if you use other getXX other than getInt, it might be converted to other type. Say, 20 to 20.0.
    It has nothing to do with sql or jdbc. it is how you get it and use it.
>>use ODBC driver to connect to the database.  But instead of 21, I get 21.0.

   are you using jdbc-odbc driver? What code are you using to get 21.0? usually you use:


  to get value. So how come you get 21.0?
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
you must use resultSet.getInt(column) to get the int value of the Field i think you are getting a double value.

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.


      You are repeating what i said ...
fylix0000Author Commented:
I am using the sun.jdbc.odbc.JdbcOdbcDriver driver and
in one .sql file I have this statement.
                                                    Select COUNT(boaeft.Message_Id) as EFT_Count FROM boaeft  
Which if I type this in a SQL query window of SQL 2000 then I would get 21.

But then I use the value EFT_Count at some place and magically it turns to 21.0 or 21.00 for some reason.  This happens quite consistenly when the value is type int, bigint, smallint ect...

The above case is just one of the example, there are some column that has distinct int value such as 23, 1, 3, 4 ect.... but when I use it in the jsp it turns to 23.0, 1.00, 3.00 ect....

I think I should not have to use resultSet.getInt(column)  if my column is allready type int.  I wonder if there is some funny setup from ODBC driver that cause this, because the database return a normal int value when I dont use ODBC driver ( aka using the SQL query window )

show me your code snippet where it occurs.
fylix0000Author Commented:
Actually Actonwang, from your question I think I might have figured out something....

You see the code I am using is a bit complex, my company has a custom mapping to map nodeset and tokens and then retreive those  to use it for jsp pages.

I went back and test it and I get 21.0 at the nodeset level, not the jsp.  Basically the value is read from the database using this query and then the other

ToFintrac.FromDb.Add.EdiMap.FintracBatch.SQLQuery.1=select Case when COUNT(sequence_Id)=0 then 1 else case when MAX(Sequence_Id)+1>99999 then 1 else MAX(Sequence_Id)+1 end end as Sequence_Id from batch


So I think I may have to go through this mess and kinda do a hack to make sure all return int number using the CONVERT function from SQL 2000

select Case when COUNT(sequence_Id)=0 then CONVER(int,1) else case when MAX(Sequence_Id)+1>99999 then CONVERT(int,1) else .......

i c. it is a little work ..

yeh... it should not be coming from java or jsp side..
All Courses

From novice to tech pro — start learning today.