java long in an Access database  
Author Message
aaronfude





PostPosted: 2006-1-16 7:41:00 Top

java-programmer, java long in an Access database Hi,

Perhaps this is more of an Access question. I'm discovering that
Access' "Long Integer" cannot store a java Long. So I'm resorting to
string the numbers as strings. I'm I doing the right thing (other than
using Access :) ) or missing someting?

Many thanks in advance!

Aaron Fude

 
Arto Viitanen





PostPosted: 2006-1-16 19:42:00 Top

java-programmer >> java long in an Access database email***@***.com wrote:
> Hi,
>
> Perhaps this is more of an Access question. I'm discovering that
> Access' "Long Integer" cannot store a java Long. So I'm resorting to
> string the numbers as strings. I'm I doing the right thing (other than
> using Access :) ) or missing someting?
>
> Many thanks in advance!
>
> Aaron Fude
>

Why not use java.math.BigDecimal? ResultSet supports it (getBigDecimal
etc.) and you can (kind of) calculate with it. If scale is 0, it behaves
like integer.

Arto Viitanen, CSC
Espoo, Finland

 
Bjorn Abelli





PostPosted: 2006-1-19 22:22:00 Top

java-programmer >> java long in an Access database
"Arto Viitanen" wrote...
> email***@***.com wrote:

>> Perhaps this is more of an Access question. I'm discovering that
>> Access' "Long Integer" cannot store a java Long. So I'm resorting to
>> string the numbers as strings. I'm I doing the right thing (other than
>> using Access :) ) or missing someting?

> Why not use java.math.BigDecimal? ResultSet supports it (getBigDecimal
> etc.) and you can (kind of) calculate with it. If scale is 0, it behaves
> like integer.

You've misunderstood the question of the OP.

He doesn't need an alternative to long on the Java side, where obviously a
long is sufficient.

To change from long to BigDecimal wouldn't solve his problem.

As Access/Jet doesn't even support a Java long in numerical form, to change
to BigDecimal would be even worse...

I believe the OP have to live with his current solution, as Access/Jet most
likely will keep the old VB compatible data types only.

Depending on what the OP actually uses the fields for, another solution
*could* be to bitmask the long value (64 bits) into two int's (32 bits) and
store them separately in two fields in the DB, and correspondingly merge
them together into one field when retrieving them from the DB...

I don't know if he would gain anything with it comparing to the "string"
version, but it's nevertheless an alternative...

...or to change to another DB...

// Bjorn A


 
 
aaronfude





PostPosted: 2006-1-30 3:29:00 Top

java-programmer >> java long in an Access database
Bjorn Abelli wrote:
> "Arto Viitanen" wrote...
> > email***@***.com wrote:
>
> >> Perhaps this is more of an Access question. I'm discovering that
> >> Access' "Long Integer" cannot store a java Long. So I'm resorting to
> >> string the numbers as strings. I'm I doing the right thing (other than
> >> using Access :) ) or missing someting?
>
> > Why not use java.math.BigDecimal? ResultSet supports it (getBigDecimal
> > etc.) and you can (kind of) calculate with it. If scale is 0, it behaves
> > like integer.
>
> You've misunderstood the question of the OP.
>
> He doesn't need an alternative to long on the Java side, where obviously a
> long is sufficient.
>
> To change from long to BigDecimal wouldn't solve his problem.
>
> As Access/Jet doesn't even support a Java long in numerical form, to change
> to BigDecimal would be even worse...
>
> I believe the OP have to live with his current solution, as Access/Jet most
> likely will keep the old VB compatible data types only.
>
> Depending on what the OP actually uses the fields for, another solution
> *could* be to bitmask the long value (64 bits) into two int's (32 bits) and
> store them separately in two fields in the DB, and correspondingly merge
> them together into one field when retrieving them from the DB...
>
> I don't know if he would gain anything with it comparing to the "string"
> version, but it's nevertheless an alternative...
>
> ...or to change to another DB...
>
> // Bjorn A

What a complete answer! Thank you very much!

Can I assume that more serious databases, such as MySQL support the
long format?

Thanks!

 
 
IchBin





PostPosted: 2006-1-30 4:43:00 Top

java-programmer >> java long in an Access database email***@***.com wrote:
> Bjorn Abelli wrote:
>> "Arto Viitanen" wrote...
>>> email***@***.com wrote:
>>>> Perhaps this is more of an Access question. I'm discovering that
>>>> Access' "Long Integer" cannot store a java Long. So I'm resorting to
>>>> string the numbers as strings. I'm I doing the right thing (other than
>>>> using Access :) ) or missing someting?
>>> Why not use java.math.BigDecimal? ResultSet supports it (getBigDecimal
>>> etc.) and you can (kind of) calculate with it. If scale is 0, it behaves
>>> like integer.
>> You've misunderstood the question of the OP.
>>
>> He doesn't need an alternative to long on the Java side, where obviously a
>> long is sufficient.
>>
>> To change from long to BigDecimal wouldn't solve his problem.
>>
>> As Access/Jet doesn't even support a Java long in numerical form, to change
>> to BigDecimal would be even worse...
>>
>> I believe the OP have to live with his current solution, as Access/Jet most
>> likely will keep the old VB compatible data types only.
>>
>> Depending on what the OP actually uses the fields for, another solution
>> *could* be to bitmask the long value (64 bits) into two int's (32 bits) and
>> store them separately in two fields in the DB, and correspondingly merge
>> them together into one field when retrieving them from the DB...
>>
>> I don't know if he would gain anything with it comparing to the "string"
>> version, but it's nevertheless an alternative...
>>
>> ...or to change to another DB...
>>
>> // Bjorn A
>
> What a complete answer! Thank you very much!
>
> Can I assume that more serious databases, such as MySQL support the
> long format?
>
> Thanks!
>
Would guess most all do.. In this case you are just dealing with Microsoft.

--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
 
Bjorn Abelli





PostPosted: 2006-1-30 18:11:00 Top

java-programmer >> java long in an Access database
<email***@***.com> wrote
> Bjorn Abelli wrote:

>> ...or to change to another DB...
>>
>> // Bjorn A
>
> What a complete answer! Thank you very much!
>
> Can I assume that more serious databases, such as MySQL support the
> long format?

MySQL has the data type BIGINT, which corresponds very well to a Java long
(64 bits integer).

// Bjorn A