Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jdbc(map java varibles to database columns)

Status
Not open for further replies.

mgl70

Programmer
Sep 10, 2003
105
0
0
US
hi,
I could not find any jdbc forum here. Thats why I am posting this message here.
.
I am able to connect to the oracle database and can manipulate data.

How to map java variables to oracle database columns.
That means I have 10variables they should map the database column names. I use those varibales instead of data base column names. I have a user interface. when I click tablename.column name, the variable should remember the column name. This mapping is a is a requirement for my work.

Any idea please...

thanks,
 
you're in the right forum, this forum is for all java questions.<br><br>have you looked at the ResultSetMetaData class? You obtain the meta data for a result set by calling resultSet.getMetaData(), which returns a ResultSetMetaData object. You can then go through each column and call getColumnName(). <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
I think you need to use formpers. You can download it for free from jslope.com. It is a way of using persistence to/from databases.

Ion Filipski
1c.bmp
 
Hi Liam,

I could not find the forum where I posted my question .thats why I could not see your reply. I am sorry.

My javafile has like this.

VARIABLE~varname1~comment~...~
VARIABLE ~varname2~........
VARIABLE ~varname3~....
CONSTANT ~ varname4~......
CONCATINATED~varname5~....

So each variable varname1,varname2,varname3,varname4,varname5 should remember the databasecolumn names.

for example when I click on &quot;emp.ename&quot; , varname1 should remember the column name.Then users donot need to know. so I shoud not use emp.ename. instead I have to use my varname1.

I did not understand exactly mapping and all.
How many types of mapping is there in jdbc?

I understand like this.
javadatatypes------->oracledatatypes
javaclass------------>databasecolumnname

Am I understanding correctly.

I did not understand my problem first.
If you have any example can you please post it?

thanks,




 
Another good persistence framework is Hibernate. It maps to the database and manages connections/connection pooling for you. It can be found at Hibernate.bluemars.net
 
imotic is right. the most flexible way is to use the metadata approach.

In addition, you may want to consider creating a dynamic way of handling oracle database columns so it's not tied to a particular table. Create an oracle view of some sort that selects from 'USER_TAB_COLUMN'. given the column_name = 'your table name', then you can retrieve all the field names associated with this table. Then use a Collection object to tie your keys to the database fields.

Things worth investigating:-
Java Collection Class
ResultMetaData (I use this a lot to create a generic custom tag)

good luck

~za~
You can't bring back a dead thread!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top