| From: | Marek Kałużny <m(dot)kaluzny(at)free4web(dot)pl> |
|---|---|
| To: | pgsql-jdbc(at)postgresql(dot)org |
| Subject: | Type casting |
| Date: | 2003-01-18 23:59:37 |
| Message-ID: | 20030119005937.469b5ab0.m.kaluzny@free4web.pl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-jdbc |
Hi!
I've got following structure:
CREATE TABLE test ( field1 int8 );
CREATE INDEX test_ndx ON test USING btree (field1);
But when I execute following Java code:
PreparedStatement pstmt = con.prepareStatement("SELECT field1 FROM
test WHERE field1=?;");
pstmt.setLong(1, 1);
pstmt.executeQuery();
it doesn't use created index.
When I change my code:
PreparedStatement pstmt = con.prepareStatement("SELECT field1 FROM
test WHERE field1=int8(?);");
pstmt.setLong(1, 1);
pstmt.executeQuery();
then it uses index.
My question is: Shouldn't JDBC Driver automatically cast type basing on
methods setLong, setInt etc. ? You can say: "Change your code, what's
your problem?". But I don't know which database I will use and not all
databases has int8() functions (I think so.). If you know what i mean.
Can you help me ?
P.S. I'm using PostgreSQL 7.3 with last PgSQL JDBC3 Driver.
"PostgreSQL Native Driver (ver.:PostgreSQL 7.3 JDBC3 jdbc driver build
106)"
--
Best regards,
Marek Kaluzny
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Welty | 2003-01-19 01:33:45 | stupid question about loading driver |
| Previous Message | Dave Cramer | 2003-01-18 04:16:06 | Re: Postgresql 7.3.1 + JDBC Build from Source |