session.connection().createStatement().execute("drop table
hts.test1;");
session.connection().createStatement().execute("CREATE TABLE
HTS.TEST1(ID BIGINT, ZEIT DECIMAL(8,7));");
session.connection().createStatement().execute("INSERT INTO HTS.TEST1
(ID, ZEIT) VALUES (1,0.0000008);");
ResultSet rs =
session.connection().createStatement().executeQuery("select * from
hts.test1;");
while (rs.next()){
System.out.println("Test: " + rs.getObject("zeit"));
}
Test: 8E-7
On 15 Jan., 13:46, Christoph Läubrich <[email protected]> wrote:
> Statement stm = connection.createStatement();
> stm.executeUpdate("CREATE TABLE TEST1(ID BIGINT, ZEIT DECIMAL(8,7))");
> stm.executeUpdate("INSERT INTO TEST1 (ID, ZEIT) VALUES (1, 0.000008)");
> stm.executeUpdate("INSERT INTO TEST1 (ID, ZEIT) VALUES (2, '0.000008')");
> ResultSet result = stm.executeQuery("SELECT * FROM TEST1");
> while (result.next()) {
> System.out.println(result.getObject(1) + " = " + result.getObject(2));
>
> }
>
> results in:
> 1 = 0.0000080
> 2 = 0.0000080
>
> so I suspect your using an old version of h2 or the retrival of the data
> is different. This even works with getFloat for me...
> 1 = 8.0E-6
> 2 = 8.0E-6
>
> Am 15.01.2012 13:31, schrieb Jochen Schreiber:
>
>
>
>
>
>
>
> > Try this:
>
> > CREATE TABLE HTS.TEST1(ID BIGINT, ZEIT DECIMAL(8,7))
>
> > INSERT INTO HTS.TEST1 (ID, ZEIT) VALUES (1,0.000008);
>
> > Then the value in Zeit is 0.00001
>
> > On 15 Jan., 13:25, Christoph L ubrich<[email protected]> wrote:
>
> >> I'm using exact decimal in a project with this definition:
> >> CREATE TABLE Eintrag (ID BIGINT AUTO_INCREMENT NOT NULL, ZEIT
> >> DECIMAL(4,2), PRIMARY KEY (ID))
> >> and it works fine, where ZEIT are values like:
> >> 2.34
> >> or something, mabe a bug in the statement parser. Have you tried using a
> >> prepared statment and setBigDecimal(new BigDecimal("0.00008"))?
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.