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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>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.


      You are repeating what i said ...
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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 )

>>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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.