Subject | empty result set |
---|---|
Author | esarog |
Post date | 2003-12-03T04:34:05Z |
using the following code example, the metadata from the result set
contain data but the resultset contain 0 rows. what am i doing wrong?
thanks!
import org.firebirdsql.jdbc.FBWrappingDataSource;
import org.firebirdsql.jca.FBConnectionRequestInfo;
import org.firebirdsql.gds.ISCConstants;
import java.sql.*;
public final class SRS_test
{
static public void main (String args[]) throws Exception
{
FBWrappingDataSource dataSource = new FBWrappingDataSource();
dataSource.setDatabase
("localhost/3050:d:/firebird/5050/SRS.FDB");
dataSource.setDescription ("student registration system");
try
{
dataSource.setLoginTimeout (10);
Connection c = dataSource.getConnection
("sysdba", "masterkey");
System.out.println ("got connection");
Statement s = c.createStatement();
final String q = "select * from student";
ResultSet rs = s.executeQuery(q);
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
System.out.println("column count: " + columnCount);
while (rs.next())
{
for (int i = 0; i < columnCount; i++)
{
System.out.print(rs.getString(i + 1) + "|");
}
System.out.print("\n");
}
c.close ();
}
catch (java.sql.SQLException e)
{
e.printStackTrace();
System.out.println ("sql exception: " + e.getMessage ());
}
}
}
contain data but the resultset contain 0 rows. what am i doing wrong?
thanks!
import org.firebirdsql.jdbc.FBWrappingDataSource;
import org.firebirdsql.jca.FBConnectionRequestInfo;
import org.firebirdsql.gds.ISCConstants;
import java.sql.*;
public final class SRS_test
{
static public void main (String args[]) throws Exception
{
FBWrappingDataSource dataSource = new FBWrappingDataSource();
dataSource.setDatabase
("localhost/3050:d:/firebird/5050/SRS.FDB");
dataSource.setDescription ("student registration system");
try
{
dataSource.setLoginTimeout (10);
Connection c = dataSource.getConnection
("sysdba", "masterkey");
System.out.println ("got connection");
Statement s = c.createStatement();
final String q = "select * from student";
ResultSet rs = s.executeQuery(q);
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
System.out.println("column count: " + columnCount);
while (rs.next())
{
for (int i = 0; i < columnCount; i++)
{
System.out.print(rs.getString(i + 1) + "|");
}
System.out.print("\n");
}
c.close ();
}
catch (java.sql.SQLException e)
{
e.printStackTrace();
System.out.println ("sql exception: " + e.getMessage ());
}
}
}