Link to home
Start Free TrialLog in
Avatar of snajalm
snajalm

asked on

Trying to make an ODBC connection but no ResultSet gets returned!

I'm trying to make an jdbc-odbc connection like the following.  I get connected but my resultset does not get populated.  What do you think the problem could be.  Here's my code,

String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:" + address + ";user=" + username + ";password=" + password;
DriverManager.getDriver(url);
Class.forName(driver);

PreparedStatement pStmt = conn.prepareStatement(query);
ResultSet rs = pStmt.executeQuery();
Avatar of for_yan
for_yan
Flag of United States of America image

What is your query ?
Avatar of snajalm
snajalm

ASKER

It is a very long query and I can't post it on here due to security reasons!  But do you have any idea of what the situation may be that the server would not return the requested ResultSet despite the fact that the connection is in fact successfully made?!
Maybe query returns nothing?

Does this quesry have no parameters?
If so, why do yiou need to have peraperdStatement?

Try to see what happens with conventional Statement
I'm also usualy claling Class.forName() before Driver.getConnection() though it is probably not important
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of snajalm

ASKER

There is nothing wrong with the query since it has been used from other applications and is valid in terms of execution and providing a valid result!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of snajalm

ASKER

Well, it ended up to be a silly mistake from my side where I was passing the wrong arguments!