Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with ResultSetMetaData getTableName()

 
Tapan Parikh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am having problems using the function getTableName() in class ResultSetMetaData.
I am using the SUN JDBCODBC Bridge to connect to MS Access... Any ideas? Is this not supported w/ this Driver?
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ideally you shouldn't be having problems.
Can you show us the code?
 
Tapan Parikh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is the very simple code I am using to test this fxnality (after it wasnt working in my other code). This result Set had 5 columns so there is definitely some columns here...
ResultSetMetaData rsmd = rs.getMetaData();
String currentTableName = rsmd.getTableName(1);
 
Tapan Parikh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Btw the prob is that the string returned is an empty string ""
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a snippet of code from one of my programs. It works for me.
Bosun
------------------------------------------------------------
DatabaseMetaData myMT = conn.getMetaData();
String[] myTables = {"TABLE"};
ResultSet tables = myMT.getTables(null,
null, "%", myTables);
String tableName = null;

while (tables.next())
{
tableName = tables.getString("TABLE_NAME");
System.out.println(tableName);
}
System.out.println("DBMS: " + myMT.getDatabaseProductName() + " " + myMT.getDatabaseProductVersion());
 
Tapan Parikh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is not exactly my problem... I am trying to get the table associated with a specific column in a ResultSet generated by a SELECT query. This is important in the case of joins, and also when I just want to find out the particular Table associated with the Results in a ResultSet...
 
Tapan Parikh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Any ideas about this? Does anyone know if Sun's JDBCODBC driver implementation just doesnt support ResultSetMetaData's getTableName() fxn?
 
satish bora
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just wondering whether metadata support is there for the File database-> Access?
 
Jayendranath Krishnamoorthy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I too have the same Problem.I am using oracle.jdbc.driver.OracleDriver Connection.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayendranath,
Welcome to JavaRanch! Note that the original post is three years old. Things may have changed since then.

Can you explain the problem you are getting? Is there an exception being thrown?
 
Jim Tough
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tapan Parikh wrote:
Any ideas about this? Does anyone know if Sun's JDBCODBC driver implementation just doesnt support ResultSetMetaData's getTableName() fxn?


I'm having this problem also. I know this discussion thread is old, but this one comes up in my Google search near the top, so here I am. I found this related post on another site:

http://fixunix.com/weblogic/223501-resultsetmetadata-gettablename-int-column-dont-work.html
Hi. Sorry to be the bearer of bad news, but Oracle's DBMS doesn't
send the information about what table a column came from, so the
oracle driver will never be able to implement that resultset
metadata call. Most DBMSes don't either, and so you will see that
99% of all JDBC drivers will also not implement that call to return
anything useful. Only Sybase, with their very latest driver and
a specific optional DBMS configuration, have done it. It takes
a change in the DBMS that most DBMS vendors will never bother to do.


This seems to be what I'm encountering. In a ResultSet from a SELECT statement with joins, there does not appear to be a way to determine what table a particular column in the result set came from. Not great if you have joined two tables that each have a column with the same name.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic