• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in retieving user defined datatypes

 
Ram Mohan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic