Friday, February 10, 2012

Can't get results from JDBC

I'm having problems getting query results for my web-app using jdbc. The connection I make to the server looks fine, but whenever I execute a query, I get no results. I'm using something like the code below:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con =
java.sql.DriverManager.getConnection(connectionUrl,userName,password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from someTable");
I'm using SQL Squirrel Client as a back-end interface, and it is using the same drivers that my web-app is using, and it has no problems getting results. But everytime, I try to query the database from the servlet that I wrote, the ResultSet that comes back has no results. The exact same query I execute using Squirrel Client, however, is getting the right results. Is there something that I'm missing?

This code looks fine -- if you're still having this issue can you post more of the actual servlet code?

-shelby

Shelby Goerlitz

Microsoft SQL Server Data Programmability

No comments:

Post a Comment