stefanwagner
Programmer
I don't get the expected results for a PreparedStatement.
I get the expected Result, when using PostgreSQL:
The line 'rs.next ()' is never printed, but if I cut'n'paste the sql-String, and replace the '?' with values:
I get results via Web-iSql or on the sql-console.
And as menntioned above: the same application, running on a postgres-database returns values as expected.
There is no exception thrown, and I don't have an idea how to search for the error further.
I get the expected Result, when using PostgreSQL:
Code:
String sql = "SELECT "
+ " m.attribut, m.mapping "
+ " FROM "
+ " mapping m "
+ " , column c "
+ " WHERE m.c_id = c.c_id "
+ " AND c.tablename = ? "
+ " AND c.columnname = ? ";
try
{
if (! isPrepared)
{
System.out.println ("prepare:");
prepstmt = con.prepareStatement (sql);
isPrepared = true;
}
prepstmt.setString (1, sTablename);
prepstmt.setString (2, sColumnname);
System.out.println ("exec query: " + sql);
ResultSet rs = prepstmt.executeQuery ();
while (rs.next ())
{
System.out.println ("rs.next()");
int id = rs.getInt (1);
// ...
Code:
-- ...
WHERE m.c_id = c.c_id
AND c.tablename = 'JOBS'
AND c.columnname = 'JOB_ID'
And as menntioned above: the same application, running on a postgres-database returns values as expected.
There is no exception thrown, and I don't have an idea how to search for the error further.