aspose file tools*
The moose likes JDBC and the fly likes Problem in retieving user defined datatypes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem in retieving user defined datatypes" Watch "Problem in retieving user defined datatypes" New topic
Author

Problem in retieving user defined datatypes

Ram Mohan
Greenhorn

Joined: Oct 21, 2005
Posts: 26
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

Joined: Oct 21, 2005
Posts: 26
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
 
 
subject: Problem in retieving user defined datatypes