pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedissue with select IN (?) query
2+ messages / 2 participants
[nested] [flat]
* issue with select IN (?) query
@ 2008-07-20 13:39 Arun ViswanathanChandrika <Arun.ViswanathanChandrika@ust-global.com>
2008-07-22 06:54 ` Re: issue with select IN (?) query Daniel Migowski <dmigowski@ikoffice.de>
0 siblings, 1 reply; 2+ messages in thread
From: Arun ViswanathanChandrika @ 2008-07-20 13:39 UTC (permalink / raw)
To: pgsql-jdbc
Hi
I am facing an issue with following select query
pm = con.prepareStatement("SELECT EMP_NAME FROM EMP where EMP_ID IN (?) ");
pm.setString(1, "2,5,7"); //created many employees and id with 2, 5 and 7
rs = pm.executeQuery(); // query is not returning any values
Is it a bug?
i was using postgresql-8.3-603.jdbc3.jar
==================================================
the code
===================================================
private static void test()
{
Connection con = null;
PreparedStatement pm = null;
ResultSet rs = null;
try
{
String driver = "org.postgresql.Driver";
String dburl="jdbc:postgresql://localhost/test";
Class.forName(driver);
con = DriverManager.getConnection(dburl, "postgres", "postgres");
pm = con.prepareStatement("SELECT EMP_NAME FROM EMP where EMP_ID IN (?) ");
pm.setString(1, "2,5,7"); //created many employees and id with 2, 5 and 7
rs = pm.executeQuery(); // query is not returning any values
if (rs != null && rs.next()) //not returning any values
{
System.out.println(rs.getString(1));
}
else
System.out.println("Nothing...");
}
catch (Exception ex)
{
ex.printStackTrace();
}
finally
{
try {
rs.close();
pm.close();
con.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
======================================================
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: issue with select IN (?) query
2008-07-20 13:39 issue with select IN (?) query Arun ViswanathanChandrika <Arun.ViswanathanChandrika@ust-global.com>
@ 2008-07-22 06:54 ` Daniel Migowski <dmigowski@ikoffice.de>
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Migowski @ 2008-07-22 06:54 UTC (permalink / raw)
To: Arun ViswanathanChandrika <Arun.ViswanathanChandrika@ust-global.com>; +Cc: pgsql-jdbc
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello Arun,<br>
<br>
Arun ViswanathanChandrika schrieb:
<blockquote
cite="mid:4ADAE57BEACCF2489D5871A8B883F9DD16EE27@TRVMSG.ustr.com"
type="cite">
<p><font size="2"><br>
<br>
pm = con.prepareStatement("SELECT EMP_NAME FROM EMP where
EMP_ID IN (?) ");<br>
pm.setString(1, "2,5,7"); //created many employees and
id with 2, 5 and 7<br>
</font></p>
</blockquote>
Resolves to: <font size="2">SELECT EMP_NAME FROM EMP where EMP_ID IN
('2,5,7');<br>
<br>
Watch the "'"'s :)<br>
<br>
With best regards,<br>
Daniel Migowski</font>
</body>
</html>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2008-07-22 06:54 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-07-20 13:39 issue with select IN (?) query Arun ViswanathanChandrika <Arun.ViswanathanChandrika@ust-global.com>
2008-07-22 06:54 ` Daniel Migowski <dmigowski@ikoffice.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox