• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in retieving user defined datatypes

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

Its me again with some problems.

I am accessing the database and populate in a JTable with the help of a tablemodel. I am retrievig the data by


And now using this I am not getting user defined datatypes.
For example: When I access "select * from sysdatabases" the column name will have no values.( name is sysname datatype).

any one have any suggestions.

Ram Mohan.
 
Ram Mohan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know we can cast like following

"
select cast(name as varchar) from Master..sysdatabases

"

and it works ,but I am getting the query from the user in a textarea.

So I cannot dynamically do it.

An alternative I found is
......

Statement stmt = connection.createStatement();
ResultSet rs= stmt.executeQuery("SELECT * FROM emp_table");
if(rs.next()) {
java.sql.Struct empType = (java.sql.Struct)rs.getObject(1);
System.out.println("Number of attributes "+ empType.getAttributes().length);
System.out.println("Name is " + empType.getAttributes()[0]);
System.out.println("Designation is " + empType.getAttributes()[1]);
System.out.println("Department is " + empType.getAttributes()[2]);
}
stmt.close();


......

But it cannot be implemented in TableModel, So pls someone help me.

Ram Mohan
 
reply
    Bookmark Topic Watch Topic
  • New Topic