Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.sql.SQLException: No data found

14 views
Skip to first unread message

Paul Bergin

unread,
Feb 4, 2002, 6:02:41 AM2/4/02
to
Hi,
I have a problem using an ODBC driver when trying to get dbMetaData. I
can connect to the db using the Oracle drivers but if I try connect to
the same db using the ODBC driver and get the metadata I get this
error

Stack Trace:-
java.sql.SQLException: No data found
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown
Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)


I connect to the db like this

if(databaseType()=="Oracle")
{
Class.forName("oracle.jdbc.driver.OracleDriver");
dbUrl = "jdbc:oracle:oci8:@"+getDatabase();
}
else if(databaseType()=="DB2")
{
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
dbUrl = "jdbc:db2:"+getDatabase();
}
else if(databaseType()=="ODBC")
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
dbUrl = "jdbc:odbc:"+getDatabase();
}
con = DriverManager.getConnection(dbUrl,getUserName(),getPassword());

DatabaseMetaData testMetaData = con.getMetaData();
String[] types = {"TABLE","VIEW"};

testDbMetaData = testMetaData.getTables(null,schemaName,null,types);

//the following line is the code which is giving the exception
println("****** results = "+testDbMetaData.getString("TABLE_NAME"));


Hope someone can help me out.

Cheers
P.

Lee Fesperman

unread,
Feb 4, 2002, 2:45:25 PM2/4/02
to
Paul Bergin wrote:
>
> Hi,
> I have a problem using an ODBC driver when trying to get dbMetaData. I
> can connect to the db using the Oracle drivers but if I try connect to
> the same db using the ODBC driver and get the metadata I get this
> error
>
> ...

> //the following line is the code which is giving the exception
> println("****** results = "+testDbMetaData.getString("TABLE_NAME"));
>
> Hope someone can help me out.

The JDBC/ODBC driver requires you to retrieve columns in order, starting at 1 (check
the docs.) The "TABLE_NAME" column is the 3rd column in the resultset. Retrieve columns
1 and 2 first.

--
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
===================================================================
* Check out Database Debunkings (http://www.firstsql.com/dbdebunk/)
* "Where Persistent Prevailing Database Fallacies Are Dispelled"

Paul Bergin

unread,
Feb 5, 2002, 10:51:22 AM2/5/02
to
> > println("****** results = "+testDbMetaData.getString("TABLE_NAME"));
> >
> > Hope someone can help me out.
>
> The JDBC/ODBC driver requires you to retrieve columns in order, starting at 1 (check
> the docs.) The "TABLE_NAME" column is the 3rd column in the resultset. Retrieve columns
> 1 and 2 first.


Thanks that worked,
problem solved.

P

0 new messages